Esempio n. 1
0
void CJSONWriter::Val(const CFSVar &Var) {
	switch (Var.GetType()) {
		case CFSVar::VAR_EMPTY:
			NullVal();
		break;
		case CFSVar::VAR_INT:
			IntVal(Var.GetInt());
		break;
		case CFSVar::VAR_FLOAT:
			FloatVal(Var.GetFloat());
		break;
		case CFSVar::VAR_BOOL:
			BoolVal(Var.GetBool());
		break;
		case CFSVar::VAR_STRING:
			StringVal(Var.GetAString());
		break;
		case CFSVar::VAR_MAP:
			ObjectStart();
			for (INTPTR ip=0; ip<Var.GetSize(); ip++) {
				CFSAString szKey=Var.GetKey(ip);
				Key(szKey);
				Val(Var[szKey]);
			}
			ObjectEnd();
		break;
		case CFSVar::VAR_ARRAY:
			ArrayStart();
			for (INTPTR ip=0; ip<Var.GetSize(); ip++) {
				Val(Var[ip]);
			}
			ArrayEnd();
		break;
	}
}
Esempio n. 2
0
// convert output to wrapper format
std::vector<SpellingResults> convertSpellingOutput(CFSArray<CFSVar>& words) {
    std::vector<SpellingResults> results;
    results.reserve(words.GetSize());
    for (int widx=0 ; widx < words.GetSize() ; ++widx) {
        CFSVar word = words[widx];
        std::string text = std::string(word["text"].GetAString());
        CFSVar suggestions = word["suggestions"];
        StringVector suggestStrings;
        suggestStrings.reserve(suggestions.GetSize());
        for (int sidx=0 ; sidx < suggestions.GetSize() ; ++sidx) {
            CFSVar suggestion = suggestions[sidx];
            suggestStrings.push_back(std::string(suggestion.GetAString()));
        }
        results.push_back(SpellingResults(text, word["spelling"].GetInt(), suggestStrings));
    }
    return results;
}