コード例 #1
0
    void ParserKeyword::initSize(const Json::JsonObject& jsonConfig) {
        // The number of record has been set explicitly with the size: keyword
        if (jsonConfig.has_item("size")) {
            Json::JsonObject sizeObject = jsonConfig.get_item("size");

            if (sizeObject.is_number()) {
                m_fixedSize = (size_t) sizeObject.as_int();
                m_keywordSizeType = FIXED;
            } else
                initSizeKeyword(sizeObject);

        } else {
            if (jsonConfig.has_item("num_tables")) {
                Json::JsonObject numTablesObject = jsonConfig.get_item("num_tables");

                if (!numTablesObject.is_object())
                    throw std::invalid_argument("The num_tables key must point to a {} object");

                initSizeKeyword(numTablesObject);
                m_isTableCollection = true;
            } else {
                if (jsonConfig.has_item("items") || jsonConfig.has_item("records"))
                    // The number of records is undetermined - the keyword will be '/' terminated.
                    m_keywordSizeType = SLASH_TERMINATED;
                else {
                    m_keywordSizeType = FIXED;
                    if (jsonConfig.has_item("data"))
                        m_fixedSize = 1;
                    else
                        m_fixedSize = 0;
                }
            }
        }
    }
コード例 #2
0
 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() );
     }
 }