UChar* Value_money_imp::get_String(
	UChar* 			outString,
	tslen 			inBufferChars ) const
{
	// The size of input buffer (inBufferChars) cannot be -1 !
	// Because this is unsafe then to write to  the memory 
	// location pointed by outString - because we don't know the size !
	if( outString == nullptr || inBufferChars <= 0 )
		return nullptr;

	char money_str[kMoneyStrMaxLength + 1];
	
	int num = snprintf(
				money_str,
				kMoneyStrMaxLength,
				"%.*f",
				(int) MONEY_PRECISION,
				get_Double() );

	tslen char_count = ( num < 0 ) ? kMoneyStrMaxLength : num;
	if( char_count > inBufferChars )
		char_count = inBufferChars;

	vu_a2u( money_str, outString, char_count );

	return outString + char_count;
}
tslen Convert_time_str_uu_fast( 
	const TimeEncoded&	inTimeEnc, 
	const UChar			inSep, 
	UChar*				outString )
{
	char strTime[kTimeStrMaxLength + 1];
	
	tslen len = Convert_time_str_aa_fast(inTimeEnc, static_cast<char>(inSep), strTime);
	vu_a2u(strTime, outString, len);
	
	return len;	
}
Exemple #3
0
//	vuint32  =>  UChar*
//
UChar* u_ultous( vuint32 inNum, UChar* outBuf )
{
    const vuint32 buff_size = kULongStrMaxLen + 1;
    char buf[kULongStrMaxLen + 1];

    // use ANSI char* library to convert from the number
    int len = snprintf( buf, buff_size, "%lu", (unsigned long) inNum );

    // CONVERT char* to UChar* string
    vu_a2u( buf, outBuf, len );

    return outBuf + len;
}
Exemple #4
0
//	double  =>  UChar*
//
UChar* u_ftos( double inNum, UChar* outBuf )
{
    const vuint32 buff_size = kDoubleStrMaxLen + 1;
    char buf[buff_size];

    // use ANSI char* library to convert from the number
    int len = snprintf( buf, buff_size, "%g", inNum );

    // CONVERT char* to UChar* string
    vu_a2u(buf, outBuf, len );

    return outBuf + len;
}
Exemple #5
0
tslen Convert_date_str_fast( 
	const DateEncoded&	inDateEnc, 
	const EDateFormat	inDateFormat,
	const UChar			inSep, 
	UChar*				outString )
{
	/// maybe this is temporary solution...
	char strDate[kDateStrMaxLength+1];
	
	tslen len = Convert_date_str_fast(inDateEnc, inDateFormat, (char)inSep, strDate);
	vu_a2u(strDate, outString, len);

	return len;
}
void Convert_time_str( 
	const I_Value*	inValue, 
	I_Value*		outValue )
{
	const I_ValueTime* pValueTime = dcast< const I_ValueTime* >( inValue );
	const DTFormat* pDTFormat = pValueTime->get_DTFormat();

	char strTime[kTimeStrMaxLength + 1];	
	tslen len = Convert_time_str_aa_fast(*(TimeEncoded*)inValue->begin(), static_cast<char>(pDTFormat->mTimeSep), strTime);

	vuint32 outValueLen = outValue->get_MaxChars();
	len = ( (tslen)outValueLen < len ) ? outValueLen : len;
	vu_a2u(strTime, (UChar*) outValue->begin(), len);		
	outValue->put_ByteLength( len * sizeof(UChar) );		
}
Exemple #7
0
//	vint32  =>  UChar*
//
// Not safe.
// Safe is: type_traits<vint32>::to_str()
//
UChar* u_ltou( vint32 inNum, UChar* outBuf )
{
    int len;

    const vuint32 buff_size = kLongStrMaxLen + 1;
    char buf[buff_size + 1];

    // use ANSI char* library to convert from the number
    len = snprintf( buf, buff_size, "%ld", (long) inNum );

    // CONVERT char* to UChar* string
    vu_a2u( buf, outBuf, len );		// not safe. We don't know size of buffer.

    return outBuf + len;
}
Exemple #8
0
//	vuint64  =>  UChar*
//
UChar* u_ulltous( vuint64 inNum, UChar* outBuf )
{
    const vuint32 buff_size = kULLongStrMaxLen + 1;
    char str[buff_size];

    // use ANSI char* library to convert from the number
#ifdef 	_MSC_VER
    int len = snprintf( str, buff_size, "%I64u", inNum );
#else
    int len = snprintf( str, buff_size, "%llu", (unsigned long long) inNum );
#endif

    // CONVERT char* to UChar* string
    vu_a2u(str, outBuf, len );

    return outBuf + len;
}
Exemple #9
0
void Convert_date_str( 
	const I_Value*	inValue, 
	I_Value*		outValue)
{
	const I_ValueDate* pValueDate = dcast< const I_ValueDate* >( inValue );
	const DTFormat* pDTFormat = pValueDate->get_DTFormat();

	/// maybe this is temporary solution...
	char strDate[kDateStrMaxLength+1];
	
	tslen len = Convert_date_str_fast(	*(DateEncoded*)inValue->begin(), 
										pDTFormat->mDateFormat, 
										(char)pDTFormat->mDateSep, 
										strDate);

	vuint32 outValueLen = outValue->get_MaxChars();
	len = ( (tslen)outValueLen < len ) ? outValueLen : len;
	vu_a2u(strDate, (UChar*) outValue->begin(), len);		
	outValue->put_ByteLength( len * sizeof(UChar) );		
}
tslen Convert_datetime_str_fast( 
	const DateTimeEncoded&	inDateTimeEnc, 
	EDateFormat				inDateFormat, 
	const UChar				inDateSep, 
	const UChar				inTimeSep, 
	UChar*					outString )
{
	// This is not safe to use such a buffer lenght.
	// Because sprintf() may exceed it.
	//char str_dt[kDateTimeStrMaxLength + 1];
	char strDateTime[128];

	tslen len = Convert_datetime_str_fast(inDateTimeEnc, 
							  inDateFormat, 
							  static_cast<char>(inDateSep), 
							  static_cast<char>(inTimeSep), 
							  strDateTime);
	vu_a2u(strDateTime, outString, len);
	
	return len;
}