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>
128 bool skip(
const uint64_t bytes);
149 explicit inline operator bool()
const;
232 template <
typename T>
242 bool write(
const void* data,
const size_t size);
254 explicit inline operator bool()
const;
283 using TagSet = std::unordered_set<unsigned long long>;
292 static inline bool registerTag(
const unsigned long long tag);
314 inline explicit Tag(
const char tagString[8]);
321 inline bool operator==(
const Tag& tag)
const;
328 inline bool operator!=(
const Tag& tag)
const;
334 inline unsigned long long value()
const;
340 inline unsigned long long& value();
391 static constexpr unsigned long long string2tag(
const char tagString[8]);
413inline InputBitstream::operator bool()
const
415 return inputStream_.good();
418inline OutputBitstream::operator bool()
const
420 return outputStream_.good();
430 tagValue_(string2tag(tagString))
442 return !(*
this == tag);
457 ocean_assert(tagString[0] != 0 && tagString[1] != 0 && tagString[2] != 0 && tagString[3] != 0
458 && tagString[4] != 0 && tagString[5] != 0 && tagString[6] != 0 && tagString[7] != 0);
460 return ((
unsigned long long)tagString[0] << 0ull)
461 | ((
unsigned long long)tagString[1] << 8ull)
462 | ((
unsigned long long)tagString[2] << 16ull)
463 | ((
unsigned long long)tagString[3] << 24ull)
464 | ((
unsigned long long)tagString[4] << 32ull)
465 | ((
unsigned long long)tagString[5] << 40ull)
466 | ((
unsigned long long)tagString[6] << 48ull)
467 | ((
unsigned long long)tagString[7] << 56ull);
This class implements an output bitstream.
Definition Bitstream.h:215
uint64_t 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...
std::ostream & outputStream_
The internal output stream object that this object encapsulates.
Definition Bitstream.h:259
bool write(const T &value)
Writes a data object to the stream and moves the internal position inside the bitstream accordingly.
This class implements a tag manager that allows to ensure that tags are not defined twice.
Definition Bitstream.h:277
std::unordered_set< unsigned long long > TagSet
Definition of a set holding tag values.
Definition Bitstream.h:283
static bool registerTag(const unsigned long long tag)
Registers a new tag value.
Definition Bitstream.h:472
TagSet tagsSet_
The set of registered tag values.
Definition Bitstream.h:297
This class implements a tag that allows to identify specific objects in an input/output stream.
Definition Bitstream.h:268
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:455
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:435
unsigned long long value() const
Returns the unique 64 bit tag value of this tag object.
Definition Bitstream.h:445
bool operator!=(const Tag &tag) const
Returns whether two tag objects are not identical.
Definition Bitstream.h:440
Tag()
Creates a new invalid tag object.
Definition Bitstream.h:423
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:396
The namespace covering the entire Ocean framework.
Definition Accessor.h:15