32 #ifndef VLXValue_INCLUDE_ONCE 33 #define VLXValue_INCLUDE_ONCE 63 const std::string&
tag()
const {
return mTag; }
84 std::string&
value() {
return mValue; }
86 const std::string&
value()
const {
return mValue; }
88 void setValue(
const char* value) { mValue = value; }
116 std::vector<T>&
value() {
return mValue; }
118 const std::vector<T>&
value()
const {
return mValue; }
120 T*
ptr() {
if (mValue.empty())
return NULL;
else return &mValue[0]; }
122 const T*
ptr()
const {
if (mValue.empty())
return NULL;
else return &mValue[0]; }
124 template<
typename T2>
void copyTo(T2*ptr)
const {
for(
size_t i=0; i<mValue.size(); ++i, ++ptr) *ptr = (T2)mValue[i]; }
126 template<
typename T2>
void copyFrom(
const T2*ptr) {
for(
size_t i=0; i<mValue.size(); ++i, ++ptr) mValue[i] = (scalar_type)*ptr; }
129 std::vector<T> mValue;
298 setRawtextBlock(rawtext);
306 setArrayInteger(arr);
365 case String: setString(str);
break;
366 case Identifier: setIdentifier(str);
break;
367 case ID: setID(str);
break;
456 mUnion.mString =
new std::string(str);
457 return *mUnion.mString;
468 mUnion.mString =
new std::string(str);
469 return *mUnion.mString;
476 const std::string&
setID(
const char* str)
480 mUnion.mString =
new std::string(str);
481 return *mUnion.mString;
484 const std::string&
getID()
const {
VL_CHECK(mType == ID);
return *mUnion.mString; }
492 return mUnion.mInteger = val;
503 return mUnion.mReal = val;
514 return mUnion.mBool = val;
548 mKeyValue.reserve(16);
554 mKeyValue.reserve(16);
561 mKeyValue.reserve(16);
570 value().resize( value().size() + 1 );
571 value().back().setKey(str);
577 value().back().setValue(val);
590 std::string&
key() {
return mKey; }
591 const std::string&
key()
const {
return mKey; }
592 void setKey(
const char* key) { mKey = key; }
603 void setID(
const char* uid) { mID = uid; }
605 const std::string&
uid()
const {
return mID; }
607 std::vector<KeyValue>&
value() {
return mKeyValue; }
609 const std::vector<KeyValue>&
value()
const {
return mKeyValue; }
614 for(
size_t i=0; i<mKeyValue.size(); ++i)
615 if (mKeyValue[i].key() == key)
616 return &mKeyValue[i].value();
622 for(
size_t i=0; i<mKeyValue.size(); ++i)
623 if (mKeyValue[i].key() == key)
624 return &mKeyValue[i].value();
630 std::vector<KeyValue> mKeyValue;
646 value().push_back( val );
652 std::vector< VLXValue >&
value() {
return mValue; }
654 const std::vector< VLXValue >&
value()
const {
return mValue; }
657 std::vector< VLXValue > mValue;
VLXList(const char *tag=NULL)
double setReal(double val)
const std::vector< VLXValue > & value() const
void setKey(const char *key)
VLXValue(VLXArrayInteger *arr)
VLXRawtextBlock * getRawtextBlock()
VLXStructure * mStructure
VLXRawtextBlock(const char *tag=NULL, const char *value=NULL)
Wrapper for all VLX value types.
VLXValue(VLXStructure *obj)
const std::vector< KeyValue > & value() const
virtual void acceptVisitor(Visitor *v)
vlX::VLXValue * getValue(const char *key)
void setValue(const char *value)
VLXStructure(const char *tag)
Key/value pair used by VLXStructure.
long long setInteger(long long val)
void setLineNumber(int line)
void setTag(const char *tag)
void copyTo(T2 *ptr) const
VLXTaggedValue(const char *tag=NULL)
void copyFrom(const T2 *ptr)
An array of 64 bits floating point numbers, can also have a tag.
const VLXArrayInteger * getArrayInteger() const
const std::string & value() const
VLXArray(const char *tag=NULL)
const std::string & getID() const
virtual void acceptVisitor(Visitor *v)
VLXStructure * getStructure()
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
VLXValue(VLXArrayReal *arr)
const VLXList * getList() const
const std::string & setIdentifier(const char *str)
std::vector< VLXValue > & value()
const std::string & setString(const char *str)
long long getInteger() const
A list of key/VLXValue pairs, can also have a tag.
void setID(const char *uid)
const std::vector< T > & value() const
const vlX::VLXValue & value() const
VLXArrayReal(const char *tag=NULL)
const std::string & key() const
void setValue(const vlX::VLXValue &value)
VLXArrayInteger(const char *tag=NULL)
A simple sequence of VLXValue objects, can also have a tag.
The base class for all the reference counted objects.
virtual ~VLXTaggedValue()
const std::string & tag() const
VLXValue(VLXRawtextBlock *rawtext)
virtual void acceptVisitor(Visitor *v)
virtual void acceptVisitor(Visitor *v)
void setLineNumber(int line)
std::vector< KeyValue > & value()
VLXStructure & operator<<(const vlX::VLXValue &val)
const VLXRawtextBlock * getRawtextBlock() const
virtual void visitList(VLXList *)
An array of 64 bits integers, can also have a tag.
std::vector< T > & value()
Base class for all visitors visiting a VLX hierarchy.
const VLXStructure * getStructure() const
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
virtual void acceptVisitor(Visitor *)=0
const std::string & setID(const char *str)
Base class for VLX values with a tag.
const std::string & uid() const
VLXValue(const char *str, EType type)
VLXValue(const VLXValue &other)
VLXArrayTemplate(const char *tag=NULL)
Base class for all arrays of VLX values.
const VLXArrayReal * getArrayReal() const
const vlX::VLXValue * getValue(const char *key) const
VLXArrayInteger * getArrayInteger()
KeyValue(const char *key, vlX::VLXValue value)
VLXRawtextBlock * mRawtextBlock
VLXStructure & operator<<(const char *str)
const std::string & getString() const
virtual void acceptVisitor(Visitor *v)
virtual void visitArray(VLXArrayInteger *)
VLXArrayReal * getArrayReal()
Object & operator=(const Object &other)
Copy operator: copies the object's name, ref count mutex and user data.
virtual void visitRawtextBlock(VLXRawtextBlock *)
VLXList & operator<<(const VLXValue &val)
VLXStructure(const char *tag, const std::string &uid)
const std::string & getIdentifier() const
virtual void visitStructure(VLXStructure *)