8 #ifndef META_OCEAN_IO_BITSTREAM_H
9 #define META_OCEAN_IO_BITSTREAM_H
92 bool read(
void* data,
const size_t size);
101 template <
typename T>
114 unsigned long long size()
const;
127 explicit inline operator bool()
const;
185 template <
typename T>
195 bool write(
const void* data,
const size_t size);
201 unsigned long long size()
const;
207 explicit inline operator bool()
const;
236 typedef std::set<unsigned long long>
TagSet;
245 static inline bool registerTag(
const unsigned long long tag);
267 inline explicit Tag(
const char tagString[8]);
274 inline bool operator==(
const Tag& tag)
const;
281 inline bool operator!=(
const Tag& tag)
const;
287 inline unsigned long long value()
const;
293 inline unsigned long long& value();
344 static constexpr
unsigned long long string2tag(
const char tagString[8]);
354 streamStartPosition_((unsigned long long)(-1))
367 inline InputBitstream::operator bool()
const
369 return inputStream.good();
372 inline OutputBitstream::operator bool()
const
374 return outputStream.good();
384 tagValue_(string2tag(tagString))
396 return !(*
this == tag);
411 ocean_assert(tagString[0] != 0 && tagString[1] != 0 && tagString[2] != 0 && tagString[3] != 0
412 && tagString[4] != 0 && tagString[5] != 0 && tagString[6] != 0 && tagString[7] != 0);
414 return ((
unsigned long long)tagString[0] << 0ull)
415 | ((
unsigned long long)tagString[1] << 8ull)
416 | ((
unsigned long long)tagString[2] << 16ull)
417 | ((
unsigned long long)tagString[3] << 24ull)
418 | ((
unsigned long long)tagString[4] << 32ull)
419 | ((
unsigned long long)tagString[5] << 40ull)
420 | ((
unsigned long long)tagString[6] << 48ull)
421 | ((
unsigned long long)tagString[7] << 56ull);
430 const bool newTag = manager.
tagsSet.find(tag) == manager.
tagsSet.end();
This class implements an output bitstream.
Definition: Bitstream.h:168
unsigned long long size() const
Returns the current size of the bitstream, in bytes.
OutputBitstream(std::ostream &stream)
Creates a new output bitstream object.
bool write(const void *data, const size_t size)
Writes a defined memory block from a given buffer into the stream and moves the internal position ins...
bool write(const T &value)
Writes a data object to the stream and moves the internal position inside the bitstream accordingly.
std::ostream & outputStream
The internal output stream object that this object encapsulates.
Definition: Bitstream.h:212
This class implements a tag manager that allows to ensure that tags are not defined twice.
Definition: Bitstream.h:230
std::set< unsigned long long > TagSet
Definition of a set holding tag values.
Definition: Bitstream.h:236
TagSet tagsSet
The set of registered tag values.
Definition: Bitstream.h:250
static bool registerTag(const unsigned long long tag)
Registers a new tag value.
Definition: Bitstream.h:426
This class implements a tag that allows to identify specific objects in an input/output stream.
Definition: Bitstream.h:221
static bool writeTag(OutputBitstream &bitstream, const Tag &tag)
Writes a tag to a bitstream.
static constexpr unsigned long long string2tag(const char tagString[8])
Converts a string with exactly eight characters to a unique tag value.
Definition: Bitstream.h:409
static bool lookTag(InputBitstream &bitstream, Tag &tag)
Reads (only a look) a tag from a bitstream.
static bool lookAndCheckTag(InputBitstream &bitstream, const Tag &expectedTag)
Reads (only a look) a tag from a bitstream and checks whether the tag is identical with an expectedTa...
static bool readAndCheckTag(InputBitstream &bitstream, const Tag &expectedTag)
Reads a tag from a bitstream and checks whether the tag is identical with an expectedTag tag.
bool operator==(const Tag &tag) const
Returns whether two tag objects are identical.
Definition: Bitstream.h:389
unsigned long long value() const
Returns the unique 64 bit tag value of this tag object.
Definition: Bitstream.h:399
bool operator!=(const Tag &tag) const
Returns whether two tag objects are not identical.
Definition: Bitstream.h:394
Tag()
Creates a new invalid tag object.
Definition: Bitstream.h:377
static bool readTag(InputBitstream &bitstream, Tag &tag)
Reads a tag from a bitstream.
unsigned long long tagValue_
The tag value of this tag object.
Definition: Bitstream.h:349
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15