5#include <cgv/media/color.h> 
    6#include <cgv/math/fvec.h> 
    9#include "../tinyxml2/tinyxml2.h" 
   29    std::string name = 
"";
 
   30    const tinyxml2::XMLElement* result = 
nullptr;
 
   46    const tinyxml2::XMLElement* 
Result()
 const {
 
 
   51    bool VisitEnter(
const tinyxml2::XMLElement& element, 
const tinyxml2::XMLAttribute* attribute)
 override {
 
   53        if(strcmp(element.Name(), name.c_str()) == 0) {
 
 
   67static tinyxml2::XMLError QueryStringAttribute(
const tinyxml2::XMLElement& elem, 
const std::string& name, std::string& value) {
 
   70    tinyxml2::XMLError result = elem.QueryStringAttribute(name.c_str(), &c);
 
   71    if (result == tinyxml2::XML_SUCCESS)
 
   72        value = std::string(c);
 
   87static tinyxml2::XMLError QueryBoolAttribute(
const tinyxml2::XMLElement& elem, 
const std::string& name, 
bool& value) {
 
   90    tinyxml2::XMLError result = QueryStringAttribute(elem, name, str);
 
   91    if(result == tinyxml2::XML_SUCCESS) {
 
   92        if(str.length() > 0) {
 
   95            if(str[0] == 
'0' || str == 
"false") {
 
   98            } 
else if(str[0] == 
'1' || str == 
"true") {
 
  103            return tinyxml2::XMLError::XML_WRONG_ATTRIBUTE_TYPE;
 
  126template <
typename T, cgv::type::u
int32_type N>
 
  127static tinyxml2::XMLError QueryVecAttribute(
const tinyxml2::XMLElement& elem, 
const std::string& name, 
cgv::math::fvec<T, N>& value) {
 
  129    std::string str = 
"";
 
  130    tinyxml2::XMLError result = QueryStringAttribute(elem, name, str);
 
  131    if(result == tinyxml2::XML_SUCCESS) {
 
  134        if(!cgv::math::from_string(str, value))
 
  135            return tinyxml2::XMLError::XML_WRONG_ATTRIBUTE_TYPE;
 
  153    tinyxml2::XMLError result = QueryVecAttribute(elem, name, vec);
 
  154    if(result == tinyxml2::XML_SUCCESS)
 
A vector with zero based index.
Finds a tinyxml2::XMLElement by name.
void SetQueryName(const std::string &name)
Changes the name used to find a matching element.
const tinyxml2::XMLElement * Result() const
Get the query result.
std::string & trim(std::string &str, const std::string &chars)
trim white space or other characters from start and end of string
char to_lower(char c)
convert char to lower case
std::string & remove(std::string &s, char c)
remove char c from the given string s and return a reference to the same string object
Helper functions to process strings.