3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
TagsList Class Reference

This class intended to load/save the class derived from the BaseClass as XML/JSON. But it may be used just for XML/JSON load/save. Pay attention, attributes of the XML not supported. More...

#include <TagsList.h>

Public Member Functions

 TagsList (const char *QuoteName)
 
void operator delete (void *ptr, size_t size)
 
void * operator new (size_t size)
 
int to_int () const
 convert tag value to int
 
float to_float () const
 convert tag value to float
 
bool to_bool () const
 convert tag value to bool
 
const char * to_string () const
 get value of the tag
 
float to_float ()
 get value of the tag as float
 
int get_data (void *buffer, int maxlength)
 get value of the tag as the data array, returns the actual data length
 
int GetTagsFromString (const char *XMLSource)
 convert string to the tags structure
 
int PutTagsIntoString (comms::cStr *To, int shift=0)
 convert tags structure to the string
 
int GetTagsFromJsonString (const char *jsonSource)
 convert string to the tags structure
 
int PutTagsIntoJsonString (comms::cStr *Source, int shift=0, bool treatAllAsText=false)
 convert tags structure to the string
 
bool ReadTagsFromFile (const char *FilePath)
 read tags from file
 
void WriteTagsToFile (const char *FilePath, bool OnlyChanged=false)
 save tags to file
 
void Assign (int v)
 assign int value to the tag value
 
void Assign (const char *s)
 assign string value to the tag
 
void SetParent (TagsList *Parent)
 
TagsListGetParent () const
 
TagsListAddSubTag (TagsList *SubQ)
 Add already allocated tag to the tags list within this tag.
 
TagsListAddSubTag (const char *quotename, const char *body="")
 Add new tag to the tags list within this tag.
 
TagsListAddSubTag (const char *quotename, int body)
 Add new tag with integer value to the tags list within this tag.
 
TagsListAddSubTag (const char *quotename, DWORD body)
 
TagsListAddSubTag (const char *quotename, short body)
 
TagsListAddSubTag (const char *quotename, WORD body)
 
TagsListAddSubTag (const char *quotename, char body)
 
TagsListAddSubTag (const char *quotename, float body)
 Add new tag with the floating point value.
 
TagsListAddSubTag (const char *quotename, void *data, int Length)
 Add new tag with the data array.
 
TagsListoperator<< (const char *string)
 
TagsListoperator<< (int value)
 
TagsListoperator<< (bool value)
 
TagsListoperator<< (float value)
 
TagsListoperator<< (const comms::cVec2 &value)
 
TagsListoperator<< (const comms::cVec3 &value)
 
TagsListoperator<< (const comms::cVec4 &value)
 
TagsListoperator<< (const comms::cMat3 &value)
 
TagsListoperator<< (const comms::cMat4 &value)
 
TagsListoperator<< (BaseClass *BC)
 
template<class X >
TagsListoperator<< (const cList< X > &array)
 
template<typename X , typename TYPE >
void StoreField (const char *tagname, const cList< X > &array, TYPE X::*member)
 
void operator>> (comms::cStr &string_value)
 read values from the tags list
 
void operator>> (int &value)
 
void operator>> (float &value)
 
void operator>> (bool &value)
 
void operator>> (comms::cVec2 &value)
 
void operator>> (comms::cVec3 &value)
 
void operator>> (comms::cVec4 &value)
 
void operator>> (comms::cMat3 &value)
 
void operator>> (comms::cMat4 &value)
 
void operator>> (BaseClass *BC)
 
template<class X >
void operator>> (cList< X > &array)
 restore simple list, the size of the element should be the same as ou stored
 
template<typename X , typename TYPE >
void RestoreField (cList< X > &array, TYPE X::*member)
 
void bin_ToBS (BinStream &BS)
 save to the binary stream in the binary form, see the implementation for the data format specification
 
void text_ToBS (BinStream &BS)
 save to the binary stream in the textual (XML) form
 
bool FromBS (BinStream &BS)
 load in binary or text form
 
comms::cStr & body ()
 
TagsListGetSubTag (int Index)
 Get sub-tag by index.
 
TagsListelem (int Index)
 
