3DCoat  3D-COAT 4.9.xx
3DCoat is the one application that has all the tools you need to take your 3D idea from a block of digital clay all the way to a production ready, fully textured organic or hard surface model.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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

int to_int () const
 convert tag value to int More...
 
float to_float () const
 convert tag value to float More...
 
bool to_bool () const
 convert tag value to bool More...
 
const char * to_string () const
 get value of the tag More...
 
float to_float ()
 get value of the tag as float More...
 
int get_data (void *buffer, int maxlength)
 get value of the tag as the data array, returns the actual data length More...
 
int GetTagsFromString (const char *XMLSource)
 convert string to the tags structure More...
 
int PutTagsIntoString (comms::cStr *To, int shift=0)
 convert tags structure to the string More...
 
int GetTagsFromJsonString (const char *jsonSource)
 convert string to the tags structure More...
 
int PutTagsIntoJsonString (comms::cStr *Source, int shift=0)
 convert tags structure to the string More...
 
bool ReadTagsFromFile (const char *FilePath)
 read tags from file More...
 
void WriteTagsToFile (const char *FilePath, bool OnlyChanged=false)
 save tags to file More...
 
void Assign (int v)
 assign int value to the tag value More...
 
void Assign (const char *s)
 assign string value to the tag More...
 
TagsListAddSubTag (TagsList *SubQ)
 Add already allocated tag to the tags list within this tag. More...
 
TagsListAddSubTag (const char *quotename, const char *body="")
 Add new tag to the tags list within this tag. More...
 
TagsListAddSubTag (const char *quotename, int body)
 Add new tag with integer value to the tags list within this tag. More...
 
TagsListAddSubTag (const char *quotename, float body)
 Add new tag with the floating point value. More...
 
TagsListAddSubTag (const char *quotename, void *data, int Length)
 Add new tag with the data array. More...
 
