O
O
Oleg Solovyov2014-02-03 18:41:56
C++ / C#
Oleg Solovyov, 2014-02-03 18:41:56

Why doesn't the QueryStringAttribute method work in the tinyxml library element?

I use tinyxml
The code looks something like this:

#include <vector>
#include <string>
#include "tinyxml/tinystr.h" // подключит от безысходности
#include "tinyxml/tinyxml.h"
typedef std::string String;
...
...
  TiXmlDocument file( "data/resource.xml" );
  if (file.LoadFile())
  {
        String path;
        path = element->Attribute("src");
        element->QueryStringAttribute("src",&path); // Ошибка при сборке
        element->QueryFloatAttribute("x",&spr_x); // нормально
    }
  }
Error text:
%class%.cpp(20) : error C2039: QueryStringAttribute: not a member of 'TiXmlElement'
%projectname%\src\tinyxml\tinyxml.h(940): see 'TiXmlElement' declaration

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Solovyov, 2014-02-03
@vbloodv

In the compiler settings, I added the TINYXML_USE_STL preprocessor,
everything worked.

L
Lolshto, 2014-02-03
@Lol4t0

Instead, the library is built without STL support
tinyxml.h :

#ifdef TIXML_USE_STL
        /// QueryStringAttribute examines the attribute - see QueryIntAttribute().
  int QueryStringAttribute( const char* name, std::string* _value ) const {
    ...
#ifdef TIXML_USE_STL

By default, this option is disabled.
Makefile
# TINYXML_USE_STL can be used to turn on STL support. NO, then STL
# will not be used. YES will include the STL files.
TINYXML_USE_STL := NO

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question