Inheritance diagram for code::BOOStream:
For this purpose, it's similar to the ByteOrder class. However, BOOStreams are somewhat more flexible in that
Example:
BOOStream out; out << productId() << productNtr() << ch << iVal << lVal; Buffer buf = out.getBytes();
Public Member Functions | |
BOOStream (bool fileIsLittleEndian=true) | |
virtual | ~BOOStream () |
virtual Buffer | createNetworkFormat () const |
void | clear () |
erase the contents of the output buffer s.t. | |
Buffer | getBytes () const |
Returns a Buffer array of the bytes written to this stream. | |
size_t | getSize () const |
Returns the size, in bytes, of the data written to this stream since its construction or the last time it was clear()ed. | |
size_t | getPos () const |
Returns an index to the current position in the output stream. | |
void | setPos (size_t pos) |
Reposition the stream s.t. | |
void | setPosEnd () |
Move the writer position to the end of the stream s.t. | |
bool | isValid (std::string *setme_error_text=0) const |
Returns true if the object passes its internal sanity checks, false otherwise. | |
virtual BOOStream & | operator<< (char c) |
Write a char to the stream. | |
virtual BOOStream & | operator<< (unsigned char c) |
Write an unsigned char to the stream. | |
virtual BOOStream & | operator<< (int16_t i) |
Write a 16-bit signed integer to the stream. | |
virtual BOOStream & | operator<< (uint16_t i) |
Write a 16-bit unsigned integer to the stream. | |
virtual BOOStream & | operator<< (int32_t i) |
Write a 32-bit signed integer to the stream. | |
virtual BOOStream & | operator<< (uint32_t i) |
Write a 32-bit unsigned integer to the stream. | |
virtual BOOStream & | operator<< (int64_t i) |
Write a 64-bit signed integer to the stream. | |
virtual BOOStream & | operator<< (uint64_t i) |
Write a 64-bit unsigned integer to the stream. | |
virtual BOOStream & | operator<< (bool b) |
Write a bool to the stream. | |
virtual BOOStream & | operator<< (const std::string &) |
Write a string to the stream. | |
virtual BOOStream & | operator<< (float f) |
Write a float to the OutputStream buffer. | |
virtual BOOStream & | operator<< (double d) |
Write a double to the OutputStream buffer. | |
Protected Member Functions | |
void | storeBytes (const char *unswapped_bytes, size_t n) |
void | storeAsIs (const char *swapped_bytes, size_t n) |
template<typename X> | |
BOOStream & | append (const X &x) |
Protected Attributes | |
const bool | _fileOrder |
std::vector< char > | _buf |
size_t | _writepos |
code::BOOStream::BOOStream | ( | bool | fileIsLittleEndian = true |
) |
virtual code::BOOStream::~BOOStream | ( | ) | [inline, virtual] |
BOOStream& code::BOOStream::append | ( | const X & | x | ) | [inline, protected] |
void code::BOOStream::clear | ( | ) | [inline] |
erase the contents of the output buffer s.t.
getSize()==0
virtual Buffer code::BOOStream::createNetworkFormat | ( | ) | const [inline, virtual] |
Buffer code::BOOStream::getBytes | ( | ) | const [inline] |
size_t code::BOOStream::getPos | ( | ) | const [inline] |
Returns an index to the current position in the output stream.
size_t code::BOOStream::getSize | ( | ) | const [inline] |
bool code::BOOStream::isValid | ( | std::string * | setme_error_text = 0 |
) | const |
Returns true if the object passes its internal sanity checks, false otherwise.
setme_error_text | if not null, and if isValid fails, a description of the failure is placed here. This setup is so that isValid can still be embedded in a throwaway assert (ie, "<code>assert(isValid())</code>") and in a exception check (ie, "<code>string s; if ( !isValid(&s) ) throw s;"). |
virtual BOOStream& code::BOOStream::operator<< | ( | double | d | ) | [inline, virtual] |
Write a double to the OutputStream buffer.
WARNING: doubles are not portable. If you are defining a new data format, please use int/long, multiplying your value by the needed precision. This is for those formats that do use double and can not be helped.
l | the long to add. |
Implements code::OutputStream.
virtual BOOStream& code::BOOStream::operator<< | ( | float | f | ) | [inline, virtual] |
Write a float to the OutputStream buffer.
WARNING: floats are not portable. If you are defining a new data format, please use int/long, multiplying your value by the needed precision. This is for those formats that do use float and can not be helped.
l | the long to add. |
Implements code::OutputStream.
virtual BOOStream& code::BOOStream::operator<< | ( | const std::string & | ) | [virtual] |
virtual BOOStream& code::BOOStream::operator<< | ( | bool | b | ) | [inline, virtual] |
virtual BOOStream& code::BOOStream::operator<< | ( | unsigned char | c | ) | [inline, virtual] |
virtual BOOStream& code::BOOStream::operator<< | ( | char | c | ) | [inline, virtual] |
void code::BOOStream::setPos | ( | size_t | pos | ) | [inline] |
Reposition the stream s.t.
subsequent << data will overwrite data in the specified position.
pos | the character index where to write subsequent << data |
void code::BOOStream::setPosEnd | ( | ) | [inline] |
Move the writer position to the end of the stream s.t.
future << calls will append to the stream.
void code::BOOStream::storeAsIs | ( | const char * | swapped_bytes, | |
size_t | n | |||
) | [protected] |
void code::BOOStream::storeBytes | ( | const char * | unswapped_bytes, | |
size_t | n | |||
) | [protected] |
std::vector<char> code::BOOStream::_buf [protected] |
const bool code::BOOStream::_fileOrder [protected] |
size_t code::BOOStream::_writepos [protected] |