![]() |
3DCoat Core API
The 3DCoat API documentation.
|
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) |
TagsList * | GetParent () const |
TagsList * | AddSubTag (TagsList *SubQ) |
Add already allocated tag to the tags list within this tag. | |
TagsList * | AddSubTag (const char *quotename, const char *body="") |
Add new tag to the tags list within this tag. | |
TagsList * | AddSubTag (const char *quotename, int body) |
Add new tag with integer value to the tags list within this tag. | |
TagsList * | AddSubTag (const char *quotename, DWORD body) |
TagsList * | AddSubTag (const char *quotename, short body) |
TagsList * | AddSubTag (const char *quotename, WORD body) |
TagsList * | AddSubTag (const char *quotename, char body) |
TagsList * | AddSubTag (const char *quotename, float body) |
Add new tag with the floating point value. | |
TagsList * | AddSubTag (const char *quotename, void *data, int Length) |
Add new tag with the data array. | |
TagsList & | operator<< (const char *string) |
TagsList & | operator<< (int value) |
TagsList & | operator<< (bool value) |
TagsList & | operator<< (float value) |
TagsList & | operator<< (const comms::cVec2 &value) |
TagsList & | operator<< (const comms::cVec3 &value) |
TagsList & | operator<< (const comms::cVec4 &value) |
TagsList & | operator<< (const comms::cMat3 &value) |
TagsList & | operator<< (const comms::cMat4 &value) |
TagsList & | operator<< (BaseClass *BC) |
template<class X > | |
TagsList & | operator<< (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 () |
TagsList * | GetSubTag (int Index) |
Get sub-tag by index. | |
TagsList * | elem (int Index) |
TagsList * | operator[] (int Index) |
Should return pointer (not reference) because of optimization error in clang/LLVM. | |
TagsList * | GetSubTag (const char *SubQuoteName) |
Get sub-tag by name. | |
int | GetSubTagIndex (const char *SubQuoteName) |
TagsList * | elem (const char *SubQuoteName) |
TagsList * | operator[] (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. | |
TagsList * | RemoveAndGetSubTag (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 | |
Static Public Attributes | |
static comms::cStr | LastTagFile |
last saved/loaded file with tags | |
static comms::cStr | LastTag |
static comms::cStr | defTab |
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.
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.
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.
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
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.
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.
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 -