diff --git a/tinyxml2.cpp b/tinyxml2.cpp index fd9ef16..4956a05 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -476,13 +476,9 @@ bool XMLUtil::ToDouble( const char* str, double* value ) return false; } -std::string XMLUtil::ToErrorName( const XMLError errorID ) +const char* XMLUtil::ToErrorName( const XMLError errorID ) { -#if __cplusplus > 199711LL return ErrorNames[errorID]; -#else - return std::string("Use C++11 or higher to use this function"); -#endif } char* XMLDocument::Identify( char* p, XMLNode** node ) diff --git a/tinyxml2.h b/tinyxml2.h index c254d15..6ef7493 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -39,8 +39,6 @@ distribution. # include # include # include -# include -# include #endif /* @@ -512,14 +510,12 @@ enum XMLError { }; #undef FF -#if __cplusplus > 199711LL #define FF(X) #X, -const std::vector ErrorNames = { +static const char *ErrorNames[] = { FOR_EACH(FF) "OUT_OF_RANGE" }; #undef FF -#endif #undef FOR_EACH @@ -601,7 +597,7 @@ public: static bool ToDouble( const char* str, double* value ); // converts XMLError to strings - static std::string ToErrorName( const XMLError errorID ); + static const char* ToErrorName( const XMLError errorID ); }; diff --git a/xmltest.cpp b/xmltest.cpp index ef57f7e..477f271 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -1222,9 +1222,7 @@ int main( int argc, const char ** argv ) XMLDocument doc; XMLError error = doc.LoadFile( "resources/empty.xml" ); XMLTest( "Loading an empty file", XML_ERROR_EMPTY_DOCUMENT, error ); -#if __cplusplus > 199711LL - XMLTest( "Loading an empty file and ErrorName as string", "XML_ERROR_EMPTY_DOCUMENT", XMLUtil::ToErrorName(error).c_str() ); -#endif + XMLTest( "Loading an empty file and ErrorName as string", "XML_ERROR_EMPTY_DOCUMENT", XMLUtil::ToErrorName(error) ); } {