TagsListoperator<< (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 More...
 
template<class X >
TagsListoperator<< (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. More...
 
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 More...
 
template<class X >
void operator>> (cList< X > &array)
 restore simple list, the size of the element should be the same as ou stored More...
 
template<typename X , typename TYPE >
void 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. More...
 
void bin_ToBS (BinStream &BS)
 save to the binary stream in the binary form, see the implementation for the data format specification More...
 
void text_ToBS (BinStream &BS)
 save to the binary stream in the textual (XML) form More...
 
bool FromBS (BinStream &BS)
 load in binary or text form More...
 
TagsListGetSubTag (int Index)
 Get sub-tag by index. More...
 
TagsListelem (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. More...
 
TagsListoperator[] (int Index)
 Should return pointer (not reference) because of optimization error in clang/LLVM. More...
 
TagsListGetSubTag (const char *SubQuoteName)
 Get sub-tag by name. More...
 
TagsListelem (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. More...
 
TagsListoperator[] (const char *SubQuoteName)
 Should return pointer (not reference) because of optimization error in clang/LLVM. More...
 
int GetSubTagsCount ()
 Get amount of sub-tags. More...
 
int length ()
 Get amount of sub-tags, same as previous, js-like. More...
 
void RemoveSubTag (int idx)
 Remove sub-tag by index. More...
 
TagsListRemoveAndGetSubTag (int idx)
 Remove and return tag by index. The return value will not be destroyed, you should do it later by yourself. More...
 
const char * GetTagName ()
 returns this tag name More...
 
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. More...
 
void FreeTag ()
 free all memory associated with this tag More...
 
void operator= (TagsList &src)
 copy More...
 

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. More...
 
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. More...
 

Static Public Attributes

static comms::cStr LastTagFile
 last saved/loaded file with tags More...
 

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.

Member Function Documentation

TagsList* TagsList::AddSubTag ( TagsList SubQ)

Add already allocated tag to the tags list within this tag.

Referenced by ExampleOfLoadSaveDataTo3BFileExtension::SaveData(), and StoreField().

TagsList* TagsList::AddSubTag ( const char *  quotename,
const char *  body = "" 
)

Add new tag to the tags list within this tag.

TagsList* TagsList::AddSubTag ( const char *  quotename,
int  body 
)

Add new tag with integer value to the tags list within this tag.

TagsList* TagsList::AddSubTag ( const char *  quotename,
float  body 
)

Add new tag with the floating point value.

TagsList* TagsList::AddSubTag ( const char *  quotename,
void *  data,
int  Length 
)

Add new tag with the data array.

void TagsList::Assign ( int  v)

assign int value to the tag value

Referenced by KnotReference::Save().

void TagsList::Assign ( const char *  s)

assign string value to the tag

void TagsList::bin_ToBS ( BinStream &  BS)

save to the binary stream in the binary form, see the implementation for the data format specification

Referenced by ExampleOfLoadSaveDataTo3BFileExtension::SaveData().

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.

Referenced by ExampleOfLoadSaveDataTo3BFileExtension::LoadData().

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.

void TagsList::FreeTag ( )

free all memory associated with this tag

bool TagsList::FromBS ( BinStream &  BS)

load in binary or text form

Referenced by ExampleOfLoadSaveDataTo3BFileExtension::LoadData().

int TagsList::get_data ( void *  buffer,
int  maxlength 
)

get value of the tag as the data array, returns the actual data length

static const char* TagsList::GetConstantLocation ( const char *  str)
static

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.

Referenced by BaseClassElement::fill().

static const char* TagsList::GetConstantSubstringLocation ( const char *  str,
int  Len,
int **  value = nullptr 
)
static

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.

TagsList* TagsList::GetSubTag ( int  Index)

Get sub-tag by index.

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

Get sub-tag by name.

int TagsList::GetSubTagsCount ( )

Get amount of sub-tags.

const char* TagsList::GetTagName ( )

returns this tag name

int TagsList::GetTagsFromJsonString ( const char *  jsonSource)

convert string to the tags structure

int TagsList::GetTagsFromString ( const char *  XMLSource)

convert string to the tags structure

int TagsList::length ( )

Get amount of sub-tags, same as previous, js-like.

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

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.

void TagsList::operator= ( TagsList src)

copy

void TagsList::operator>> ( comms::cStr &  string_value)

read values from the tags list

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

restore simple list, the size of the element should be the same as ou stored

TagsList* TagsList::operator[] ( int  Index)

Should return pointer (not reference) because of optimization error in clang/LLVM.

TagsList* TagsList::operator[] ( const char *  SubQuoteName)

Should return pointer (not reference) because of optimization error in clang/LLVM.

int TagsList::PutTagsIntoJsonString ( comms::cStr *  Source,
int  shift = 0 
)

convert tags structure to the string

Referenced by gltf::gModel::toJson().

int TagsList::PutTagsIntoString ( comms::cStr *  To,
int  shift = 0 
)

convert tags structure to the string

bool TagsList::ReadTagsFromFile ( const char *  FilePath)

read tags from file

TagsList* TagsList::RemoveAndGetSubTag ( int  idx)

Remove and return tag by index. The return value will not be destroyed, you should do it later by yourself.

void TagsList::RemoveSubTag ( int  idx)

Remove sub-tag by index.

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.

Referenced by ExampleOfLoadSaveDataTo3BFileExtension::LoadData().

void TagsList::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.

Referenced by CurvePrimitive::OnChangeMember().

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

References AddSubTag().

Referenced by ExampleOfLoadSaveDataTo3BFileExtension::SaveData().

void TagsList::text_ToBS ( BinStream &  BS)

save to the binary stream in the textual (XML) form

bool TagsList::to_bool ( ) const

convert tag value to bool

float TagsList::to_float ( ) const

convert tag value to float

float TagsList::to_float ( )

get value of the tag as float

int TagsList::to_int ( ) const

convert tag value to int

const char* TagsList::to_string ( ) const

get value of the tag

Referenced by KnotReference::Load().

void TagsList::WriteTagsToFile ( const char *  FilePath,
bool  OnlyChanged = false 
)

save tags to file

Member Data Documentation

comms::cStr TagsList::LastTagFile
static

last saved/loaded file with tags


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