Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
igl::xml::serialization_xml Namespace Reference

Classes

struct  is_eigen_type
 
struct  is_eigen_type< Eigen::Matrix< T, R, C, P, MR, MC > >
 
struct  is_eigen_type< Eigen::SparseMatrix< T, P, I > >
 
struct  is_serializable
 
struct  is_stl_container
 
struct  is_stl_container< std::map< T1, T2 > >
 
struct  is_stl_container< std::pair< T1, T2 > >
 
struct  is_stl_container< std::set< T > >
 
struct  is_stl_container< std::vector< T1, T2 > >
 

Functions

template<typename T >
IGL_INLINE std::enable_if< std::is_fundamental< T >::value >::type serialize (const T &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_fundamental< T >::value >::type deserialize (T &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
IGL_INLINE void serialize (const std::string &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
IGL_INLINE void deserialize (std::string &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_base_of< XMLSerializableBase, T >::value >::type serialize (const T &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_base_of< XMLSerializableBase, T >::value >::type deserialize (T &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T1 , typename T2 >
IGL_INLINE void serialize (const std::pair< T1, T2 > &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T1 , typename T2 >
IGL_INLINE void deserialize (std::pair< T1, T2 > &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T1 , typename T2 >
IGL_INLINE void serialize (const std::vector< T1, T2 > &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T1 , typename T2 >
IGL_INLINE void deserialize (std::vector< T1, T2 > &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE void serialize (const std::set< T > &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE void deserialize (std::set< T > &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T1 , typename T2 >
IGL_INLINE void serialize (const std::map< T1, T2 > &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T1 , typename T2 >
IGL_INLINE void deserialize (std::map< T1, T2 > &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void serialize (const Eigen::Matrix< T, R, C, P, MR, MC > &obj, const std::string &name, const std::function< std::string(const T &) > &to_string, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element)
 
template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void serialize (const Eigen::Matrix< T, R, C, P, MR, MC > &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void deserialize (const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name, const std::function< void(const std::string &, T &)> &from_string, Eigen::Matrix< T, R, C, P, MR, MC > &obj)
 
template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void deserialize (Eigen::Matrix< T, R, C, P, MR, MC > &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T , int P, typename I >
IGL_INLINE void serialize (const Eigen::SparseMatrix< T, P, I > &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T , int P, typename I >
IGL_INLINE void deserialize (Eigen::SparseMatrix< T, P, I > &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_pointer< T >::value >::type serialize (const T &obj, tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_pointer< T >::value >::type deserialize (T &obj, const tinyxml2::XMLDocument *doc, const tinyxml2::XMLElement *element, const std::string &name)
 
IGL_INLINE tinyxml2::XMLElement * getElement (tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
 
IGL_INLINE void getAttribute (const char *src, bool &dest)
 
IGL_INLINE void getAttribute (const char *src, char &dest)
 
IGL_INLINE void getAttribute (const char *src, std::string &dest)
 
IGL_INLINE void getAttribute (const char *src, float &dest)
 
IGL_INLINE void getAttribute (const char *src, double &dest)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value >::type getAttribute (const char *src, T &dest)
 
template<typename T >
IGL_INLINE std::enable_if< std::is_integral< T >::value &&!std::is_unsigned< T >::value >::type getAttribute (const char *src, T &dest)
 
IGL_INLINE void replaceSubString (std::string &str, const std::string &search, const std::string &replace)
 
IGL_INLINE void encodeXMLElementName (std::string &name)
 
IGL_INLINE void decodeXMLElementName (std::string &name)
 
static bool is_base64 (unsigned char c)
 
std::string base64_encode (unsigned char const *bytes_to_encode, unsigned int in_len)
 
std::string base64_decode (std::string const &encoded_string)
 

Variables

static const int numForbiddenChars = 8
 
static const char forbiddenChars [] ={' ','/','~','#','&','>','<','='}
 
static const std::string base64_chars
 

Function Documentation

◆ base64_decode()

IGL_INLINE std::string igl::xml::serialization_xml::base64_decode ( std::string const encoded_string)
855 {
856 int in_len = encoded_string.size();
857 int i = 0;
858 int j = 0;
859 int in_ = 0;
860 unsigned char char_array_4[4],char_array_3[3];
861 std::string ret;
862
863 // construct fast lookup table
864 // added by Christian Sch�ller (schuellc@inf.ethz.ch)
865 int charLookup[200];
866 for(int i=0;i<(int)(base64_chars.length());i++)
867 charLookup[(int)base64_chars[i]] = i;
868
869 while(in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
870 char_array_4[i++] = encoded_string[in_]; in_++;
871 if(i ==4) {
872 for(i = 0; i <4; i++)
873 char_array_4[i] = charLookup[char_array_4[i]]; // new fast lookup
874 //char_array_4[i] = base64_chars.find(char_array_4[i]); // original version
875
876 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
877 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
878 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
879
880 for(i = 0; (i < 3); i++)
881 ret += char_array_3[i];
882
883 i = 0;
884 }
885 }
886
887 if(i) {
888 for(j = i; j <4; j++)
889 char_array_4[j] = 0;
890
891 for(j = 0; j <4; j++)
892 char_array_4[j] = base64_chars.find(char_array_4[j]);
893
894 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
895 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
896 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
897
898 for(j = 0; (j < i - 1);
899 j++) ret += char_array_3[j];
900 }
901
902 return ret;
903 }
static const std::string base64_chars
Definition serialize_xml.cpp:802
static bool is_base64(unsigned char c)
Definition serialize_xml.cpp:807

References base64_chars, and is_base64().

Referenced by igl::xml::deserialize_xml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base64_encode()

IGL_INLINE std::string igl::xml::serialization_xml::base64_encode ( unsigned char const bytes_to_encode,
unsigned int  in_len 
)
812 {
813 std::string ret;
814 int i = 0;
815 int j = 0;
816 unsigned char char_array_3[3];
817 unsigned char char_array_4[4];
818
819 while(in_len--) {
820 char_array_3[i++] = *(bytes_to_encode++);
821 if(i == 3) {
822 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
823 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
824 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
825 char_array_4[3] = char_array_3[2] & 0x3f;
826
827 for(i = 0; (i <4) ; i++)
828 ret += base64_chars[char_array_4[i]];
829
830 i = 0;
831 }
832 }
833
834 if(i)
835 {
836 for(j = i; j < 3; j++)
837 char_array_3[j] = '\0';
838
839 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
840 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
841 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
842 char_array_4[3] = char_array_3[2] & 0x3f;
843
844 for(j = 0; (j < i + 1); j++)
845 ret += base64_chars[char_array_4[j]];
846
847 while((i++ < 3))
848 ret += '=';
849 }
850
851 return ret;
852 }

References base64_chars.

Referenced by igl::xml::serialize_xml().

+ Here is the caller graph for this function:

◆ decodeXMLElementName()

IGL_INLINE void igl::xml::serialization_xml::decodeXMLElementName ( std::string &  name)
763 {
764 if(name.find("::",0) == 0)
765 name.replace(0,3,"");
766
767 for(auto chr : forbiddenChars)
768 {
769 std::stringstream searchs;
770 searchs << ":" << (int)chr;
771 std::string search = searchs.str();
772 std::string replace;
773 replace = chr;
774
775 replaceSubString(name,search,replace);
776 }
777 }
IGL_INLINE void replaceSubString(std::string &str, const std::string &search, const std::string &replace)
Definition serialize_xml.cpp:731
static const char forbiddenChars[]
Definition serialize_xml.cpp:729

References forbiddenChars, and replaceSubString().

+ Here is the call graph for this function:

◆ deserialize() [1/11]

template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void igl::xml::serialization_xml::deserialize ( const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name,
const std::function< void(const std::string &, T &)> &  from_string,
Eigen::Matrix< T, R, C, P, MR, MC > &  obj 
)
462 {
463 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
464 bool initialized = false;
465 if(child != NULL)
466 {
467 const unsigned int rows = child->UnsignedAttribute("rows");
468 const unsigned int cols = child->UnsignedAttribute("cols");
469
470 if(rows > 0 && cols > 0)
471 {
472 obj.resize(rows,cols);
473
474 const tinyxml2::XMLAttribute* attribute = child->FindAttribute("matrix");
475 if(attribute != NULL)
476 {
477 std::string matTemp;
478 getAttribute(attribute->Value(),matTemp);
479
480 std::string line,srows,scols;
481 std::stringstream mats;
482 mats << matTemp;
483
484 int r=0;
485 std::string val;
486 // for each line
487 getline(mats,line);
488 while(getline(mats,line))
489 {
490 // get current line
491 std::stringstream liness(line);
492
493 for(unsigned int c=0;c<cols-1;c++)
494 {
495 // split line
496 getline(liness,val,',');
497
498 // push pack the data if any
499 if(!val.empty())
500 {
501 from_string(val,obj.coeffRef(r,c));
502 }
503 }
504
505 getline(liness,val);
506 from_string(val,obj.coeffRef(r,cols-1));
507
508 r++;
509 }
510 initialized = true;
511 }
512 }
513 }
514
515 if(!initialized)
516 {
518 }
519 }
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
Definition PlainObjectBase.h:183
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition PlainObjectBase.h:279
IGL_INLINE void getAttribute(const char *src, bool &dest)
Definition serialize_xml.cpp:686
static BOOLEAN initialized
Definition hid.c:131

References Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols >::coeffRef(), getAttribute(), initialized, and Eigen::PlainObjectBase< Derived >::resize().

+ Here is the call graph for this function:

◆ deserialize() [2/11]

template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void igl::xml::serialization_xml::deserialize ( Eigen::Matrix< T, R, C, P, MR, MC > &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
527 {
528 const std::function<void(const std::string &,T &)> & from_string =
529 [](const std::string & s,T & v)
530 {
531 getAttribute(s.c_str(),v);
532 };
533 deserialize(doc,element,name,from_string,obj);
534 }
typedef void(GLAPIENTRYP _GLUfuncptr)(void)

References deserialize(), getAttribute(), and void().

+ Here is the call graph for this function:

◆ deserialize() [3/11]

template<typename T , int P, typename I >
IGL_INLINE void igl::xml::serialization_xml::deserialize ( Eigen::SparseMatrix< T, P, I > &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
568 {
569 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
570 bool initialized = false;
571 if(child != NULL)
572 {
573 const unsigned int rows = child->UnsignedAttribute("rows");
574 const unsigned int cols = child->UnsignedAttribute("cols");
575
576 if(rows > 0 && cols > 0)
577 {
578 obj.resize(rows,cols);
579 obj.setZero();
580
581 const tinyxml2::XMLAttribute* attribute = child->FindAttribute("matrix");
582 if(attribute != NULL)
583 {
584 std::string matTemp;
585 getAttribute(attribute->Value(),matTemp);
586
587 std::string line,srows,scols;
588 std::stringstream mats;
589 mats << matTemp;
590
591 std::vector<Eigen::Triplet<T,I> > triplets;
592 int r=0;
593 std::string val;
594
595 // for each line
596 getline(mats,line);
597 while(getline(mats,line))
598 {
599 // get current line
600 std::stringstream liness(line);
601
602 // row
603 getline(liness,val,',');
604 int row = atoi(val.c_str());
605 // col
606 getline(liness,val,',');
607 int col = atoi(val.c_str());
608 // val
609 getline(liness,val);
610 T value;
611 getAttribute(val.c_str(),value);
612
613 triplets.push_back(Eigen::Triplet<T,I>(row,col,value));
614
615 r++;
616 }
617
618 obj.setFromTriplets(triplets.begin(),triplets.end());
619 initialized = true;
620 }
621 }
622 }
623
624 if(!initialized)
625 {
627 }
628 }
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). *‍/.
Definition BlockMethods.h:859
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Definition BlockMethods.h:838
A versatible sparse matrix representation.
Definition SparseMatrix.h:98
void setFromTriplets(const InputIterators &begin, const InputIterators &end)
Definition SparseMatrix.h:993
void setZero()
Definition SparseMatrix.h:251
void resize(Index rows, Index cols)
Definition SparseMatrix.h:621
A small structure to hold a non zero as a triplet (i,j,value).
Definition SparseUtil.h:155

References col(), getAttribute(), initialized, Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::resize(), row(), Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::setFromTriplets(), and Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::setZero().

+ Here is the call graph for this function:

◆ deserialize() [4/11]

template<typename T1 , typename T2 >
IGL_INLINE void igl::xml::serialization_xml::deserialize ( std::map< T1, T2 > &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
379 {
380 obj.clear();
381
382 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
383 if(child != NULL)
384 {
385 unsigned int size = child->UnsignedAttribute("size");
386
387 std::stringstream num;
388 typename std::map<T1,T2>::iterator iter = obj.begin();
389 for(int i=0;i<size;i++)
390 {
391 num.str("");
392 num << "value" << i;
393
394 std::pair<T1,T2> pair;
395 deserialize(pair,doc,child,num.str());
396 obj.insert(pair);
397 }
398 }
399 else
400 {
401 obj.clear();
402 }
403 }

References deserialize().

+ Here is the call graph for this function:

◆ deserialize() [5/11]

template<typename T1 , typename T2 >
IGL_INLINE void igl::xml::serialization_xml::deserialize ( std::pair< T1, T2 > &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
262 {
263 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
264 if(child != NULL)
265 {
266 deserialize(obj.first,doc,child,"first");
267 deserialize(obj.second,doc,child,"second");
268 }
269 else
270 {
271 obj.first = T1();
272 obj.second = T2();
273 }
274 }

References deserialize().

+ Here is the call graph for this function:

◆ deserialize() [6/11]

template<typename T >
IGL_INLINE void igl::xml::serialization_xml::deserialize ( std::set< T > &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
335 {
336 obj.clear();
337
338 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
339 if(child != NULL)
340 {
341 unsigned int size = child->UnsignedAttribute("size");
342
343 std::stringstream num;
344 typename std::set<T>::iterator iter = obj.begin();
345 for(int i=0;i<size;i++)
346 {
347 num.str("");
348 num << "value" << i;
349
350 T val;
351 deserialize(val,doc,child,num.str());
352 obj.insert(val);
353 }
354 }
355 else
356 {
357 obj.clear();
358 }
359 }

References deserialize().

+ Here is the call graph for this function:

◆ deserialize() [7/11]

IGL_INLINE void igl::xml::serialization_xml::deserialize ( std::string &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
211 {
212 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
213 if(child != NULL)
214 {
215 getAttribute(child->Attribute("val"),obj);
216 }
217 else
218 {
219 obj = std::string("");
220 }
221 }

References getAttribute().

+ Here is the call graph for this function:

◆ deserialize() [8/11]

template<typename T1 , typename T2 >
IGL_INLINE void igl::xml::serialization_xml::deserialize ( std::vector< T1, T2 > &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
293 {
294 obj.clear();
295
296 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
297 if(child != NULL)
298 {
299 unsigned int size = child->UnsignedAttribute("size");
300 obj.resize(size);
301
302 std::stringstream num;
303 for(unsigned int i=0;i<size;i++)
304 {
305 num.str("");
306 num << "value" << i;
307
308 deserialize(obj[i],doc,child,num.str());
309 }
310 }
311 else
312 {
313 obj.clear();
314 }
315 }

References deserialize().

+ Here is the call graph for this function:

◆ deserialize() [9/11]

template<typename T >
IGL_INLINE std::enable_if< std::is_fundamental< T >::value >::type igl::xml::serialization_xml::deserialize ( T &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
190 {
191 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
192 if(child != NULL)
193 {
194 getAttribute(child->Attribute("val"),obj);
195 }
196 else
197 {
198 obj = T();
199 }
200 }

References getAttribute().

Referenced by deserialize(), deserialize(), deserialize(), deserialize(), deserialize(), deserialize(), and igl::xml::deserialize_xml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize() [10/11]

template<typename T >
IGL_INLINE std::enable_if< std::is_base_of< XMLSerializableBase, T >::value >::type igl::xml::serialization_xml::deserialize ( T &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
237 {
238 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
239
240 if(child != NULL)
241 {
242 obj.Deserialize(doc,child);
243 }
244 else
245 {
246 obj = T();
247 }
248 }

◆ deserialize() [11/11]

template<typename T >
IGL_INLINE std::enable_if< std::is_pointer< T >::value >::type igl::xml::serialization_xml::deserialize ( T &  obj,
const tinyxml2::XMLDocument *  doc,
const tinyxml2::XMLElement *  element,
const std::string &  name 
)
647 {
648 const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
649 if(child != NULL)
650 {
651 bool isNullPtr = child->BoolAttribute("isNullPtr");
652
653 if(isNullPtr)
654 {
655 if(obj != NULL)
656 {
657 std::cout << "deserialization: possible memory leak for '" << typeid(obj).name() << "'" << std::endl;
658 obj = NULL;
659 }
660 }
661 else
662 {
663 if(obj != NULL)
664 std::cout << "deserialization: possible memory leak for '" << typeid(obj).name() << "'" << std::endl;
665
666 obj = new typename std::remove_pointer<T>::type();
667
668 serialization_xml::deserialize(*obj,doc,element,name);
669 }
670 }
671 }

References deserialize().

+ Here is the call graph for this function:

◆ encodeXMLElementName()

IGL_INLINE void igl::xml::serialization_xml::encodeXMLElementName ( std::string &  name)
742 {
743 // must not start with a digit
744 if(isdigit(*name.begin()))
745 {
746 name = ":::" + name;
747 }
748
749 std::stringstream stream;
750 for(int i=0;i<numForbiddenChars;i++)
751 {
752 std::string search;
753 search = forbiddenChars[i];
754 std::stringstream replaces;
755 replaces << ":" << (int)forbiddenChars[i];
756 std::string replace = replaces.str();
757
758 replaceSubString(name,search,replace);
759 }
760 }

References forbiddenChars, numForbiddenChars, and replaceSubString().

Referenced by igl::xml::deserialize_xml(), and igl::xml::serialize_xml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttribute() [1/7]

IGL_INLINE void igl::xml::serialization_xml::getAttribute ( const char *  src,
bool &  dest 
)
687 {
688 tinyxml2::XMLUtil::ToBool(src,&dest);
689 }

Referenced by deserialize(), deserialize(), deserialize(), deserialize(), and deserialize().

+ Here is the caller graph for this function:

◆ getAttribute() [2/7]

IGL_INLINE void igl::xml::serialization_xml::getAttribute ( const char *  src,
char &  dest 
)
692 {
693 dest = (char)atoi(src);
694 }

◆ getAttribute() [3/7]

IGL_INLINE void igl::xml::serialization_xml::getAttribute ( const char *  src,
double &  dest 
)
707 {
708 tinyxml2::XMLUtil::ToDouble(src,&dest);
709 }

◆ getAttribute() [4/7]

IGL_INLINE void igl::xml::serialization_xml::getAttribute ( const char *  src,
float &  dest 
)
702 {
703 tinyxml2::XMLUtil::ToFloat(src,&dest);
704 }

◆ getAttribute() [5/7]

IGL_INLINE void igl::xml::serialization_xml::getAttribute ( const char *  src,
std::string &  dest 
)
697 {
698 dest = src;
699 }

◆ getAttribute() [6/7]

template<typename T >
IGL_INLINE std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value >::type igl::xml::serialization_xml::getAttribute ( const char *  src,
T &  dest 
)
713 {
714 unsigned int val;
715 tinyxml2::XMLUtil::ToUnsigned(src,&val);
716 dest = (T)val;
717 }

◆ getAttribute() [7/7]

template<typename T >
IGL_INLINE std::enable_if< std::is_integral< T >::value &&!std::is_unsigned< T >::value >::type igl::xml::serialization_xml::getAttribute ( const char *  src,
T &  dest 
)
721 {
722 int val;
723 tinyxml2::XMLUtil::ToInt(src,&val);
724 dest = (T)val;
725 }

◆ getElement()

tinyxml2::XMLElement * igl::xml::serialization_xml::getElement ( tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
676 {
677 tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
678 if(child == NULL)
679 {
680 child = doc->NewElement(name.c_str());
681 element->InsertEndChild(child);
682 }
683 return child;
684 }

Referenced by serialize(), serialize(), serialize(), serialize(), serialize(), serialize(), serialize(), and serialize().

+ Here is the caller graph for this function:

◆ is_base64()

static bool igl::xml::serialization_xml::is_base64 ( unsigned char  c)
inlinestatic
807 {
808 return (isalnum(c) || (c == '+') || (c == '/'));
809 }

Referenced by base64_decode().

+ Here is the caller graph for this function:

◆ replaceSubString()

IGL_INLINE void igl::xml::serialization_xml::replaceSubString ( std::string &  str,
const std::string &  search,
const std::string &  replace 
)
732 {
733 size_t pos = 0;
734 while((pos = str.find(search,pos)) != std::string::npos)
735 {
736 str.replace(pos,search.length(),replace);
737 pos += replace.length();
738 }
739 }

Referenced by decodeXMLElementName(), and encodeXMLElementName().

+ Here is the caller graph for this function:

◆ serialize() [1/11]

template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void igl::xml::serialization_xml::serialize ( const Eigen::Matrix< T, R, C, P, MR, MC > &  obj,
const std::string &  name,
const std::function< std::string(const T &) > &  to_string,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element 
)
412 {
413 tinyxml2::XMLElement* matrix = getElement(doc,element,name.c_str());
414
415 const unsigned int rows = obj.rows();
416 const unsigned int cols = obj.cols();
417
418 matrix->SetAttribute("rows",rows);
419 matrix->SetAttribute("cols",cols);
420
421 std::stringstream ms;
422 ms << "\n";
423 for(unsigned int r=0;r<rows;r++)
424 {
425 for(unsigned int c=0;c<cols;c++)
426 {
427 ms << to_string(obj(r,c)) << ",";
428 }
429 ms << "\n";
430 }
431
432 std::string mString = ms.str();
433 if(mString.size() > 1)
434 mString[mString.size()-2] = '\0';
435
436 matrix->SetAttribute("matrix",mString.c_str());
437 }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const
Definition PlainObjectBase.h:153
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const
Definition PlainObjectBase.h:151
IGL_INLINE tinyxml2::XMLElement * getElement(tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *element, const std::string &name)
Definition serialize_xml.cpp:675

References Eigen::PlainObjectBase< Derived >::cols(), getElement(), and Eigen::PlainObjectBase< Derived >::rows().

+ Here is the call graph for this function:

◆ serialize() [2/11]

template<typename T , int R, int C, int P, int MR, int MC>
IGL_INLINE void igl::xml::serialization_xml::serialize ( const Eigen::Matrix< T, R, C, P, MR, MC > &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
446 {
447 const std::function<std::string(const T &) > to_string =
448 [](const T & v)->std::string
449 {
450 return
451 STR(std::setprecision(std::numeric_limits<double>::digits10+2)<<v);
452 };
453 serialize(obj,name,to_string,doc,element);
454 }
void serialize(Archive &ar, FacenamesSerializer &t, const std::uint32_t version)
Definition GLGizmoEmboss.cpp:1562
#define STR(X)
Definition STR.h:17

References serialize(), and STR.

+ Here is the call graph for this function:

◆ serialize() [3/11]

template<typename T , int P, typename I >
IGL_INLINE void igl::xml::serialization_xml::serialize ( const Eigen::SparseMatrix< T, P, I > &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
538 {
539 tinyxml2::XMLElement* matrix = getElement(doc,element,name.c_str());
540
541 const unsigned int rows = obj.rows();
542 const unsigned int cols = obj.cols();
543
544 matrix->SetAttribute("rows",rows);
545 matrix->SetAttribute("cols",cols);
546
547 char buffer[200];
548 std::stringstream ms;
549 ms << "\n";
550 for(int k=0;k<obj.outerSize();++k)
551 {
552 for(typename Eigen::SparseMatrix<T,P,I>::InnerIterator it(obj,k);it;++it)
553 {
554 tinyxml2::XMLUtil::ToStr(it.value(),buffer,200);
555 ms << it.row() << "," << it.col() << "," << buffer << "\n";
556 }
557 }
558
559 std::string mString = ms.str();
560 if(mString.size() > 0)
561 mString[mString.size()-1] = '\0';
562
563 matrix->SetAttribute("matrix",mString.c_str());
564 }
Definition SparseCompressedBase.h:137
Index outerSize() const
Definition SparseMatrix.h:143
Index rows() const
Definition SparseMatrix.h:136
Index cols() const
Definition SparseMatrix.h:138

References Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::cols(), getElement(), Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::outerSize(), and Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::rows().

+ Here is the call graph for this function:

◆ serialize() [4/11]

template<typename T1 , typename T2 >
IGL_INLINE void igl::xml::serialization_xml::serialize ( const std::map< T1, T2 > &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
363 {
364 tinyxml2::XMLElement* map = getElement(doc,element,name.c_str());
365 map->SetAttribute("size",(unsigned int)obj.size());
366
367 std::stringstream num;
368 typename std::map<T1,T2>::const_iterator iter = obj.cbegin();
369 for(int i=0;iter!=obj.end();iter++,i++)
370 {
371 num.str("");
372 num << "value" << i;
373 serialize((std::pair<T1,T2>)*iter,doc,map,num.str());
374 }
375 }

References getElement(), and serialize().

+ Here is the call graph for this function:

◆ serialize() [5/11]

template<typename T1 , typename T2 >
IGL_INLINE void igl::xml::serialization_xml::serialize ( const std::pair< T1, T2 > &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
254 {
255 tinyxml2::XMLElement* pair = getElement(doc,element,name.c_str());
256 serialize(obj.first,doc,pair,"first");
257 serialize(obj.second,doc,pair,"second");
258 }

References getElement(), and serialize().

+ Here is the call graph for this function:

◆ serialize() [6/11]

template<typename T >
IGL_INLINE void igl::xml::serialization_xml::serialize ( const std::set< T > &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
319 {
320 tinyxml2::XMLElement* set = getElement(doc,element,name.c_str());
321 set->SetAttribute("size",(unsigned int)obj.size());
322
323 std::stringstream num;
324 typename std::set<T>::iterator iter = obj.begin();
325 for(int i=0;iter!=obj.end();iter++,i++)
326 {
327 num.str("");
328 num << "value" << i;
329 serialize((T)*iter,doc,set,num.str());
330 }
331 }

References getElement(), and serialize().

+ Here is the call graph for this function:

◆ serialize() [7/11]

IGL_INLINE void igl::xml::serialization_xml::serialize ( const std::string &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
205 {
206 tinyxml2::XMLElement* child = getElement(doc,element,name.c_str());
207 child->SetAttribute("val",obj.c_str());
208 }

References getElement().

+ Here is the call graph for this function:

◆ serialize() [8/11]

template<typename T1 , typename T2 >
IGL_INLINE void igl::xml::serialization_xml::serialize ( const std::vector< T1, T2 > &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
278 {
279 tinyxml2::XMLElement* vector = getElement(doc,element,name.c_str());
280 vector->SetAttribute("size",(unsigned int)obj.size());
281
282 std::stringstream num;
283 for(unsigned int i=0;i<obj.size();i++)
284 {
285 num.str("");
286 num << "value" << i;
287 serialize(obj[i],doc,vector,num.str());
288 }
289 }

References getElement(), and serialize().

+ Here is the call graph for this function:

◆ serialize() [9/11]

template<typename T >
IGL_INLINE std::enable_if< std::is_fundamental< T >::value >::type igl::xml::serialization_xml::serialize ( const T &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
183 {
184 tinyxml2::XMLElement* child = getElement(doc,element,name.c_str());
185 child->SetAttribute("val",obj);
186 }

References getElement().

Referenced by serialize(), serialize(), serialize(), serialize(), serialize(), serialize(), and igl::xml::serialize_xml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize() [10/11]

template<typename T >
IGL_INLINE std::enable_if< std::is_base_of< XMLSerializableBase, T >::value >::type igl::xml::serialization_xml::serialize ( const T &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
227 {
228 // Serialize object implementing Serializable interface
229 const XMLSerializableBase& object = dynamic_cast<const XMLSerializableBase&>(obj);
230
231 tinyxml2::XMLElement* child = getElement(doc,element,name.c_str());
232 object.Serialize(doc,child);
233 }
Definition XMLSerializable.h:21

References getElement().

+ Here is the call graph for this function:

◆ serialize() [11/11]

template<typename T >
IGL_INLINE std::enable_if< std::is_pointer< T >::value >::type igl::xml::serialization_xml::serialize ( const T &  obj,
tinyxml2::XMLDocument *  doc,
tinyxml2::XMLElement *  element,
const std::string &  name 
)
634 {
635 tinyxml2::XMLElement* pointer = getElement(doc,element,name.c_str());
636
637 bool isNullPtr = (obj == NULL);
638
639 pointer->SetAttribute("isNullPtr",isNullPtr);
640
641 if(isNullPtr == false)
642 serialization_xml::serialize(*obj,doc,element,name);
643 }

References getElement(), and serialize().

+ Here is the call graph for this function:

Variable Documentation

◆ base64_chars

const std::string igl::xml::serialization_xml::base64_chars
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"

Referenced by base64_decode(), and base64_encode().

◆ forbiddenChars

const char igl::xml::serialization_xml::forbiddenChars[] ={' ','/','~','#','&','>','<','='}
static

◆ numForbiddenChars

const int igl::xml::serialization_xml::numForbiddenChars = 8
static

Referenced by encodeXMLElementName().