TagsListoperator[] (int Index)
 Should return pointer (not reference) because of optimization error in clang/LLVM.
 
TagsListGetSubTag (const char *SubQuoteName)
 Get sub-tag by name.
 
int GetSubTagIndex (const char *SubQuoteName)
 
TagsListelem (const char *SubQuoteName)
 
TagsListoperator[] (const char *SubQuoteName)
 Should return pointer (not reference) because of optimization error in clang/LLVM.
 
int GetSubTagsCount ()
 Get amount of sub-tags.
 
int length ()
 Get amount of sub-tags, same as previous, js-like.
 
void RemoveSubTag (int idx)
 Remove sub-tag by index.
 
void RemoveSubTag (const char *id)
 Remove sub-tag by index.
 
TagsListRemoveAndGetSubTag (int idx)
 Remove and return tag by index. The return value will not be destroyed, you should do it later by yourself.
 
const char * GetTagName ()
 returns this tag name
 
void SetTagName (const char *Name)
 set name for the current tag. If this tag was already used somewhere, the memory will not be allocated for the name.
 
void FreeTag ()
 free all memory associated with this tag
 
void operator= (TagsList &src)
 copy
 
void setAsArray (bool isArray)
 
bool isArray () const
 

Static Public Member Functions

static const char * GetConstantLocation (const char *str)
 This function returns constant location for the input string. Even if the input string will be destroyed later, the return value will be kept till the program termination.
 
static int & GetConstantLocationValueRef (const char *str)
 
static const char * GetConstantSubstringLocation (const char *str, int Len, int **value=nullptr)
 This function returns constant location for the input sub - string (max length = Len). Even if the input string will be destroyed later, the return value will be kept till the program termination.
 

Static Public Attributes

static comms::cStr LastTagFile
 last saved/loaded file with tags
 
static comms::cStr LastTag
 
static comms::cStr defTab
 

Detailed Description

This class intended to load/save the class derived from the BaseClass as XML/JSON. But it may be used just for XML/JSON load/save. Pay attention, attributes of the XML not supported.

Examples
TreesGenerator.cpp.

Member Function Documentation

◆ elem() [1/2]

TagsList * TagsList::elem ( const char *  SubQuoteName)

returns the reference to the element. Pay attention, it may return the zero reference! Anyway, it may be useful for operations like T->elem("X") >> x. It works even it the element "X" does not exist, in this case x will be just cleared.

◆ elem() [2/2]

TagsList * TagsList::elem ( int  Index)

returns the reference to the element. Pay attention, it may return the zero reference! Anyway, it may be useful for operations like T->elem(i) >> x. It works even it the element i-th does not exist, in this case x will be just cleared.

◆ operator<<() [1/2]

TagsList & TagsList::operator<< ( const char *  string)

add tags using << operator. Add tag name (should start with # sign), then pass the value. Tags names will be treated without the # sign. Example: tags << "#x" << x << "#name" << name; You may pass values without tags, then tags names will be treated as empty

◆ operator<<() [2/2]

template<class X >
TagsList & TagsList::operator<< ( const cList< X > &  array)

store the list of simple elements. Elements should consist of simple types. Pointers, virtual functions or nontrivial constructors strictly prohibited there! This is intended to keep simple arrays of values, vectors etc.

◆ RestoreField()

template<typename X , typename TYPE >
void TagsList::RestoreField ( cList< X > &  array,
TYPE X::*  member 
)

This template is complimentary to the StoreField. It allows to restore previously stored field of the structure. See the StoreField description.

◆ StoreField()

template<typename X , typename TYPE >
void TagsList::StoreField ( const char *  tagname,
const cList< X > &  array,
TYPE X::*  member 
)

This template allows to store the given field of the array into the TagsList It is helpful if you need to store separate fields of some complex structure thta may not be serialized as a whole Example: you need to store Vector3D::x into the list -

....add elements...
FagsList T;
T.StoreField("V3X",v3list,&Vector3D::x);//store
....
T.elem("V3X").RestoreField(v3list1,&Vector3D::x);//now v3list1 has filled x field
The array template, refer it as coat::list <...> if you are using the Core API.
Definition cList.h:133

The documentation for this class was generated from the following file: