本文整理汇总了C++中LocalPointer::format方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalPointer::format方法的具体用法?C++ LocalPointer::format怎么用?C++ LocalPointer::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalPointer
的用法示例。
在下文中一共展示了LocalPointer::format方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
virtual void run()
{
fTraceInfo = 1;
LocalPointer<NumberFormat> percentFormatter;
UErrorCode status = U_ZERO_ERROR;
#if 0
// debugging code,
for (int i=0; i<4000; i++) {
status = U_ZERO_ERROR;
UDataMemory *data1 = udata_openChoice(0, "res", "en_US", isAcceptable, 0, &status);
UDataMemory *data2 = udata_openChoice(0, "res", "fr", isAcceptable, 0, &status);
udata_close(data1);
udata_close(data2);
if (U_FAILURE(status)) {
error("udata_openChoice failed.\n");
break;
}
}
return;
#endif
#if 0
// debugging code,
int m;
for (m=0; m<4000; m++) {
status = U_ZERO_ERROR;
UResourceBundle *res = NULL;
const char *localeName = NULL;
Locale loc = Locale::getEnglish();
localeName = loc.getName();
// localeName = "en";
// ResourceBundle bund = ResourceBundle(0, loc, status);
//umtx_lock(&gDebugMutex);
res = ures_open(NULL, localeName, &status);
//umtx_unlock(&gDebugMutex);
//umtx_lock(&gDebugMutex);
ures_close(res);
//umtx_unlock(&gDebugMutex);
if (U_FAILURE(status)) {
error("Resource bundle construction failed.\n");
break;
}
}
return;
#endif
// Keep this data here to avoid static initialization.
FormatThreadTestData kNumberFormatTestData[] =
{
FormatThreadTestData((double)5.0, UnicodeString("5", "")),
FormatThreadTestData( 6.0, UnicodeString("6", "")),
FormatThreadTestData( 20.0, UnicodeString("20", "")),
FormatThreadTestData( 8.0, UnicodeString("8", "")),
FormatThreadTestData( 8.3, UnicodeString("8.3", "")),
FormatThreadTestData( 12345, UnicodeString("12,345", "")),
FormatThreadTestData( 81890.23, UnicodeString("81,890.23", "")),
};
int32_t kNumberFormatTestDataLength = (int32_t)(sizeof(kNumberFormatTestData) /
sizeof(kNumberFormatTestData[0]));
// Keep this data here to avoid static initialization.
FormatThreadTestData kPercentFormatTestData[] =
{
FormatThreadTestData((double)5.0, CharsToUnicodeString("500\\u00a0%")),
FormatThreadTestData( 1.0, CharsToUnicodeString("100\\u00a0%")),
FormatThreadTestData( 0.26, CharsToUnicodeString("26\\u00a0%")),
FormatThreadTestData(
16384.99, CharsToUnicodeString("1\\u00a0638\\u00a0499\\u00a0%")), // U+00a0 = NBSP
FormatThreadTestData(
81890.23, CharsToUnicodeString("8\\u00a0189\\u00a0023\\u00a0%")),
};
int32_t kPercentFormatTestDataLength =
(int32_t)(sizeof(kPercentFormatTestData) / sizeof(kPercentFormatTestData[0]));
int32_t iteration;
status = U_ZERO_ERROR;
LocalPointer<NumberFormat> formatter(NumberFormat::createInstance(Locale::getEnglish(),status));
if(U_FAILURE(status)) {
error("Error on NumberFormat::createInstance().");
goto cleanupAndReturn;
}
percentFormatter.adoptInstead(NumberFormat::createPercentInstance(Locale::getFrench(),status));
if(U_FAILURE(status)) {
error("Error on NumberFormat::createPercentInstance().");
goto cleanupAndReturn;
}
for(iteration = 0;!getError() && iteration<kFormatThreadIterations;iteration++)
{
int32_t whichLine = (iteration + fOffset)%kNumberFormatTestDataLength;
UnicodeString output;
//.........这里部分代码省略.........