Line data Source code
1 : /* 2 : * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : #include "config_json_parser_base.h" 5 : 6 : #include <boost/lexical_cast.hpp> 7 : 8 : #include "config_cassandra_client.h" 9 : 10 : #include "base/autogen_util.h" 11 : #include "config_client_log_types.h" 12 : 13 3673 : ConfigJsonParserBase::ConfigJsonParserBase(){ 14 3673 : } 15 : 16 3673 : ConfigJsonParserBase::~ConfigJsonParserBase() { 17 3673 : } 18 : 19 0 : void ConfigJsonParserBase::EndOfConfig() { 20 0 : return; 21 : } 22 : 23 1614 : std::string ConfigJsonParserBase::GetParentName(const string &left, 24 : const string &right) const { 25 : ParentNameMap::const_iterator it = 26 1614 : parent_name_map_.find(make_pair(left, right)); 27 1614 : if (it == parent_name_map_.end()) 28 0 : return ""; 29 1614 : return it->second; 30 : } 31 : 32 1205 : std::string ConfigJsonParserBase::GetLinkName(const string &left, 33 : const string &right) const { 34 : LinkNameMap::const_iterator it = 35 1205 : link_name_map_.find(make_pair(left, right)); 36 1205 : if (it == link_name_map_.end()) 37 0 : return ""; 38 1205 : return it->second.first; 39 : } 40 : 41 1205 : bool ConfigJsonParserBase::IsLinkWithAttr(const string &left, 42 : const string &right) const { 43 : LinkNameMap::const_iterator it = 44 1205 : link_name_map_.find(make_pair(left, right)); 45 1205 : if (it == link_name_map_.end()) 46 0 : return false; 47 1205 : return it->second.second; 48 : } 49 : 50 528 : std::string ConfigJsonParserBase::GetWrapperFieldName(const string &type_name, 51 : const string &property_name) const { 52 : WrapperFieldMap::const_iterator it = 53 528 : wrapper_field_map_.find(type_name+':'+property_name); 54 528 : if (it == wrapper_field_map_.end()) { 55 0 : return ""; 56 : } else { 57 : // TODO: Fix the autogen to have _ instead of - 58 528 : string temp_str = it->second; 59 528 : std::replace(temp_str.begin(), temp_str.end(), '-', '_'); 60 528 : return temp_str; 61 528 : } 62 : } 63 : 64 191 : bool ConfigJsonParserBase::IsListOrMapPropEmpty(const string &uuid_key, 65 : const string &lookup_key) const { 66 191 : return mgr_->config_db_client()->IsListOrMapPropEmpty(uuid_key, lookup_key); 67 : } 68 :