Skip to content

Commit

Permalink
Use contrail_rapidjson as namespace to allow multiple versions
Browse files Browse the repository at this point in the history
Different versions rapidjson code which is headers only though still needs to
be kept separately as they contain templates. When instantiated, class from
one version can collide with another and produce undesired and unexpected
outcome.

Use a separate namespace contrail_rapidjson as a fix in all of contrail code

Partial-Bug: #1632470

Change-Id: Ifbd31fc229572ac456265710f7055e21813c7883
  • Loading branch information
ananth-at-camphor-networks committed Feb 14, 2017
1 parent e908adf commit 08bfd5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions ifmap_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def getMetaParentName(meta):
meta = self._meta
fnname = '%s_ParseJsonMetadata' % meta.getCppName()
file.write('bool %s(\n' % fnname)
file.write(' const rapidjson::Value &parent,\n')
file.write(' const contrail_rapidjson::Value &parent,\n')
file.write(' std::auto_ptr<AutogenProperty > *resultp) {\n')

if meta.getCType():
Expand Down Expand Up @@ -323,7 +323,7 @@ def GenerateJsonParser(self, JsonDecoderDict, file):

if not meta.getCType():
decl = """
bool %s::ParseJsonMetadata(const rapidjson::Value &parent,
bool %s::ParseJsonMetadata(const contrail_rapidjson::Value &parent,
std::auto_ptr<AutogenProperty> *resultp) {
%sData *data = new %sData();
resultp->reset(data);
Expand Down Expand Up @@ -443,7 +443,7 @@ def GenerateServer(self, file, MetaDict):
return true;
}
static bool ParseJsonLinkMetadata(const rapidjson::Value &parent,
static bool ParseJsonLinkMetadata(const contrail_rapidjson::Value &parent,
std::auto_ptr<AutogenProperty> *resultp) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions type_classgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def _GenerateTypeSub(self, file, ctype):
std::auto_ptr<AutogenProperty> *resultp);
void Encode(pugi::xml_node *node) const;
void CalculateCrc(boost::crc_32_type *crc) const;
bool JsonParse(const rapidjson::Value &node);
static bool JsonParseProperty(const rapidjson::Value &node,
bool JsonParse(const contrail_rapidjson::Value &node);
static bool JsonParseProperty(const contrail_rapidjson::Value &node,
std::auto_ptr<AutogenProperty> *resultp);
};
""" % (ctype.getName())
Expand Down
10 changes: 5 additions & 5 deletions type_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def __init__(self, cTypeDict):
def GenerateJsonTypeParser(self, file, ctype):
print "generating parser for %s" %ctype.getName()
start = """
bool %s::JsonParse(const rapidjson::Value &parent) {
bool %s::JsonParse(const contrail_rapidjson::Value &parent) {
for (Value::ConstMemberIterator itr = parent.MemberBegin();
itr != parent.MemberEnd(); ++itr) {
""" % ctype.getName()
file.write(start)
if len(ctype.getDataMembers()) > 0:
file.write(
' const rapidjson::Value &value_node = itr->value;\n')
' const contrail_rapidjson::Value &value_node = itr->value;\n')
file.write(' if (value_node.IsNull()) continue;\n')
file.write(' std::string var;\n')
file.write(' if (!autogen::ParseString(itr->name, &var)) return false;\n')
Expand Down Expand Up @@ -87,7 +87,7 @@ def GenerateJsonTypeParser(self, file, ctype):
file.write(' }\n return true;\n}\n')

static_fn = """
bool %s::JsonParseProperty(const rapidjson::Value &parent,
bool %s::JsonParseProperty(const contrail_rapidjson::Value &parent,
auto_ptr<AutogenProperty> *resultp) {
%s *ptr = new %s();
resultp->reset(ptr);
Expand Down Expand Up @@ -359,14 +359,14 @@ def GenerateAttributeParser(self, file, ctype):
def GenerateJsonAttributeParser(self, file, ctype):
print "generating json parser for attribute %s" %ctype.getName()
function_def = """
bool %s::JsonParse(const rapidjson::Value &parent) {
bool %s::JsonParse(const contrail_rapidjson::Value &parent) {
return true;
}
""" % ctype.getName()
file.write(function_def)

static_fn = """
bool %s::JsonParseProperty(const rapidjson::Value &parent,
bool %s::JsonParseProperty(const contrail_rapidjson::Value &parent,
auto_ptr<AutogenProperty> *resultp) {
return true;
}
Expand Down

0 comments on commit 08bfd5e

Please sign in to comment.