예제 #1
0
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
0
void TiXmlElement::SetAttribute( const char * name, int val )
{
    char buf[64];
    #if defined(TIXML_SNPRINTF)
        TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
    #else
        sprintf( buf, "%d", val );
    #endif
    SetAttribute( name, buf );
}
예제 #3
0
void TiXmlAttribute::SetIntValue( int _value )
{
    char buf [64];
    #if defined(TIXML_SNPRINTF)
        TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
    #else
        sprintf (buf, "%d", _value);
    #endif
    SetValue (buf);
}
예제 #4
0
파일: tinyxml.cpp 프로젝트: rgde/rgdengine
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 );
}
예제 #5
0
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);
}
예제 #6
0
	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);
		}
	}
예제 #7
0
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
}
예제 #8
0
	void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
	{
		TIXML_SNPRINTF( buffer, bufferSize, "%f", v );
	}
예제 #9
0
	void XMLUtil::ToStr( bool v, char* buffer, int bufferSize )
	{
		TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 );
	}
예제 #10
0
	void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize )
	{
		TIXML_SNPRINTF( buffer, bufferSize, "%u", v );
	}
예제 #11
0
	void XMLUtil::ToStr( int v, char* buffer, int bufferSize )
	{
		TIXML_SNPRINTF( buffer, bufferSize, "%d", v );
	}
예제 #12
0
파일: tinyxml.cpp 프로젝트: dos5gw/TMeter
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.
			// &#xA9;	-- 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;
		}
	}
}
예제 #13
0
void XMLUtil::ToStr( float v, char* buffer, int bufferSize )
{
    TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v );
}
예제 #14
0
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' )
        {

            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 )
        {

            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


            outString->append( buf, (int)strlen( buf ) );
            ++i;
        }
        else
        {

            *outString += (char) c;
            ++i;
        }
    }
}
예제 #15
0
std::string VarFloat::GetString()
{
	char buf[16];
	TIXML_SNPRINTF( buf, sizeof(buf), "%f", value );
	return std::string(buf);
}
예제 #16
0
std::string VarInteger::GetString()
{
	char buf[16];
	TIXML_SNPRINTF( buf, sizeof(buf), "%d", value );
	return std::string(buf);
}