コード例 #1
0
ファイル: dicttrieperf.cpp プロジェクト: MIPS/external-icu
 BytesTrieDictLookup(const DictionaryTriePerfTest &perfTest)
         : DictLookup(perfTest), trie(NULL), noDict(FALSE) {
     IcuToolErrorCode errorCode("BytesTrieDictLookup()");
     builder=new BytesTrieBuilder(errorCode);
     CharString str;
     const ULine *lines=perf.getCachedLines();
     int32_t numLines=perf.getNumLines();
     for(int32_t i=0; i<numLines; ++i) {
         // Skip comment lines (start with a character below 'A').
         if(lines[i].name[0]<0x41) {
             continue;
         }
         if(!thaiWordToBytes(lines[i].name, lines[i].len, str.clear(), errorCode)) {
             fprintf(stderr, "thaiWordToBytes(): failed for word %ld (0-based)\n", (long)i);
             noDict=TRUE;
             break;
         }
         builder->add(str.toStringPiece(), 0, errorCode);
     }
     if(!noDict) {
         int32_t length=builder->buildStringPiece(USTRINGTRIE_BUILD_SMALL, errorCode).length();
         printf("size of BytesTrie:           %6ld bytes\n", (long)length);
         trie=builder->build(USTRINGTRIE_BUILD_SMALL, errorCode);
     }
 }
コード例 #2
0
ファイル: gendict.cpp プロジェクト: Acorld/WinObjC-Heading
 // add a word to the trie
 void addWord(const UnicodeString &word, int32_t value, UErrorCode &status) {
     if (bt) {
         CharString buf;
         transform(word, buf, status);
         bt->add(buf.toStringPiece(), value, status);
     }
     if (ut) { ut->add(word, value, status); }
 }
コード例 #3
0
ファイル: fmtable.cpp プロジェクト: MIPS/external-icu
// --------------------------------------
StringPiece Formattable::getDecimalNumber(UErrorCode &status) {
    if (U_FAILURE(status)) {
        return "";
    }
    if (fDecimalStr != NULL) {
      return fDecimalStr->toStringPiece();
    }

    CharString *decimalStr = internalGetCharString(status);
    if(decimalStr == NULL) {
      return ""; // getDecimalNumber returns "" for error cases
    } else {
      return decimalStr->toStringPiece();
    }
}