AttributeValueStringSet::AttributeValueStringSet(const JsonValue& jsonValue) { Array<JsonValue> ss = jsonValue.GetArray("SS"); for (unsigned i = 0; i < ss.GetLength(); ++i) { m_sS.push_back(ss[i].AsString()); } }
AttributeValueByteBufferSet::AttributeValueByteBufferSet(const JsonValue& jsonValue) { const Array<JsonValue>&& bs = jsonValue.GetArray("BS"); for (unsigned i = 0; i < bs.GetLength(); ++i) { m_bS.push_back(HashingUtils::Base64Decode(bs[i].AsString())); } }
AttributeValueNumberSet::AttributeValueNumberSet(const JsonValue& jsonValue) { const Array<JsonValue>&& ns = jsonValue.GetArray("NS"); for (unsigned i = 0; i < ns.GetLength(); ++i) { m_nS.push_back(ns[i].AsString()); } }
AttributeValueList::AttributeValueList(const JsonValue& jsonValue) { const Array<JsonValue> array = jsonValue.GetArray("L"); for (unsigned i = 0; i < array.GetLength(); ++i) { std::shared_ptr<AttributeValue> attributeValue = Aws::MakeShared<AttributeValue>("AttributeValue"); JsonValue itemValue = array[i]; *attributeValue = itemValue; m_l.push_back(attributeValue); } }
bool TournamentConfig::Load(const std::string &fileName) { JsonValue json; bool ret = JsonReader::ParseFile(json, fileName); if (ret) { std::string value; if (json.GetValue("version", value)) { if (value == TOURNAMENT_CONFIG_VERSION) { // Setup tournament configuration mOptions.turns.clear(); JsonValue tournament = json.FindValue("tournament"); if (tournament.GetArray().Size() > 0U) { for (JsonArray::Iterator iter = tournament.GetArray().Begin(); iter != tournament.GetArray().End(); ++iter) { if (iter->IsObject()) { JsonValue value = iter->GetObj().GetValue("type"); Tarot::Distribution shuffle; if (value.IsString()) { if (value.GetString() == "custom") { shuffle.mType = Tarot::Distribution::CUSTOM_DEAL; value = iter->GetObj().GetValue("file"); if (value.IsString()) { shuffle.mFile = value.GetString(); } else { ret = false; } } else if (value.GetString() == "random") { shuffle.mType = Tarot::Distribution::RANDOM_DEAL; } else if (value.GetString() == "numbered") { shuffle.mType = Tarot::Distribution::NUMBERED_DEAL; shuffle.mSeed = iter->GetObj().GetValue("number").GetInteger(); // FIXME we can add a test on the type here before setting the seed } else { TLogError("Unsupported deal type value"); ret = false; } } if (ret) { mOptions.turns.push_back(shuffle); } } } } else { TLogError("No tournament details"); ret = false; } } else { TLogError("Wrong tournament configuration file version"); ret = false; } } else { TLogError("Cannot read tournament configuration file version"); ret = false; } } else { TLogError("Cannot open tournament configuration file" + fileName); } if (!ret) { // Overwrite old file with default value mOptions = GetDefault(); ret = Save(fileName); } mLoaded = true; return ret; }