78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
/******************************************************************************/
|
|
/* SRD - BINARY STORAGE *******************************************************/
|
|
/******************************************************************************/
|
|
|
|
#ifndef _H_EBCL_SRDBINARY
|
|
#define _H_EBCL_SRDBINARY
|
|
#include <ebcl/SRDIO.hh>
|
|
#include <ebcl/HashIndex.hh>
|
|
namespace ebcl {
|
|
|
|
|
|
/*= WRITER ===================================================================*/
|
|
|
|
class T_SRDBinaryWriter : public A_SRDWriter
|
|
{
|
|
private:
|
|
T_BinaryWriter writer_;
|
|
T_HashIndex wordsIndex_;
|
|
T_Array< T_String > words_;
|
|
T_StringBuilder comment_;
|
|
uint32_t depth_;
|
|
|
|
void flushComment( );
|
|
void writeWord( T_String const& word );
|
|
|
|
public:
|
|
T_SRDBinaryWriter( ) = delete;
|
|
T_SRDBinaryWriter( T_SRDBinaryWriter const& ) = delete;
|
|
T_SRDBinaryWriter( T_SRDBinaryWriter&& ) = delete;
|
|
|
|
explicit T_SRDBinaryWriter( A_OutputStream& output );
|
|
|
|
T_SRDBinaryWriter& start( ) override;
|
|
|
|
T_SRDBinaryWriter& startList( ) override;
|
|
T_SRDBinaryWriter& endList( ) override;
|
|
|
|
T_SRDBinaryWriter& putText( T_String const& text ) override;
|
|
T_SRDBinaryWriter& putWord( T_String const& word ) override;
|
|
T_SRDBinaryWriter& putString( T_String const& string ) override;
|
|
|
|
T_SRDBinaryWriter& putComment( T_String const& comment ) override;
|
|
|
|
T_SRDBinaryWriter& putVariable( T_String const& variable ) override;
|
|
|
|
T_SRDBinaryWriter& putBinary( T_Buffer< uint8_t > const& binary ) override;
|
|
|
|
T_SRDBinaryWriter& putInteger( int64_t value ) override;
|
|
T_SRDBinaryWriter& putInt32( int32_t value ) override;
|
|
T_SRDBinaryWriter& putInt64( int64_t value ) override;
|
|
|
|
T_SRDBinaryWriter& putFloat( double value ) override;
|
|
|
|
T_SRDBinaryWriter& end( ) override;
|
|
};
|
|
|
|
void SRDBinaryWriteTo( A_OutputStream& output , T_SRDList const& data );
|
|
|
|
|
|
/*= READER ===================================================================*/
|
|
|
|
class T_SRDBinaryReader : public A_SRDReader
|
|
{
|
|
public:
|
|
T_SRDBinaryReader( ) = delete;
|
|
T_SRDBinaryReader( T_SRDBinaryReader const& ) = delete;
|
|
T_SRDBinaryReader( T_SRDBinaryReader&& ) = delete;
|
|
|
|
T_SRDBinaryReader( A_SRDReaderTarget& target );
|
|
void read( T_String const& name , A_InputStream& input ) override;
|
|
};
|
|
|
|
T_SRDList SRDBinaryReadFrom( T_String const& name , A_InputStream& input , bool structured = true );
|
|
|
|
|
|
} // namespace
|
|
#include <ebcl/inline/SRDBinary.hh>
|
|
#endif // _H_EBCL_SRDBINARY
|