MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / ParseLexiconFromFile

Method ParseLexiconFromFile

src/Lexicon.cpp:79–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79LexiconPtr Lexicon::ParseLexiconFromFile(FILE* fp) {
80 const int ENTRY_BUFF_SIZE = 4096;
81 char buff[ENTRY_BUFF_SIZE];
82 LexiconPtr lexicon(new Lexicon);
83 UTF8Util::SkipUtf8Bom(fp);
84
85 size_t lineNum = 1;
86 while (fgets(buff, ENTRY_BUFF_SIZE, fp)) {
87 if (*buff == '#') {
88 lineNum++;
89 continue;
90 }
91 DictEntry* entry = ParseKeyValues(buff, lineNum);
92 if (entry != nullptr) {
93 lexicon->Add(entry);
94 }
95 lineNum++;
96 }
97 return lexicon;
98}
99
100LexiconPtr Lexicon::ParseLexiconFromBuffer(const char* data, size_t size) {
101 LexiconPtr lexicon(new Lexicon);

Callers

nothing calls this directly

Calls 2

ParseKeyValuesFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected