Atoms Crowd  7.0.0
AtomsCore::Archive Class Reference

Archive class. More...

#include <Serialiser.h>

Public Types

enum  Tags { kNone = 0 , kCompress = 1 , kRandomAccessCompress = 2 , kMultithread = 4 }
 

Public Member Functions

 Archive ()
 Constructor.
 
 Archive (size_t len, size_t tag=kNone)
 Constructor. More...
 
 ~Archive ()
 Destructor. More...
 
bool writeToFile (const std::string &fileName)
 Writes binary stream to a file. More...
 
bool readFromFile (const std::string &fileName)
 Reads a file and store inside the binary stream. More...
 
void reset ()
 Resets the index pointer of the archive.
 
void clear ()
 Clears the binary stream.
 
void resize (size_t len)
 Resize buffer.
 
std::string encodeBase64 (bool compress=false)
 Encode the binary stream in base 64. More...
 
bool decodeBase64 (const std::string &stringValue)
 Reads a base64 string and store inside the binary stream. More...
 

Public Attributes

unsigned char * buffer
 Binary stream.
 
size_t index
 Current binary stream index. More...
 
size_t size
 Memory size of the binary stream.
 
size_t version
 Archive serialization version.
 
std::string headerString
 Header string.
 
size_t tags
 Flags.
 
bool autoDelete
 Autodelete flag. More...
 

Detailed Description

Archive class.

The Archive class is used to serialize or deserialize atoms objects.

Constructor & Destructor Documentation

◆ Archive()

AtomsCore::Archive::Archive ( size_t  len,
size_t  tag = kNone 
)

Constructor.

Parameters
lenLenght of the binary stream (in bytes)
tagSerialization options (can be used togheter):
  • kMultithread: activate multithread serialization
  • kCompress: activate lz4 compression on whole file
  • kRandomAccessCompress: activate lz4 compression on single key-value

◆ ~Archive()

AtomsCore::Archive::~Archive ( )

Destructor.

If the autoDelete flag is on, the destructor deletes the stream buffer before destroying the object

Member Function Documentation

◆ decodeBase64()

bool AtomsCore::Archive::decodeBase64 ( const std::string &  stringValue)

Reads a base64 string and store inside the binary stream.

Parameters
stringValueString
Returns
Return true if the string is read

◆ encodeBase64()

std::string AtomsCore::Archive::encodeBase64 ( bool  compress = false)

Encode the binary stream in base 64.

Parameters
fileNameFile path
Returns
Return the binary stream encoded in base 64

◆ readFromFile()

bool AtomsCore::Archive::readFromFile ( const std::string &  fileName)

Reads a file and store inside the binary stream.

Parameters
fileNameFile path
Returns
Return true if the file is read

◆ writeToFile()

bool AtomsCore::Archive::writeToFile ( const std::string &  fileName)

Writes binary stream to a file.

Parameters
fileNameFile path
Returns
Return true if the file is written

Member Data Documentation

◆ autoDelete

bool AtomsCore::Archive::autoDelete

Autodelete flag.

If this flag is true the binary stream is deleted by the destructor

◆ index

size_t AtomsCore::Archive::index

Current binary stream index.

This store the current index used to read or write the binary stream


The documentation for this class was generated from the following file: