Пример #1
0
char* Value_time_imp::get_String( 
	char*	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* pEnd = nullptr;

	if( inBufferChars < tslen(kTimeStrMaxLength) )
	{
		String res( get_String( inBufferChars ) );
		tslen len = res.length();
		memcpy( outString, res.getBufferA(), len );
		*(outString + len) = 0;
		pEnd = outString + len;
	}
	else
	{
		const DTFormat* pDTFormat = get_DTFormat();
		Convert_time_str_aa_fast( 
			(TimeEncoded&)mValue, static_cast<char>(pDTFormat->mTimeSep), outString );

		pEnd = outString + kTimeStrMaxLength;
	}

	return pEnd;
}
Пример #2
0
void Convert_bin_datetime( 
	const I_Value*	inValue, 
	I_Value*		outValue )
{
	I_ValueDateTime* pValueDateTime = dcast< I_ValueDateTime* >( outValue );
	const DTFormat* pDTFormat = pValueDateTime->get_DTFormat();

	// TODO:
	// Currently we assume inValue is a single-byted string.
	// After we make everything localizable we can improve this using IOConverter as we do
	// for string values.
	//

	const char* pBinStart = inValue->begin();
	const char* pBinEnd = inValue->end();
	
	if( pBinStart )
	{
		char strDateTime[kDateTimeStrMaxLength + 1];
		
		tslen len = tslen(pBinEnd - pBinStart);
		memcpy( strDateTime, pBinStart, Min(len, (tslen)kDateTimeStrMaxLength) );

		Convert_str_datetime_aa_aux( 
			strDateTime,
			pDTFormat,
			*(DateTimeEncoded*) outValue->begin() );	
	}
}
Пример #3
0
UChar* Value_date_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;

	UChar* pEnd = nullptr;

	if( inBufferChars < tslen(kDateStrMaxLength) )
	{
		String res( get_String( inBufferChars ) );
		tslen len = res.length();
		memcpy( outString, res.begin(), len * sizeof(UChar) );
		*(outString + len) = 0;
		pEnd = outString + len;
	}
	else
	{
		const DTFormat* pDTFormat = get_DTFormat();

		Convert_date_str_fast( 
			(DateEncoded&)mValue, pDTFormat->mDateFormat, pDTFormat->mDateSep, outString );

		pEnd = ( ((DateEncoded&)mValue).encoded < 0 ) ? 
						outString + kDateStrMaxLength : 
						outString + kDateStrMaxLength - 1;
	}

	return pEnd;
}	
Пример #4
0
//	UChar*  =>  vuint64
//
vuint64 u_ustoull( const UChar* inStr )
{
    char buf[kULLongStrMaxLen + 1];

    if( inStr )
    {
        vuint32 len = (vuint32) vu_strlen(inStr);
        vu_u2a(inStr, buf, tslen( Min(len, kULLongStrMaxLen)) );
    }
    else
    {
        return 0;
    }

#ifdef _MSC_VER

    vuint64 value = 0;
    sscanf(buf, "%I64u", &value);

#else

    unsigned long long value = 0;
    sscanf(buf, "%llu", &value);

#endif //_MSC_VER

    return value;
}
Пример #5
0
//	UChar*  =>  vint64
//
vint64 u_utoll( const UChar* inStr )
{
    char buf[kLLongStrMaxLen + 1];
    if( inStr )
    {
        vuint32 len = (vuint32) vu_strlen(inStr);
        vu_u2a(inStr, buf, tslen( Min(len, kLLongStrMaxLen) ) );
    }
    else
    {
        return 0;
    }

#ifdef _MSC_VER

    vint64 value = (vint64) _atoi64( buf );

#else

    char* stopChar = nullptr;
    vint64 value = (vint64) strtoll( buf, &stopChar, 10 );

#endif //_MSC_VER

    return value;
}
Пример #6
0
// Convert functions. For HI perfomance.
//
vuint16 Convert_str_datetime_uu_fast( 
	const UChar*		inStr,
	const UChar*		inStrEnd,
	const DTFormat*		inFormat,
	DateTimeEncoded&	outDateTimeEnc )
{
	char strDateTime[kDateTimeStrMaxLength + 1];
	
	tslen len = tslen( inStrEnd - inStr );
	vu_u2a( inStr, strDateTime, len );

	return Convert_str_datetime_aa_fast( strDateTime, inFormat, outDateTimeEnc );
}
Пример #7
0
// WRAPPER, from UChar* to char* 
//
void Convert_str_time_uu_fast( 
	const UChar*		inStr, 
	const UChar*		inStrEnd, 
	const DTFormat*		inDTFormat,
	TimeEncoded&		outTimeEnc )
{
	char strTime[kTimeStrMaxLength + 1];
	
	tslen len = tslen( inStrEnd - inStr );
	vu_u2a(inStr, strTime, len);
	
	Convert_str_time_aa_fast(strTime, inDTFormat, outTimeEnc );
}
Пример #8
0
//	UChar*  =>  double
//
double u_utof( const UChar* inStr )
{
    char buf[kDoubleStrMaxLen + 1];
    if( inStr )
    {
        vuint32 len = (vuint32) vu_strlen(inStr);
        vu_u2a(inStr, buf, tslen( Min(len, kDoubleStrMaxLen) ) );

        return atof(buf);
    }
    else
    {
        return 0.0;
    }
}
Пример #9
0
// WRAPPER: UChar* => char*
//
void Convert_str_time_uu_aux( 
	const UChar*		inStr,
	const UChar*		inStrEnd,
	const DTFormat* 	inDTFormat,
	TimeEncoded&		ioTime )
{
	if( !inStr )
		return;

	char strTime[kTimeStrMaxLength + 1];
	
	tslen len = inStrEnd ? tslen(inStrEnd - inStr) : vu_strlen(inStr);
	vu_u2a(inStr, strTime, len);

	Convert_str_time_aa_aux( strTime, inDTFormat, ioTime );
}
Пример #10
0
// WRAPPER: UChar* => char*
//
void Convert_str_date_uu_aux( 
	const UChar*		inStr,
	const UChar*		inStrEnd,
	const DTFormat* 	inDTFormat,
	DateEncoded&		ioDate )
{
	if( !inStr )
		return;

	char strDate[kDateStrMaxLength + 1];

	tslen len = inStrEnd ? tslen(inStrEnd - inStr) : vu_strlen(inStr);
	vu_u2a( inStr, strDate, len );

	return Convert_str_date_aa_aux( 
					strDate, 
					inDTFormat,
					ioDate );
}
Пример #11
0
FBL_Begin_Namespace


#pragma mark === Internal convert functions ===


/**********************************************************************************************/
// WRAPPER, from UChar* to char* 
//
vuint16 Convert_str_date_uu_fast( 
	const UChar*	inStr, 
	const UChar*	inStrEnd, 
	const DTFormat*	inDateFormat,
	DateEncoded&	outDateEnc )
{
	/// maybe this is a temporary solution...
	char strDate[kDateStrMaxLength + 1];

	tslen len = tslen( inStr - inStrEnd );
	vu_u2a( inStr, strDate, len );

	return Convert_str_date_aa_fast( strDate, inDateFormat, outDateEnc );
}