25#include "sexpr/isexprable.h"
26#include "sexpr/sexpr_exception.h"
34 enum class SEXPR_TYPE :
char
37 SEXPR_TYPE_ATOM_INTEGER,
38 SEXPR_TYPE_ATOM_DOUBLE,
39 SEXPR_TYPE_ATOM_STRING,
40 SEXPR_TYPE_ATOM_SYMBOL,
43 typedef std::vector< class SEXPR * > SEXPR_VECTOR;
49 bool IsList()
const {
return m_type == SEXPR_TYPE::SEXPR_TYPE_LIST; }
50 bool IsSymbol()
const {
return m_type == SEXPR_TYPE::SEXPR_TYPE_ATOM_SYMBOL; }
51 bool IsString()
const {
return m_type == SEXPR_TYPE::SEXPR_TYPE_ATOM_STRING; }
52 bool IsDouble()
const {
return m_type == SEXPR_TYPE::SEXPR_TYPE_ATOM_DOUBLE; }
53 bool IsInteger()
const {
return m_type == SEXPR_TYPE::SEXPR_TYPE_ATOM_INTEGER; }
54 void AddChild(
SEXPR* aChild );
55 SEXPR_VECTOR
const * GetChildren()
const;
56 SEXPR * GetChild(
size_t aIndex )
const;
57 size_t GetNumberOfChildren()
const;
58 int64_t GetLongInteger()
const;
59 int32_t GetInteger()
const;
60 float GetFloat()
const;
61 double GetDouble()
const;
62 std::string
const & GetString()
const;
63 std::string
const & GetSymbol()
const;
65 std::string AsString(
size_t aLevel = 0)
const;
66 size_t GetLineNumber()
const {
return m_lineNumber; }
70 SEXPR( SEXPR_TYPE aType,
size_t aLineNumber );
71 SEXPR( SEXPR_TYPE aType );
80 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_INTEGER ), m_value( aValue ) {};
83 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_INTEGER, aLineNumber ), m_value( aValue ) {};
91 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_DOUBLE ), m_value( aValue ) {};
94 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_DOUBLE, aLineNumber ), m_value( aValue ) {};
102 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_STRING ), m_value( aValue ) {};
104 SEXPR_STRING(
const std::string& aValue,
int aLineNumber ) :
105 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_STRING, aLineNumber ), m_value( aValue ) {};
113 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_SYMBOL ), m_value( aValue ) {};
115 SEXPR_SYMBOL(
const std::string& aValue,
int aLineNumber ) :
116 SEXPR( SEXPR_TYPE::SEXPR_TYPE_ATOM_SYMBOL, aLineNumber ), m_value( aValue ) {};
122 const std::string& _String;
125 inline _OUT_STRING AsSymbol(
const std::string& aString )
131 inline _OUT_STRING AsString(
const std::string& aString )
133 struct _OUT_STRING ret = {
false, aString };
140 std::string& _String;
143 inline _IN_STRING AsSymbol( std::string& aString )
149 inline _IN_STRING AsString( std::string& aString )
151 struct _IN_STRING ret = {
false, aString };
159 type( Type::INT ) { u.int_value = aValue; }
162 type( Type::LONGINT ) { u.lint_value = aValue; }
165 type( Type::DOUBLE ) { u.dbl_value = aValue; }
168 type( Type::STRING ) { u.str_value = aValue; }
171 type( Type::SEXPR_STRING ) { u.sexpr_str = &aValue; }
174 type( Type::STRING_COMP ) { str_value = *aValue; }
177 type( Type::STRING_COMP ) { str_value = aValue; }
180 type( Type::STRING_COMP ) { str_value = aValue; }
185 enum class Type :
char { INT, DOUBLE, STRING, LONGINT, STRING_COMP,
SEXPR_STRING };
193 std::string* str_value;
197 std::string str_value;
204 type( Type::INT ) { u.int_value = aValue; }
207 type( Type::LONGINT ) { u.lint_value = aValue; }
210 type( Type::DOUBLE ) { u.dbl_value = aValue; }
213 type( Type::STRING ) { str_value = aValue; }
216 type( Type::STRING ) { str_value = aValue; }
219 type( Type::SEXPR_STRING ) { str_value = aValue._String; u.symbol = aValue._Symbol; }
222 type( Type::SEXPR_ATOM ) { u.sexpr_ptr = aPointer; }
227 enum class Type :
char { INT, DOUBLE, STRING, LONGINT,
SEXPR_STRING, SEXPR_ATOM };
239 std::string str_value;
245 SEXPR_LIST() :
SEXPR( SEXPR_TYPE::SEXPR_TYPE_LIST ), m_inStreamChild( 0 ) {};
248 SEXPR( SEXPR_TYPE::SEXPR_TYPE_LIST, aLineNumber), m_inStreamChild( 0 ) {};
250 template <
typename... Args>
252 SEXPR( SEXPR_TYPE::SEXPR_TYPE_LIST ), m_inStreamChild( 0 )
254 AddChildren(args...);
257 SEXPR_VECTOR m_children;
259 template <
typename... Args>
260 size_t Scan(
const Args&... args )
263 return doScan( arg_array,
sizeof...( Args ) );
266 template <
typename... Args>
267 void AddChildren(
const Args&... args )
270 doAddChildren( arg_array,
sizeof...( Args ) );
Definition: isexprable.h:29
_t< detail::is_< T, C > > is
is
Definition: meta.hpp:874