mirror of https://github.com/AxioDL/tinyxml2.git
move to cpp file.
This commit is contained in:
parent
1527cf4b2f
commit
53db4a6cf4
66
tinyxml2.cpp
66
tinyxml2.cpp
|
@ -30,6 +30,72 @@ distribution.
|
||||||
# include <cstddef>
|
# include <cstddef>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
||||||
|
// Microsoft visual studio, version 2005 and higher. Not WinCE.
|
||||||
|
/*int _snprintf_s(
|
||||||
|
char *buffer,
|
||||||
|
size_t sizeOfBuffer,
|
||||||
|
size_t count,
|
||||||
|
const char *format [,
|
||||||
|
argument] ...
|
||||||
|
);*/
|
||||||
|
inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start( va, format );
|
||||||
|
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
||||||
|
va_end( va );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
|
||||||
|
{
|
||||||
|
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TIXML_VSCPRINTF _vscprintf
|
||||||
|
#define TIXML_SSCANF sscanf_s
|
||||||
|
#elif defined _MSC_VER
|
||||||
|
// Microsoft Visual Studio 2003 and earlier or WinCE
|
||||||
|
#define TIXML_SNPRINTF _snprintf
|
||||||
|
#define TIXML_VSNPRINTF _vsnprintf
|
||||||
|
#define TIXML_SSCANF sscanf
|
||||||
|
#if (_MSC_VER == 1300 ) && (!defined WINCE)
|
||||||
|
// Microsoft Visual Studio 2003 and not WinCE.
|
||||||
|
#define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
|
||||||
|
#else
|
||||||
|
// Microsoft Visual Studio 2003 and earlier or WinCE.
|
||||||
|
inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
||||||
|
{
|
||||||
|
int len = 512;
|
||||||
|
for (;;) {
|
||||||
|
len = len*2;
|
||||||
|
char* str = new char[len]();
|
||||||
|
const int required = _vsnprintf(str, len, format, va);
|
||||||
|
delete[] str;
|
||||||
|
if ( required != -1 ) {
|
||||||
|
len = required;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
// GCC version 3 and higher
|
||||||
|
//#warning( "Using sn* functions." )
|
||||||
|
#define TIXML_SNPRINTF snprintf
|
||||||
|
#define TIXML_VSNPRINTF vsnprintf
|
||||||
|
inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
||||||
|
{
|
||||||
|
int len = vsnprintf( 0, 0, format, va );
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
#define TIXML_SSCANF sscanf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
|
static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
|
||||||
static const char LF = LINE_FEED;
|
static const char LF = LINE_FEED;
|
||||||
static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
|
static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
|
||||||
|
|
63
tinyxml2.h
63
tinyxml2.h
|
@ -91,69 +91,6 @@ distribution.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
|
||||||
// Microsoft visual studio, version 2005 and higher. Not WinCE.
|
|
||||||
/*int _snprintf_s(
|
|
||||||
char *buffer,
|
|
||||||
size_t sizeOfBuffer,
|
|
||||||
size_t count,
|
|
||||||
const char *format [,
|
|
||||||
argument] ...
|
|
||||||
);*/
|
|
||||||
inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
va_start( va, format );
|
|
||||||
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
|
||||||
va_end( va );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
|
|
||||||
{
|
|
||||||
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#define TIXML_VSCPRINTF _vscprintf
|
|
||||||
#define TIXML_SSCANF sscanf_s
|
|
||||||
#elif defined _MSC_VER
|
|
||||||
// Microsoft Visual Studio 2003 and earlier or WinCE
|
|
||||||
#define TIXML_SNPRINTF _snprintf
|
|
||||||
#define TIXML_VSNPRINTF _vsnprintf
|
|
||||||
#define TIXML_SSCANF sscanf
|
|
||||||
#if (_MSC_VER == 1300 ) && (!defined WINCE)
|
|
||||||
// Microsoft Visual Studio 2003 and not WinCE.
|
|
||||||
#define TIXML_VSCPRINTF _vscprintf //VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
|
|
||||||
#else
|
|
||||||
// Microsoft Visual Studio 2003 and earlier or WinCE.
|
|
||||||
inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
|
||||||
{
|
|
||||||
int len = 512;
|
|
||||||
for (;;) {
|
|
||||||
len = len*2;
|
|
||||||
char* str = new char[len]();
|
|
||||||
const int required = _vsnprintf(str, len, format, va);
|
|
||||||
delete[] str;
|
|
||||||
if ( required != -1 ) {
|
|
||||||
len = required;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
// GCC version 3 and higher
|
|
||||||
//#warning( "Using sn* functions." )
|
|
||||||
#define TIXML_SNPRINTF snprintf
|
|
||||||
#define TIXML_VSNPRINTF vsnprintf
|
|
||||||
inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
|
||||||
{
|
|
||||||
int len = vsnprintf( 0, 0, format, va );
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
#define TIXML_SSCANF sscanf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Versioning, past 1.0.14:
|
/* Versioning, past 1.0.14:
|
||||||
http://semver.org/
|
http://semver.org/
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue