corelib/include/ebcl/SRDText.hh

94 lines
2.9 KiB
C++
Raw Normal View History

/******************************************************************************/
/* SRD - TEXT STORAGE *********************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_SRDTEXT
#define _H_LW_LIB_SRDTEXT
#include <lw/lib/SRDIO.hh>
namespace lw {
/*= READER ===================================================================*/
// Streaming lexer for SRD text
class T_SRDLexer : public A_PrivateImplementation
{
public:
T_SRDLexer( ) = delete;
T_SRDLexer( T_SRDLexer const& ) = delete;
T_SRDLexer( T_SRDLexer&& ) = delete;
T_SRDLexer( T_String const& name , T_SRDErrors& errors , A_SRDReaderTarget& target );
void processCharacter( T_Character c );
void processEnd( );
};
M_CLASS_POINTERS( SRDLexer );
/*----------------------------------------------------------------------------*/
// Text reader - wraps the lexer inside a SRD reader
class T_SRDTextReader : public A_SRDReader
{
public:
T_SRDTextReader( ) = delete;
T_SRDTextReader( T_SRDTextReader const& ) = delete;
T_SRDTextReader( T_SRDTextReader&& ) = delete;
T_SRDTextReader( A_SRDReaderTarget& target );
void read( T_String const& name , A_InputStream& input ) override;
};
M_CLASS_POINTERS( SRDTextReader );
/*----------------------------------------------------------------------------*/
T_SRDList SRDFromText( T_String const& name , T_String const& string , bool structured = true );
T_SRDList SRDFromText( T_String const& name , char const* string , bool structured = true );
/*= WRITER ===================================================================*/
// T_SRDTextWriter - Writer for the text form of SRD
class T_SRDTextWriter : public A_SRDWriter , public A_PrivateImplementation
{
public:
T_SRDTextWriter( ) = delete;
T_SRDTextWriter( T_SRDTextWriter const& ) = delete;
T_SRDTextWriter( T_SRDTextWriter&& ) = delete;
explicit T_SRDTextWriter( A_OutputStream& output );
T_SRDTextWriter& start( ) override;
T_SRDTextWriter& startList( ) override;
T_SRDTextWriter& endList( ) override;
T_SRDTextWriter& putText( T_String const& text ) override;
T_SRDTextWriter& putWord( T_String const& word ) override;
T_SRDTextWriter& putString( T_String const& string ) override;
T_SRDTextWriter& putComment( T_String const& comment ) override;
T_SRDTextWriter& putVariable( T_String const& variable ) override;
T_SRDTextWriter& putBinary( T_Buffer< uint8_t > const& binary ) override;
T_SRDTextWriter& putInteger( int64_t value ) override;
T_SRDTextWriter& putInt32( int32_t value ) override;
T_SRDTextWriter& putInt64( int64_t value ) override;
T_SRDTextWriter& putFloat( double value ) override;
T_SRDTextWriter& end( ) override;
};
M_CLASS_POINTERS( SRDTextWriter );
/*----------------------------------------------------------------------------*/
void SRDWriteAsText( A_OutputStream& output , T_SRDList const& data );
} // namespace
#include <lw/lib/inline/SRDText.hh>
#endif // _H_LW_LIB_SRDTEXT