Memory stream. More...
#include <mem_stream.h>
Inherits NLMISC::IStream.
Inherited by NLMISC::CBitMemStream, NLMISC::CStringStream, and NLNET::CMessage.
Public Member Functions | |
| CMemStream (bool inputStream=false, bool stringmode=false, uint32 defaultcapacity=0) | |
| Initialization constructor. | |
| CMemStream (const CMemStream &other) | |
| Copy constructor. | |
| CMemStream & | operator= (const CMemStream &other) |
| Assignment operator. | |
| void | swap (CMemStream &other) |
| allocated memory exchange | |
| void | setStringMode (bool stringmode) |
| Set string mode. | |
| bool | stringMode () const |
| Return string mode. | |
| std::string | toString (bool hexFormat=false) const |
| Returns a readable string to display it to the screen. | |
| virtual void | serialBuffer (uint8 *buf, uint len) |
| Method inherited from IStream. | |
| virtual void | serialBit (bool &bit) |
| Method inherited from IStream. | |
| virtual bool | seek (sint32 offset, TSeekOrigin origin) const throw (EStream) |
| Moves the stream pointer to a specified location. | |
| virtual sint32 | getPos () const throw (EStream) |
| Get the location of the stream pointer. | |
| sint32 | reserve (uint len) |
| When writing, skip 'len' bytes and return the position of the blank space for a future poke(). | |
| template<class T > | |
| void | poke (T value, sint32 pos) |
| When writing, fill a value previously reserved by reserve() (warning: you MUST have called reserve() with sizeof(T) before poking). | |
| virtual void | clear () |
| Clears the message. | |
| virtual uint32 | length () const |
| Returns the length (size) of the message, in bytes. | |
| uint32 | size () const |
| Returns the size of the buffer (can be greater than the length, especially in output mode). | |
| virtual const uint8 * | buffer () const |
| Returns a pointer to the message buffer (read only) Returns NULL if the buffer is empty. | |
| void | resetBufPos () |
| When you fill the buffer externaly (using bufferAsVector) you have to reset the BufPos calling this method. | |
| void | fill (const uint8 *srcbuf, uint32 len) |
| Resize the message buffer and fill data at position 0. | |
| void | resize (uint32 size) |
| Resize the buffer. | |
| uint8 * | bufferToFill (uint32 msgsize) |
| Resize the stream with the specified size, set the current position at the beginning of the stream and return a pointer to the stream buffer. | |
| virtual void | invert () |
| Transforms the message from input to output or from output to input. | |
| void | resetPtrTable () |
| Force to reset the ptr table. | |
| void | increaseBufferIfNecessary (uint32 len) |
| Increase the buffer size if 'len' can't enter, otherwise, do nothing. | |
| template<class T > | |
| void | fastSerial (T &val) |
| template<class T > | |
| void | fastWrite (const T &value) |
| template<class T > | |
| void | fastRead (T &value) |
| template<class T > | |
| void | serial (T &obj) |
| Template serialization (should take the one from IStream). | |
| template<class T > | |
| void | serialCont (std::vector< T > &cont) |
| template<class T > | |
| void | serialCont (std::list< T > &cont) |
| template<class T > | |
| void | serialCont (std::deque< T > &cont) |
| template<class T > | |
| void | serialCont (std::set< T > &cont) |
| template<class T > | |
| void | serialCont (std::multiset< T > &cont) |
| template<class K , class T > | |
| void | serialCont (std::map< K, T > &cont) |
| template<class K , class T > | |
| void | serialCont (std::multimap< K, T > &cont) |
| virtual void | serialCont (std::vector< uint8 > &cont) |
| Specialisation of serialCont() for vector<uint8>. | |
| virtual void | serialCont (std::vector< sint8 > &cont) |
| Specialisation of serialCont() for vector<sint8>. | |
| virtual void | serialCont (std::vector< bool > &cont) |
| Specialisation of serialCont() for vector<bool>. | |
| template<class T0 , class T1 > | |
| void | serial (T0 &a, T1 &b) |
| template<class T0 , class T1 , class T2 > | |
| void | serial (T0 &a, T1 &b, T2 &c) |
| template<class T0 , class T1 , class T2 , class T3 > | |
| void | serial (T0 &a, T1 &b, T2 &c, T3 &d) |
| template<class T0 , class T1 , class T2 , class T3 , class T4 > | |
| void | serial (T0 &a, T1 &b, T2 &c, T3 &d, T4 &e) |
| template<class T0 , class T1 , class T2 , class T3 , class T4 , class T5 > | |
| void | serial (T0 &a, T1 &b, T2 &c, T3 &d, T4 &e, T5 &f) |
Base types serialisation, redefined for string mode | |
| virtual void | serial (uint8 &b) |
| virtual void | serial (sint8 &b) |
| virtual void | serial (uint16 &b) |
| virtual void | serial (sint16 &b) |
| virtual void | serial (uint32 &b) |
| virtual void | serial (sint32 &b) |
| virtual void | serial (uint64 &b) |
| virtual void | serial (sint64 &b) |
| virtual void | serial (float &b) |
| virtual void | serial (double &b) |
| virtual void | serial (bool &b) |
| virtual void | serial (char &b) |
| virtual void | serial (std::string &b) |
| virtual void | serial (ucstring &b) |
String-specific methods | |
| uint | serialSeparatedBufferIn (uint8 *buf, uint len) |
| Input: read len bytes at most from the stream until the next separator, and return the number of bytes read. The separator is then skipped. | |
| void | serialSeparatedBufferOut (uint8 *buf, uint len) |
| Output: writes len bytes from buf into the stream. | |
| virtual void | serialHex (uint32 &b) |
| Serialisation in hexadecimal. | |
Protected Member Functions | |
| virtual uint32 | lengthS () const |
| Returns the serialized length (number of bytes written or read). | |
| uint32 | lengthR () const |
| Returns the "read" message size (number of bytes to read) Do not use directly, use length() instead in reading mode (which is virtual). | |
| virtual uint | getDbgStreamSize () const |
| Get the size for this stream. | |
Protected Attributes | |
| CMemStreamBuffer | _Buffer |
| bool | _StringMode |
| uint32 | _DefaultCapacity |
Memory stream.
How output mode works: The buffer size is increased by factor 2. It means the stream can be smaller than the buffer size. The size of the stream is the current position in the stream (given by lengthS() which is equal to getPos()), because data is always written at the end (except when using poke()). About seek() particularities: see comment of the seek() method.
buffer() ----------------------------------- getPos() ---------------- size() data already serialized out | length() = lengthS()
How input mode works: The stream is exactly the buffer (the size is given by lengthR()). Data is read inside the stream, at the current position (given by getPos()). If you try to read data while getPos() is equal to lengthR(), you'll get an EStreamOverflow exception.
buffer() ----------------------------------- getPos() ------------------------- size() data already serialized in data not read yet | length() = lengthR()
Definition at line 140 of file mem_stream.h.
| NLMISC::CMemStream::CMemStream | ( | bool | inputStream = false, |
|
| bool | stringmode = false, |
|||
| uint32 | defaultcapacity = 0 | |||
| ) | [inline] |
Initialization constructor.
Definition at line 145 of file mem_stream.h.
References _Buffer, _DefaultCapacity, NLMISC::CMemStreamBuffer::getBufferWrite(), and NLMISC::CMemStreamBuffer::Pos.
| NLMISC::CMemStream::CMemStream | ( | const CMemStream & | other | ) | [inline] |
| virtual const uint8* NLMISC::CMemStream::buffer | ( | ) | const [inline, virtual] |
Returns a pointer to the message buffer (read only) Returns NULL if the buffer is empty.
Reimplemented in NLNET::CMessage.
Definition at line 299 of file mem_stream.h.
References _Buffer, and NLMISC::CMemStreamBuffer::getBuffer().
Referenced by NLMISC::CBitMemStream::append(), NLMISC::displayBitStream(), NLMISC::CBitMemStream::internalSerial(), NLMISC::CBufFIFO::push(), NLNET::CBufServer::receive(), NLNET::CBufClient::receive(), NLNET::CMessageRecorder::recordNext(), NLMISC::IStream::serialMemStream(), NLMISC::CBitMemStream::serialMemStream(), NL3D::CVectorPacker::serialPackedVector16(), NLMISC::CBitMemStream::serialPoke(), and toString().
Resize the stream with the specified size, set the current position at the beginning of the stream and return a pointer to the stream buffer.
Precondition: the stream is an input stream.
Suggested usage: construct an input stream, resize and get the buffer using bufferToFillAndRead(), fill it with raw data using any filling function (warning: don't fill more than 'msgsize' bytes!), then you are ready to read, using serial(), the data you've just filled.
Reimplemented in NLMISC::CBitMemStream.
Definition at line 350 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBufferWrite(), NLMISC::IStream::isReading(), nlassert, and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLNET::CMessage::extractStreamFromPos(), NLPACS::CGlobalRetriever::CLrLoader::run(), NLNET::TMessageRecord::serial(), NLMISC::IStream::serialMemStream(), and NLNET::CMessage::serialMessage().
| virtual void NLMISC::CMemStream::clear | ( | void | ) | [inline, virtual] |
Clears the message.
Reimplemented in NLMISC::CBitMemStream, and NLNET::CMessage.
Definition at line 262 of file mem_stream.h.
References _Buffer, _DefaultCapacity, NLMISC::CMemStreamBuffer::getBufferWrite(), NLMISC::IStream::isReading(), NLMISC::CMemStreamBuffer::Pos, and resetPtrTable().
Referenced by NLMISC::CBufFIFO::front(), NLMISC::CConfigFile::reparse(), and NLPACS::CGlobalRetriever::CLrLoader::run().
| void NLMISC::CMemStream::fastRead | ( | T & | value | ) | [inline] |
Definition at line 445 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBuffer(), length(), lengthS(), and NLMISC::CMemStreamBuffer::Pos.
| void NLMISC::CMemStream::fastSerial | ( | T & | val | ) | [inline] |
Definition at line 412 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBuffer(), NLMISC::CMemStreamBuffer::getBufferWrite(), increaseBufferIfNecessary(), NLMISC::IStream::isReading(), length(), lengthS(), NLMISC::CMemStreamBuffer::Pos, and serial().
Referenced by serial().
| void NLMISC::CMemStream::fastWrite | ( | const T & | value | ) | [inline] |
Definition at line 435 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBufferWrite(), increaseBufferIfNecessary(), and NLMISC::CMemStreamBuffer::Pos.
Resize the message buffer and fill data at position 0.
Input stream: the current position is set at the beginning; Output stream: the current position is set after the filled data.
Reimplemented in NLMISC::CBitMemStream.
Definition at line 318 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBuffer(), NLMISC::CMemStreamBuffer::getBufferWrite(), NLMISC::IStream::isReading(), NLMISC::CFastMem::memcpy, and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLNET::CMessage::assignFromSubMessage(), NL3D::CTextureMem::doGenerate(), and NLMISC::CBufFIFO::front().
| uint NLMISC::CMemStream::getDbgStreamSize | ( | ) | const [protected, virtual] |
Get the size for this stream.
return 0 by default. Only implemented for input stream that know their size. Used internally to detect OverFlow with vector<> for instance
Reimplemented from NLMISC::IStream.
Definition at line 234 of file mem_stream.cpp.
References NLMISC::IStream::isReading(), and length().
Get the location of the stream pointer.
NB: If the stream doesn't support the seek fonctionnality, it throws ESeekNotSupported. Default implementation: { throw ESeekNotSupported; }
| offset | is the wanted offset from the origin. | |
| origin | is the origin of the seek |
Reimplemented from NLMISC::IStream.
Reimplemented in NLNET::CMessage.
Definition at line 220 of file mem_stream.h.
References _Buffer, and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLMISC::CBitMemStream::append(), NLMISC::CBitMemStream::reserve(), NLNET::TSecurityDataDesc::serial(), NLMISC::CBitMemStream::serial(), NLMISC::CBitMemStream::serialCont(), and NLMISC::CBitMemStream::serialMemStream().
| void NLMISC::CMemStream::increaseBufferIfNecessary | ( | uint32 | len | ) | [inline] |
Increase the buffer size if 'len' can't enter, otherwise, do nothing.
Definition at line 401 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBuffer(), NLMISC::CMemStreamBuffer::getBufferWrite(), and NLMISC::CMemStreamBuffer::Pos.
Referenced by fastSerial(), fastWrite(), reserve(), and serialBuffer().
| virtual void NLMISC::CMemStream::invert | ( | ) | [inline, virtual] |
Transforms the message from input to output or from output to input.
Precondition:
Reimplemented in NLMISC::CBitMemStream, and NLNET::CMessage.
Definition at line 373 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBufferWrite(), NLMISC::IStream::isReading(), lengthR(), NLMISC::CMemStreamBuffer::Pos, resetPtrTable(), and NLMISC::IStream::setInOut().
Referenced by NL3D::CParticleSystemShape::buildFromPS(), NL3D::CAnimationOptimizer::cloneTrack(), NL3D::CParticleSystemShape::flushTextures(), NL3D::CParticleSystemShape::instanciatePS(), NLMISC::CConfigFile::reparse(), and NLPACS::CGlobalRetriever::CLrLoader::run().
| virtual uint32 NLMISC::CMemStream::length | ( | ) | const [inline, virtual] |
Returns the length (size) of the message, in bytes.
If isReading(), it is the number of bytes that can be read, otherwise it is the number of bytes that have been written.
Reimplemented in NLMISC::CBitMemStream, and NLNET::CMessage.
Definition at line 278 of file mem_stream.h.
References NLMISC::IStream::isReading(), lengthR(), and lengthS().
Referenced by fastRead(), fastSerial(), getDbgStreamSize(), NLMISC::CBufFIFO::push(), NLNET::CBufSock::pushBuffer(), NLNET::CBufServer::pushBufferToHost(), NLNET::CMessageRecorder::recordNext(), resize(), NLNET::CBufServer::send(), NLNET::CBufClient::send(), serialBuffer(), NLMISC::IStream::serialMemStream(), serialSeparatedBufferIn(), and toString().
| uint32 NLMISC::CMemStream::lengthR | ( | ) | const [inline, protected] |
Returns the "read" message size (number of bytes to read) Do not use directly, use length() instead in reading mode (which is virtual).
Reimplemented in NLNET::CMessage.
Definition at line 552 of file mem_stream.h.
References size().
Referenced by NLMISC::CBitMemStream::getSerialItem(), NLMISC::CBitMemStream::internalSerial(), invert(), length(), and NLMISC::CBitMemStream::length().
| virtual uint32 NLMISC::CMemStream::lengthS | ( | ) | const [inline, protected, virtual] |
Returns the serialized length (number of bytes written or read).
Reimplemented in NLNET::CMessage.
Definition at line 543 of file mem_stream.h.
References _Buffer, and NLMISC::CMemStreamBuffer::Pos.
Referenced by fastRead(), fastSerial(), length(), NLMISC::CBitMemStream::length(), serialBuffer(), and serialSeparatedBufferIn().
| CMemStream& NLMISC::CMemStream::operator= | ( | const CMemStream & | other | ) | [inline] |
Assignment operator.
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, NLMISC::CStringStream, and NLNET::CMessage.
Definition at line 161 of file mem_stream.h.
References _Buffer, _DefaultCapacity, and _StringMode.
Referenced by CMemStream().
When writing, fill a value previously reserved by reserve() (warning: you MUST have called reserve() with sizeof(T) before poking).
Usually it's an alternative to use serialCont with a vector. Example: uint8 counter=0; sint32 counterPos = msgout.reserve( sizeof(counter) ); counter = serialSelectedItems( msgout ); msgout.poke( counter, counterPos );
Definition at line 251 of file mem_stream.h.
References _Buffer, NLMISC::CMemStreamBuffer::getBufferWrite(), NLMISC::IStream::isReading(), nlassert, and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLNET::TSecurityDataDesc::serial().
When writing, skip 'len' bytes and return the position of the blank space for a future poke().
Warning: this has nothing to do with the semantics of reserve() in std::vector!
Reimplemented in NLMISC::CBitMemStream.
Definition at line 229 of file mem_stream.h.
References _Buffer, increaseBufferIfNecessary(), NLMISC::IStream::isReading(), and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLNET::TSecurityDataDesc::serial().
| void NLMISC::CMemStream::resetBufPos | ( | ) | [inline] |
When you fill the buffer externaly (using bufferAsVector) you have to reset the BufPos calling this method.
If you are using the stream only in output mode, you can use this method as a faster version of clear() *if you don't serialize pointers*.
Reimplemented in NLMISC::CBitMemStream.
Definition at line 311 of file mem_stream.h.
References _Buffer, and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLMISC::IStream::serialMemStream().
| void NLMISC::CMemStream::resetPtrTable | ( | ) | [inline] |
Force to reset the ptr table.
Reimplemented from NLMISC::IStream.
Definition at line 395 of file mem_stream.h.
Referenced by clear(), NL3D::CParticleSystemShape::flushTextures(), NL3D::CParticleSystemShape::instanciatePS(), and invert().
| void NLMISC::CMemStream::resize | ( | uint32 | size | ) |
Resize the buffer.
Warning: the position is unchanged, only the size is changed.
Definition at line 147 of file mem_stream.cpp.
References _Buffer, NLMISC::CMemStreamBuffer::getBufferWrite(), and length().
Referenced by NLNET::CBufServer::receive(), and NLNET::CBufClient::receive().
| bool NLMISC::CMemStream::seek | ( | sint32 | offset, | |
| TSeekOrigin | origin | |||
| ) | const throw (EStream) [virtual] |
Moves the stream pointer to a specified location.
Warning: in output mode, seek(end) does not point to the end of the serialized data, but on the end of the whole allocated buffer (see size()). If you seek back and want to return to the end of the serialized data, you have to store the position (a better way is to use reserve()/poke()).
NB: If the stream doesn't support the seek fonctionnality, it throws ESeekNotSupported. Default implementation: { throw ESeekNotSupported; }
| offset | is the wanted offset from the origin. | |
| origin | is the origin of the seek |
Reimplemented from NLMISC::IStream.
Definition at line 113 of file mem_stream.cpp.
Referenced by NLNET::CMessage::assignFromSubMessage(), NLNET::CMessage::changeType(), NLNET::CMessage::CMessage(), NL3D::CParticleSystemShape::flushTextures(), NLNET::CMessage::getName(), NLNET::getNameOfMessageOrTransportClass(), NLNET::CMessage::getType(), NL3D::CParticleSystemShape::instanciatePS(), NLNET::CMessage::readType(), NLNET::CMessage::readTypeAtCurrentPos(), NLNET::TSecurityDataDesc::serial(), NLNET::CMessage::serialMessage(), and NLNET::CMessage::unlockSubMessage().
| void NLMISC::CMemStream::serial | ( | ucstring & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 912 of file mem_stream.h.
References _StringMode, NLMISC::IStream::checkStreamSize(), NLMISC::IStream::isReading(), NLMISC::SEPARATOR, serial(), and serialBuffer().
| void NLMISC::CMemStream::serial | ( | std::string & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 848 of file mem_stream.h.
References _StringMode, NLMISC::IStream::checkStreamSize(), fastSerial(), NLMISC::IStream::isReading(), NLMISC::IStream::isXML(), NLMISC::SEPARATOR, serial(), and serialBuffer().
| void NLMISC::CMemStream::serial | ( | char & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 823 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), NLMISC::SEPARATOR, and serialBuffer().
| void NLMISC::CMemStream::serial | ( | bool & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 808 of file mem_stream.h.
References _StringMode, fastSerial(), and serialBit().
| void NLMISC::CMemStream::serial | ( | double & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 788 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | float & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 768 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | sint64 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 748 of file mem_stream.h.
References _StringMode, NLMISC::atoiInt64(), fastSerial(), NLMISC::IStream::isReading(), NL_I64, readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | uint64 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 728 of file mem_stream.h.
References _StringMode, NLMISC::atoiInt64(), fastSerial(), NLMISC::IStream::isReading(), NL_I64, readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | sint32 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 708 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | uint32 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 687 of file mem_stream.h.
References _StringMode, NLMISC::atoui(), fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | sint16 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 667 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | uint16 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 646 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | sint8 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 626 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | uint8 & | b | ) | [inline, virtual] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 606 of file mem_stream.h.
References _StringMode, fastSerial(), NLMISC::IStream::isReading(), readnumber, and writenumber.
| void NLMISC::CMemStream::serial | ( | T0 & | a, | |
| T1 & | b, | |||
| T2 & | c, | |||
| T3 & | d, | |||
| T4 & | e, | |||
| T5 & | f | |||
| ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CStringStream.
Definition at line 500 of file mem_stream.h.
References serial().
Referenced by serial().
| void NLMISC::CMemStream::serial | ( | T0 & | a, | |
| T1 & | b, | |||
| T2 & | c, | |||
| T3 & | d, | |||
| T4 & | e | |||
| ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CStringStream.
Definition at line 497 of file mem_stream.h.
References serial().
Referenced by serial().
| void NLMISC::CMemStream::serial | ( | T0 & | a, | |
| T1 & | b, | |||
| T2 & | c, | |||
| T3 & | d | |||
| ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CStringStream.
Definition at line 494 of file mem_stream.h.
References serial().
Referenced by serial().
| void NLMISC::CMemStream::serial | ( | T0 & | a, | |
| T1 & | b, | |||
| T2 & | c | |||
| ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CStringStream.
Definition at line 491 of file mem_stream.h.
References serial().
Referenced by serial().
| void NLMISC::CMemStream::serial | ( | T0 & | a, | |
| T1 & | b | |||
| ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CStringStream.
Definition at line 488 of file mem_stream.h.
References serial().
Referenced by serial().
| void NLMISC::CMemStream::serial | ( | T & | obj | ) | [inline] |
Template serialization (should take the one from IStream).
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 461 of file mem_stream.h.
Referenced by NLNET::CPacsClient::addPrimitive(), NLNET::CUnifiedNetwork::addService(), NLNET::CLoginClient::authenticateBegin(), NLNET::CUnifiedNetwork::autoReconnect(), NLNET::CGatewayL5Transport::cbDispatchL5Message(), NLNET::cbExecCommand(), NLNET::CGatewayL5Transport::cbL5AddTransport(), NLNET::CGatewayL5Transport::cbL5RemoveTransport(), NLNET::cbPacsAnswer(), NLNET::cbQueryPort(), NLNET::cbReceiveShardId(), NLNET::cbRegister(), NLNET::cbRegisterBroadcast(), NLNET::cbServGetView(), NLNET::cbShardChooseShard(), NLNET::cbShardValidate(), NLNET::cbShardValidation(), NLNET::cbTCReceiveOtherSideClass(), NLNET::cbUnregisterBroadcast(), NLNET::cbVerifyLoginPassword(), NLNET::cbWSChooseShard(), NLNET::cbWSDisconnectClient(), NLNET::CMessage::changeType(), NLNET::CTransportClass::className(), NLNET::cleanRequest(), NLNET::CLoginServer::clientDisconnected(), NLNET::CLoginClient::confirmConnection(), NLNET::CCallbackClient::connect(), NLNET::CLoginClient::connectToShard(), NLNET::CTransportClass::createLocalRegisteredClassMessage(), NLNET::createMessage(), NLNET::CNetDisplayer::doDisplay(), NLNET::CPacsClient::evalCollision(), NLLOGIC::CLogicState::exitState(), fastSerial(), NLNET::getNameOfMessageOrTransportClass(), NLNET::CPacsClient::getPositionSpeed(), NLNET::CPacsClient::globalMove(), NLNET::CLoginServer::isValidCookie(), NLNET::notifyWSRemovedPendingCookie(), NLNET::CGatewayL5Transport::onAddTransport(), NLNET::CGatewayL5Transport::onServiceUp(), NLNET::CPacsClient::rayTest(), NLNET::CTransportClass::readHeader(), NLNET::CMessage::readType(), NLNET::CMessage::readTypeAtCurrentPos(), NLNET::CMessageRecorder::recordNext(), NLNET::CPacsClient::relativeMove(), NLNET::CPacsClient::removePrimitive(), NLNET::CMessageRecorder::replayConnectionAttempt(), NLNET::CLoginClient::selectShardBegin(), NLNET::sendAdminEmail(), NLNET::CL5Route::sendMessage(), NLNET::CPacsClient::sendMessage(), NLNET::CStandardGateway::sendPendingModuleUpdate(), NLNET::TModuleSecurityChangeMsg::serial(), NLNET::TModuleDescCodec::serial(), NLNET::TSecurityDataDesc::serial(), NLNET::CInetAddress::serial(), NLNET::CModuleMessageHeaderCodec::serial(), NLNET::TUnknownSecurityData::serial(), NLNET::TMessageRecord::serial(), serial(), serialBit(), serialHex(), NLNET::CMessage::serialMessage(), NLNET::CPacsClient::setAbsorption(), NLNET::CPacsClient::setCollisionMask(), NLNET::CPacsClient::setCurrentPrimitive(), NLNET::CPacsClient::setHeight(), NLNET::CPacsClient::setObstacle(), NLNET::CPacsClient::setOcclusionMask(), NLNET::CPacsClient::setOrientation(), NLNET::CPacsClient::setPrimitiveType(), NLNET::CPacsClient::setRadius(), NLNET::CPacsClient::setReactionType(), NLNET::CPacsClient::setSize(), NLNET::CPacsClient::setTriggerType(), NLNET::CMessage::setType(), NLNET::CPacsClient::testMove(), NLLOGIC::CLogicState::trySendEntryMessages(), NLLOGIC::CLogicState::trySendEventMessages(), NLNET::uncbServiceIdentification(), NLNET::updateAdmin(), and NLNET::CTransportClass::void().
| void NLMISC::CMemStream::serialBit | ( | bool & | bit | ) | [virtual] |
Method inherited from IStream.
Implements NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 83 of file mem_stream.cpp.
References NLMISC::IStream::isReading(), and serial().
Referenced by serial().
Method inherited from IStream.
Implements NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream.
Definition at line 43 of file mem_stream.cpp.
References _Buffer, NLMISC::CMemStreamBuffer::getBuffer(), NLMISC::CMemStreamBuffer::getBufferWrite(), increaseBufferIfNecessary(), NLMISC::IStream::isReading(), length(), lengthS(), NLMISC::CFastMem::memcpy, nlassert, and NLMISC::CMemStreamBuffer::Pos.
Referenced by NLMISC::CConfigFile::reparse(), NLNET::TMessageRecord::serial(), serial(), and NLNET::CMessage::serialMessage().
| virtual void NLMISC::CMemStream::serialCont | ( | std::vector< bool > & | cont | ) | [inline, virtual] |
Specialisation of serialCont() for vector<bool>.
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 483 of file mem_stream.h.
References serialCont().
| virtual void NLMISC::CMemStream::serialCont | ( | std::vector< sint8 > & | cont | ) | [inline, virtual] |
Specialisation of serialCont() for vector<sint8>.
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 481 of file mem_stream.h.
References serialCont().
| virtual void NLMISC::CMemStream::serialCont | ( | std::vector< uint8 > & | cont | ) | [inline, virtual] |
Specialisation of serialCont() for vector<uint8>.
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 479 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::multimap< K, T > & | cont | ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 477 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::map< K, T > & | cont | ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 475 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::multiset< T > & | cont | ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 473 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::set< T > & | cont | ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 471 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::deque< T > & | cont | ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 469 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::list< T > & | cont | ) | [inline] |
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 467 of file mem_stream.h.
References serialCont().
| void NLMISC::CMemStream::serialCont | ( | std::vector< T > & | cont | ) | [inline] |
Reimplemented in NLMISC::CBitMemStream, and NLMISC::CStringStream.
Definition at line 465 of file mem_stream.h.
Referenced by NLNET::cbInfo(), NLNET::cbPacsAnswer(), NLNET::cbRegisterBroadcast(), NLNET::cleanRequest(), NLNET::CTransportClass::propertyCont(), NLNET::CTransportClass::propertyVector(), and serialCont().
| void NLMISC::CMemStream::serialHex | ( | uint32 & | b | ) | [inline, virtual] |
Serialisation in hexadecimal.
Reimplemented in NLMISC::CStringStream.
Definition at line 953 of file mem_stream.h.
References _StringMode, NLMISC::atoihex(), NLMISC::IStream::isReading(), readnumber, serial(), and writenumber.
Referenced by NLNET::TMessageRecord::serial().
Input: read len bytes at most from the stream until the next separator, and return the number of bytes read. The separator is then skipped.
Reimplemented in NLMISC::CStringStream.
Definition at line 158 of file mem_stream.cpp.
References _Buffer, _StringMode, NLMISC::CMemStreamBuffer::getBuffer(), NLMISC::IStream::isReading(), length(), lengthS(), nlassert, NLMISC::CMemStreamBuffer::Pos, NLMISC::SEP_SIZE, and NLMISC::SEPARATOR.
Output: writes len bytes from buf into the stream.
Reimplemented in NLMISC::CStringStream.
Definition at line 192 of file mem_stream.cpp.
References _Buffer, _StringMode, NLMISC::CMemStreamBuffer::getBuffer(), NLMISC::CMemStreamBuffer::getBufferWrite(), NLMISC::IStream::isReading(), NLMISC::CFastMem::memcpy, nlassert, NLMISC::CMemStreamBuffer::Pos, NLMISC::SEP_SIZE, and NLMISC::SEPARATOR.
| void NLMISC::CMemStream::setStringMode | ( | bool | stringmode | ) | [inline] |
Set string mode.
Definition at line 174 of file mem_stream.h.
References _StringMode.
Referenced by NLNET::CMessage::init().
| uint32 NLMISC::CMemStream::size | ( | ) | const [inline] |
Returns the size of the buffer (can be greater than the length, especially in output mode).
Definition at line 291 of file mem_stream.h.
References _Buffer, and NLMISC::CMemStreamBuffer::getBuffer().
Referenced by lengthR(), NLNET::CBufServer::receive(), and NLNET::CBufClient::receive().
| bool NLMISC::CMemStream::stringMode | ( | ) | const [inline] |
Return string mode.
Definition at line 177 of file mem_stream.h.
References _StringMode.
Referenced by NLNET::CInetAddress::serial(), and NLNET::TMessageRecord::serial().
| void NLMISC::CMemStream::swap | ( | CMemStream & | other | ) |
allocated memory exchange
Reimplemented from NLMISC::IStream.
Reimplemented in NLMISC::CBitMemStream, and NLNET::CMessage.
Definition at line 31 of file mem_stream.cpp.
References _Buffer, _DefaultCapacity, _StringMode, and NLMISC::CMemStreamBuffer::swap().
| std::string NLMISC::CMemStream::toString | ( | bool | hexFormat = false |
) | const |
Returns a readable string to display it to the screen.
It's only for debugging purpose! Don't use it for anything else than to debugging, the string format could change in the future.
| hexFormat | If true, display all bytes in hexadecimal, else display as chars (above 31, otherwise '.') |
Definition at line 215 of file mem_stream.cpp.
References buffer(), length(), and NLMISC::toString().
Referenced by NLMISC::CBitMemStream::displayStream(), and NLMISC::CBitMemStream::getSerialItem().
CMemStreamBuffer NLMISC::CMemStream::_Buffer [protected] |
Definition at line 562 of file mem_stream.h.
Referenced by NLNET::CMessage::buffer(), buffer(), bufferToFill(), clear(), CMemStream(), NLMISC::CBitMemStream::displayStream(), fastRead(), fastSerial(), fastWrite(), fill(), NLNET::CMessage::getName(), NLNET::CMessage::getPos(), getPos(), NLMISC::CBitMemStream::getPosInBit(), NLMISC::CBitMemStream::getSerialItem(), NLNET::CMessage::getType(), increaseBufferIfNecessary(), NLMISC::CBitMemStream::increaseBufferIfNecessary(), NLMISC::CBitMemStream::internalSerial(), NLNET::CMessage::invert(), invert(), NLMISC::CBitMemStream::invert(), NLNET::CMessage::lengthS(), lengthS(), operator=(), NLMISC::CBitMemStream::pointNextByte(), NLMISC::CBitMemStream::poke(), poke(), NLMISC::CBitMemStream::pokeBits(), NLMISC::CBitMemStream::prepareNextByte(), reserve(), resetBufPos(), NLMISC::CBitMemStream::resetBufPos(), NLNET::CMessage::resetSubMessageInternals(), resize(), serialBuffer(), NLMISC::CBitMemStream::serialPoke(), serialSeparatedBufferIn(), serialSeparatedBufferOut(), size(), and swap().
uint32 NLMISC::CMemStream::_DefaultCapacity [protected] |
Definition at line 566 of file mem_stream.h.
Referenced by clear(), CMemStream(), operator=(), and swap().
bool NLMISC::CMemStream::_StringMode [mutable, protected] |
Definition at line 564 of file mem_stream.h.
Referenced by operator=(), NLNET::CMessage::readType(), NLNET::CMessage::readTypeAtCurrentPos(), NLMISC::CBitMemStream::serial(), serial(), serialHex(), serialSeparatedBufferIn(), serialSeparatedBufferOut(), setStringMode(), NLNET::CMessage::setType(), stringMode(), and swap().
1.6.1