本文整理汇总了C++中TIXML_SNPRINTF函数的典型用法代码示例。如果您正苦于以下问题:C++ TIXML_SNPRINTF函数的具体用法?C++ TIXML_SNPRINTF怎么用?C++ TIXML_SNPRINTF使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIXML_SNPRINTF函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
void TiXmlAttribute::SetDoubleValue( double _value )
{
char buf [256];
#if defined(TIXML_SNPRINTF)
TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);
#else
sprintf (buf, "%lf", _value);
#endif
SetValue (buf);
}
示例2: defined
void TiXmlElement::SetDoubleAttribute( const char * name, double val )
{
char buf[256];
#if defined(TIXML_SNPRINTF)
TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
#else
sprintf( buf, "%f", val );
#endif
SetAttribute( name, buf );
}
示例3: defined
void TiXmlAttribute::SetUnsignedIntValue( unsigned int _value )
{
char buf [256];
#if defined(TIXML_SNPRINTF)
TIXML_SNPRINTF( buf, sizeof(buf), "%08x", _value);
#else
sprintf (buf, "%08x", _value);
#endif
SetValue (buf);
}
示例4: TIXML_SNPRINTF
void XMLDocument::PrintError() const
{
if (_errorID)
{
static const int LEN = 20;
char buf1[LEN] = { 0 };
char buf2[LEN] = { 0 };
if (_errorStr1)
{
TIXML_SNPRINTF(buf1, LEN, "%s", _errorStr1);
}
if (_errorStr2)
{
TIXML_SNPRINTF(buf2, LEN, "%s", _errorStr2);
}
printf("XMLDocument error id=%d '%s' str1=%s str2=%s\n",
_errorID, ErrorName(), buf1, buf2);
}
}
示例5: setlocale
void TiXmlElement::SetDoubleAttribute( const char * name, double val )
{
#ifndef WIN32
// need to switch to default locale "C" to prevent problems when current locale uses comma
// instead of decimal point
const char* oldlocale = setlocale(LC_NUMERIC, "C");
#endif
char buf[256];
#if defined(TIXML_SNPRINTF)
TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
#else
sprintf( buf, "%f", val );
#endif
SetAttribute( name, buf );
#ifndef WIN32
setlocale(LC_NUMERIC, oldlocale);
#endif
}
示例6: TIXML_SNPRINTF
void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
{
TIXML_SNPRINTF( buffer, bufferSize, "%f", v );
}
示例7: while
void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
{
int i=0;
while( i<(int)str.length() )
{
unsigned char c = (unsigned char) str[i];
if ( c == '&'
&& i < ( (int)str.length() - 2 )
&& str[i+1] == '#'
&& str[i+2] == 'x' )
{
// Hexadecimal character reference.
// Pass through unchanged.
// © -- copyright symbol, for example.
//
// The -1 is a bug fix from Rob Laveaux. It keeps
// an overflow from happening if there is no ';'.
// There are actually 2 ways to exit this loop -
// while fails (error case) and break (semicolon found).
// However, there is no mechanism (currently) for
// this function to return an error.
while ( i<(int)str.length()-1 )
{
outString->append( str.c_str() + i, 1 );
++i;
if ( str[i] == ';' )
break;
}
}
else if ( c == '&' )
{
outString->append( entity[0].str, entity[0].strLength );
++i;
}
else if ( c == '<' )
{
outString->append( entity[1].str, entity[1].strLength );
++i;
}
else if ( c == '>' )
{
outString->append( entity[2].str, entity[2].strLength );
++i;
}
else if ( c == '\"' )
{
outString->append( entity[3].str, entity[3].strLength );
++i;
}
else if ( c == '\'' )
{
outString->append( entity[4].str, entity[4].strLength );
++i;
}
else if ( c < 32 )
{
// Easy pass at non-alpha/numeric/symbol
// Below 32 is symbolic.
char buf[ 32 ];
#if defined(TIXML_SNPRINTF)
TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
#else
sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
#endif
//*ME: warning C4267: convert 'size_t' to 'int'
//*ME: Int-Cast to make compiler happy ...
outString->append( buf, (int)strlen( buf ) );
++i;
}
else
{
//char realc = (char) c;
//outString->append( &realc, 1 );
*outString += (char) c; // somewhat more efficient function call.
++i;
}
}
}
示例8: TIXML_SNPRINTF
void XMLUtil::ToStr( float v, char* buffer, int bufferSize )
{
TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v );
}
示例9: TIXML_SNPRINTF
std::string VarFloat::GetString()
{
char buf[16];
TIXML_SNPRINTF( buf, sizeof(buf), "%f", value );
return std::string(buf);
}