osxlocalepeer.cpp

来自「这是VCF框架的代码」· C++ 代码 · 共 915 行 · 第 1/3 页

CPP
915
字号
	}	return result;}UnicodeString OSXLocalePeer::getCurrencyDecimalPoint(){	CFTextString prop;	prop = (CFStringRef) CFNumberFormatterCopyProperty( currencyNumFormatterRef_, kCFNumberFormatterCurrencyDecimalSeparator );	return prop;}UnicodeString OSXLocalePeer::getCurrencyThousandsSeparator(){	CFTextString prop;	prop = (CFStringRef) CFNumberFormatterCopyProperty( currencyNumFormatterRef_, kCFNumberFormatterGroupingSeparator );	return prop;}UnicodeString OSXLocalePeer::getCurrencySymbol(){	CFTextString prop;	prop = (CFStringRef) CFNumberFormatterCopyProperty( currencyNumFormatterRef_, kCFNumberFormatterCurrencySymbol );	return prop;}int OSXLocalePeer::getCurrencyFractionalDigits(){	int result = 0;	CFRefObject<CFNumberRef> prop;	prop = (CFNumberRef) CFNumberFormatterCopyProperty( currencyNumFormatterRef_, kCFNumberFormatterMinFractionDigits );	if ( NULL != prop ) {		CFNumberGetValue( prop, kCFNumberIntType, &result );	}		return result;}UnicodeString OSXLocalePeer::getCurrencyPositiveSign(){	CFTextString prop;	prop = (CFStringRef) CFNumberFormatterCopyProperty( currencyNumFormatterRef_, kCFNumberFormatterPlusSign );	return prop;}UnicodeString OSXLocalePeer::getCurrencyNegativeSign(){	CFTextString prop;	prop = (CFStringRef) CFNumberFormatterCopyProperty( currencyNumFormatterRef_, kCFNumberFormatterMinusSign );	return prop;}bool OSXLocalePeer::isCharA( const long& charTypeMask, const VCFChar& c ){	long mask = 0;	UnicodeString oldLocaleStr = setlocale( LC_CTYPE, NULL );	setlocale( LC_CTYPE, crtLocaleStr_.ansi_c_str() );	if ( charTypeMask & ctSpace ) {		if ( isspace( c ) ) {			mask |= ctSpace;		}	}	if ( charTypeMask & ctPrint ) {		if ( isprint( c ) ) {			mask |= ctPrint;		}	}	if ( charTypeMask & ctCntrl ) {		if ( isprint( c ) ) {			mask |= ctCntrl;		}	}	if ( charTypeMask & ctCntrl ) {		if ( iscntrl( c ) ) {			mask |= ctCntrl;		}	}	if ( charTypeMask & ctUpper ) {		if ( isupper( c ) ) {			mask |= ctUpper;		}	}	if ( charTypeMask & ctLower ) {		if ( islower( c ) ) {			mask |= ctLower;		}	}	if ( charTypeMask & ctDigit ) {		if ( isdigit( c ) ) {			mask |= ctDigit;		}	}	if ( charTypeMask & ctPunct ) {		if ( ispunct( c ) ) {			mask |= ctPunct;		}	}	if ( charTypeMask & ctHexDigit ) {		if ( isxdigit( c ) ) {			mask |= ctHexDigit;		}	}	if ( charTypeMask & ctAlpha ) {		if ( isalpha( c ) ) {			mask |= ctAlpha;		}	}	if ( charTypeMask & ctAlphaNumeric ) {		if ( isalnum( c ) ) {			mask |= ctAlphaNumeric;		}	}	if ( charTypeMask & ctGraph ) {		if ( isgraph( c ) ) {			mask |= ctGraph;		}	}	setlocale( LC_CTYPE, oldLocaleStr.ansi_c_str() );	return (0 == mask) ? false : true;}UnicodeString OSXLocalePeer::translate( const UnicodeString& id ){	return "";}UnicodeString OSXLocalePeer::toStringFromDate( const DateTime& val, const UnicodeString& format ){	CFTextString result;	unsigned long year;	unsigned long month;	unsigned long day;	unsigned long hour;	unsigned long minute;	unsigned long second;	unsigned long millisecond;		val.get( &year, &month, &day, &hour, &minute, &second, &millisecond );	CFGregorianDate cfDate;	cfDate.year = year;	cfDate.month = month;	cfDate.day = day;	cfDate.hour = hour;	cfDate.minute = minute;	cfDate.second = ((double)second) + ( 1000.0/(double)millisecond );		CFAbsoluteTime timeVal = CFGregorianDateGetAbsoluteTime( cfDate, NULL );	CFRefObject<CFDateRef> dt = CFDateCreate(NULL, timeVal);	CFDateFormatterRef dtFmt = CFDateFormatterCreate(NULL, 													localeRef_, 													kCFDateFormatterLongStyle, 													kCFDateFormatterNoStyle);														result = CFDateFormatterCreateStringWithDate(NULL, dtFmt, dt);		return result;}UnicodeString OSXLocalePeer::toStringFromTime( const DateTime& val, const UnicodeString& format ){	CFTextString result;	unsigned long year;	unsigned long month;	unsigned long day;	unsigned long hour;	unsigned long minute;	unsigned long second;	unsigned long millisecond;		val.get( &year, &month, &day, &hour, &minute, &second, &millisecond );		CFGregorianDate cfDate;	cfDate.year = year;	cfDate.month = month;	cfDate.day = day;	cfDate.hour = hour;	cfDate.minute = minute;	cfDate.second = ((double)second) + ( 1000.0/(double)millisecond );		CFAbsoluteTime timeVal = CFGregorianDateGetAbsoluteTime( cfDate, NULL );	CFRefObject<CFDateRef> dt = CFDateCreate(NULL, timeVal);	CFDateFormatterRef dtFmt = CFDateFormatterCreate(NULL, 													localeRef_, 													kCFDateFormatterNoStyle, 													kCFDateFormatterShortStyle);														result = CFDateFormatterCreateStringWithDate(NULL, dtFmt, dt);		return result;}ulong32 OSXLocalePeer::getLanguageCode(){	CFTextString tmp(CFLocaleGetIdentifier(localeRef_));		UnicodeString id = tmp;		VCF_ASSERT( id.size() >= 2 );	return Locale::stringToLanguageCode( id.substr(0,2) );}ulong32 OSXLocalePeer::getCountryCode(){	CFTextString tmp(CFLocaleGetIdentifier(localeRef_));		UnicodeString id = tmp;		VCF_ASSERT( id.size() >= 2 );		size_t pos = id.find("_");		VCF_ASSERT( pos != UnicodeString::npos );		return Locale::stringToCountryCode( id.substr(pos+1,id.size()-(pos+1)) );}String OSXLocalePeer::getLanguage(){	String result;	return result;}/***CVS Log info*$Log$*Revision 1.4  2006/04/07 02:35:34  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.3.2.3  2006/03/23 05:23:14  ddiego*added missing stub for OSX to locale peer.**Revision 1.3.2.2  2005/11/27 23:55:45  ddiego*more osx updates.**Revision 1.3.2.1  2005/11/13 16:02:46  ddiego*more sox updates.**Revision 1.3  2005/07/09 23:15:04  ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.2.4.1  2005/06/23 01:26:56  ddiego*build updates**Revision 1.2  2004/08/07 02:49:13  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.7  2004/07/27 04:26:04  ddiego*updated devmain-0-6-5 branch with osx changes**Revision 1.1.2.6  2004/06/06 07:05:32  marcelloptr*changed macros, text reformatting, copyright sections**Revision 1.1.2.4  2004/05/03 03:44:53  ddiego*This checks in a bunch of changes to the FoundationKit for OSX*porting. The thread, mutex, semaphor, condition, and file peers*have all been implemented and tested. The file peer could be improved*and needs search functionality. The locale peer is only partially*complete, but the functions will return values. The unicode transition*is also finished and works OK now.**Revision 1.1.2.3  2004/04/30 05:44:34  ddiego*added OSX changes for unicode migration**Revision 1.2  2004/04/03 15:48:47  ddiego*Merged over code from the 0-6-3 branch.**Revision 1.1.2.1  2004/02/21 03:27:09  ddiego*updates for OSX porting**Revision 1.1.2.1  2004/02/16 05:38:10  ddiego*updated linux makefiles as a result of new locale support - pushed in stubs for locale peer impl, but no functionality at this point**Revision 1.1.2.1  2004/02/16 04:08:44  ddiego*updates some missing locale impl files**/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?