void ParserKeyword::initSizeKeyword(const Json::JsonObject& sizeObject) { if (sizeObject.is_object()) { std::string sizeKeyword = sizeObject.get_string("keyword"); std::string sizeItem = sizeObject.get_string("item"); initSizeKeyword(sizeKeyword, sizeItem); } else { m_keywordSizeType = ParserKeywordSizeEnumFromString( sizeObject.as_string() ); } }
void ParserKeyword::initMatchRegex(const Json::JsonObject& jsonObject) { if (!jsonObject.has_item("deck_name_regex")) return; const Json::JsonObject regexStringObject = jsonObject.get_item("deck_name_regex"); if (!regexStringObject.is_string()) throw std::invalid_argument("The 'deck_name_regex' JSON item of keyword "+m_name+" need to be a string"); setMatchRegex(regexStringObject.as_string()); }
void ParserKeyword::initSectionNames(const Json::JsonObject& jsonObject) { if (!jsonObject.has_item("sections")) throw std::invalid_argument("The 'sections' JSON item of keyword "+m_name+" needs to be defined"); const Json::JsonObject namesObject = jsonObject.get_item("sections"); if (!namesObject.is_array()) throw std::invalid_argument("The 'sections' JSON item of keyword "+m_name+" needs to be a list"); m_validSectionNames.clear(); for (size_t nameIdx = 0; nameIdx < namesObject.size(); ++ nameIdx) { const Json::JsonObject nameObject = namesObject.get_array_item(nameIdx); if (!nameObject.is_string()) throw std::invalid_argument("The sub-items of 'sections' of keyword "+m_name+" need to be strings"); addValidSectionName(nameObject.as_string()); } }
void ParserKeyword::initDeckNames(const Json::JsonObject& jsonObject) { if (!jsonObject.has_item("deck_names")) return; const Json::JsonObject namesObject = jsonObject.get_item("deck_names"); if (!namesObject.is_array()) throw std::invalid_argument("The 'deck_names' JSON item of keyword "+m_name+" needs to be a list"); if (namesObject.size() > 0) m_deckNames.clear(); for (size_t nameIdx = 0; nameIdx < namesObject.size(); ++ nameIdx) { const Json::JsonObject nameObject = namesObject.get_array_item(nameIdx); if (!nameObject.is_string()) throw std::invalid_argument("The sub-items of 'deck_names' of keyword "+m_name+" need to be strings"); addDeckName(nameObject.as_string()); } }