32 #ifndef VLXParserVLT_INCLUDE_ONCE 33 #define VLXParserVLT_INCLUDE_ONCE 119 Log::error(
Say(
"Line %n : error parsing VLT header at '%s'.\n") <<
tokenizer()->lineNumber() << mToken.mString );
139 mLastTag = mToken.mString;
144 st->setLineNumber(
tokenizer()->lineNumber() );
148 if (mToken.mString.length())
149 Log::error(
Say(
"Line %n : parse error at '%s'.\n") << mTokenizer->lineNumber() << mToken.mString.c_str() );
151 Log::error(
Say(
"Line %n : parse error.\n") << mTokenizer->lineNumber() );
159 Log::error(
Say(
"Line %n : parse error at '%s'.\n") << mTokenizer->lineNumber() << mToken.mString.c_str() );
165 Log::error(
Say(
"Line %n : parse error at '%s'.\n") << mTokenizer->lineNumber() << mToken.mString.c_str() );
179 if (!mLastTag.empty())
181 object->setTag(mLastTag.c_str());
195 if (mToken.mString.length() == 2)
197 if (mToken.mString ==
"ID")
200 if (!object->
uid().empty() &&
object->uid() !=
"#NULL")
213 object->setID(mToken.mString.c_str());
221 if (mToken.mString ==
"Id" || mToken.mString ==
"iD" || mToken.mString ==
"id")
230 name_value.
setKey( mToken.mString.c_str() );
244 if (mLastTag.empty())
246 mLastTag = mToken.mString;
268 list->setLineNumber(
tokenizer()->lineNumber() );
300 if (!mLastTag.empty())
308 if (!mLastTag.empty())
316 if (!mLastTag.empty())
318 name_value.
value().
setID(mToken.mString.c_str());
324 if (!mLastTag.empty())
332 if (!mLastTag.empty())
340 if (!mLastTag.empty())
342 name_value.
value().
setReal( atof(mToken.mString.c_str()) );
357 if (!mLastTag.empty())
359 list->
setTag(mLastTag.c_str());
371 switch( mToken.mType )
376 if (mLastTag.empty())
377 mLastTag = mToken.mString;
391 list->
value().push_back( value );
402 sub_list->setLineNumber(
tokenizer()->lineNumber() );
406 list->
value().push_back( value );
420 list->
value().push_back(value);
429 if (!mLastTag.empty())
431 value.
setString( mToken.mString.c_str() ); list->
value().push_back( value );
436 if (!mLastTag.empty())
449 list->
value().push_back( value );
460 if (!mLastTag.empty())
462 value.
setID( mToken.mString.c_str() ); list->
value().push_back( value );
467 if (!mLastTag.empty())
469 value.
setBool( mToken.mString ==
"true" ); list->
value().push_back( value );
474 if (!mLastTag.empty())
476 value.
setInteger( atoll(mToken.mString.c_str()) ); list->
value().push_back( value );
481 if (!mLastTag.empty())
483 value.
setReal( atof(mToken.mString.c_str()) ); list->
value().push_back( value );
497 struct struct_consume_tag
499 struct_consume_tag(
ref<VLXArray>* p1, std::string* p2): p_arr(p1), p_tag(p2) {}
501 ~struct_consume_tag()
503 if ((*p_arr).get() && !p_tag->empty())
505 (*p_arr)->setTag(p_tag->c_str());
512 } consume_tag(&arr, &mLastTag);
565 case VLTToken::Integer: arr_integer->value().push_back( atoll( mToken.mString.c_str() ) );
break;
579 arr_floating->value().reserve(1024);
594 case VLTToken::real: arr_floating->value().push_back( atof( mToken.mString.c_str() ) );
break;
626 case VLTToken::String: printf(
"String = %s\n", mToken.mString.c_str());
break;
627 case VLTToken::ID: printf(
"ID = %s\n", mToken.mString.c_str());
break;
630 case VLTToken::real: printf(
"real = %s\n", mToken.mString.c_str());
break;
639 printf(
"Line %d: syntax error : '%s'.\n", mTokenizer->lineNumber(), mToken.mString.c_str());
648 std::string mLastTag;
VLXRawtextBlock * getRawtextBlock()
double setReal(double val)
long long setInteger(long long val)
void setKey(const char *key)
std::vector< ref< VLXStructure > > mStructures
void setTag(const char *tag)
An abstract class representing a file.
Base class for VLX parsers.
void setValue(const char *value)
A simple String formatting class.
const VLTTokenizer * tokenizer() const
Parses a VLT file translating it into a VLX hierarchy.
VLCORE_EXPORT VLXStructure * setStructure(VLXStructure *)
std::map< std::string, VLXValue > mMetadata
bool parseArray(ref< VLXArray > &arr)
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
VLCORE_EXPORT VLXList * setList(VLXList *)
An array of 64 bits floating point numbers, can also have a tag.
const std::string & setID(const char *str)
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Tokenizer used to parse VLT files.
Visualization Library main namespace.
const std::string & uid() const
VLCORE_EXPORT VLXArray * setArray(VLXArray *)
Key/value pair used by VLXStructure.
bool parseList(VLXList *list)
bool getToken(VLTToken &token)
const std::string & setIdentifier(const char *str)
void setLineNumber(int line)
Wrapper for all VLX value types.
void setLineNumber(int line)
An array of 64 bits integers, can also have a tag.
const std::string & setString(const char *str)
A simple sequence of VLXValue objects, can also have a tag.
A token of information as defined by VLT specification.
The ref<> class is used to reference-count an Object.
VLCORE_EXPORT VLXRawtextBlock * setRawtextBlock(VLXRawtextBlock *)
std::vector< VLXValue > & value()
bool parseStructure(VLXStructure *object)
void parseMetadata()
Moves the <Metadata> key/value pairs in the Metadata map for quick and easy access and removes the <M...
A list of key/VLXValue pairs, can also have a tag.
VLTTokenizer * tokenizer()