String Value_datetime_imp::get_String( tslen inLimit ) const
{
	String str;

	if( inLimit != 0 )
	{
		UChar* p = str.getBuffer(kDateTimeStrMaxLength + 1);

		const DTFormat* pDTFormat = get_DTFormat();

		Convert_datetime_str_fast( 
			(DateTimeEncoded&)mValue, 
			pDTFormat->mDateFormat,
			pDTFormat->mDateSep,
			pDTFormat->mTimeSep,
			p );

		if( ((DateTimeEncoded&)mValue).encoded < 0 )
			str.releaseBuffer(kDateTimeStrMaxLength);		// 24 symbols for negative dates
		else
			str.releaseBuffer(kDateTimeStrMaxLength - 1);	// 23 symbols for positive dates

		// not -1 and less than maxLen
		if( inLimit > 0 && vuint32(inLimit) < kDateTimeStrMaxLength )
		{
			str.truncate( inLimit );
		}
	}

	return str;
}
Example #2
0
File: test.cpp Project: nandai/slog
void JsonTest::test02()
{
    SLOG(CLS_NAME, "test01");

    String str;
    Json* json1 = Json::getNewObject();

    Json* json2 = Json::getNewObject();
    json2->add("addr", "Tokyo");
    json2->add("tel", "03");
    json1->add(json2);

    Json* json3 = Json::getNewObject();
    json3->add("addr", "Osaka");
    json3->add("tel", "06");
    json1->add(json3);

    json1->serialize(&str);
    SMSG(slog::DEBUG, "%s", str.getBuffer());
    SASSERT("01", str.equals(
        "["
            "{\"addr\":\"Tokyo\",\"tel\":\"03\"},"
            "{\"addr\":\"Osaka\",\"tel\":\"06\"}"
        "]"));

    delete json1;
}
Example #3
0
File: test.cpp Project: nandai/slog
void JsonTest::test01()
{
    SLOG(CLS_NAME, "test01");

    String str;
    Json* json1 = Json::getNewObject();

    json1->serialize(&str);
    SMSG(slog::DEBUG, "%s", str.getBuffer());
    SASSERT("01", str.equals("{}"));

    json1->add("name", "printf");
    json1->serialize(&str);
    SMSG(slog::DEBUG, "%s", str.getBuffer());
    SASSERT("02", str.equals("{\"name\":\"printf\"}"));

    delete json1;
}
Example #4
0
File: test.cpp Project: nandai/slog
void JsonTest::test04()
{
    SLOG(CLS_NAME, "test04");

    String str;
    Json* json1 = Json::getNewObject();

    json1->add("id", 1);
    json1->serialize(&str);
    SMSG(slog::DEBUG, "%s", str.getBuffer());
    SASSERT("01", str.equals("{\"id\":1}"));
}
Example #5
0
File: test.cpp Project: nandai/slog
void JsonTest::test03()
{
    SLOG(CLS_NAME, "test03");
    String str;

    Json* json1 = Json::getNewObject();
    Json* json2 = Json::getNewObject("messages");

    json1->add(json2);
    json1->add("kind", "0003");

    json1->serialize(&str);
    SMSG(slog::DEBUG, "%s", str.getBuffer());
    SASSERT("01", str.equals("{\"messages\":[],\"kind\":\"0003\"}"));

    delete json1;
}
Example #6
0
String Value_money_imp::get_String( tslen inLimit ) const
{
	String str;
	
	if( inLimit != 0 )
	{
		tslen MaxLen = get_MaxChars();
		tslen BuffLength = MaxLen + 1;
		UChar* pBuffer = str.getBuffer( BuffLength );
		UChar* pEnd    = get_String( pBuffer, MaxLen ); // copy str into buffer.

		str.releaseBuffer( static_cast<tslen>(pEnd - pBuffer) );

		// not -1 and less than maxLen
		if( inLimit > 0 && inLimit < MaxLen )
		{
			str.truncate( inLimit );
		}
	}
	
	return str;
}