Skip to content

Commit

Permalink
Fix build when JSON_USE_EXCEPTION == 0 (#332)
Browse files Browse the repository at this point in the history
* Fix build when JSON_USE_EXCEPTION == 0

Signed-off-by: Nate Koenig <[email protected]>

* Use central define

Signed-off-by: Nate Koenig <[email protected]>

---------

Signed-off-by: Nate Koenig <[email protected]>
  • Loading branch information
nkoenig authored Mar 14, 2023
1 parent 8d06833 commit cb7030c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/JSONParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ using namespace fuel_tools;
#define timegm _mkgmtime
#endif

#define GZ_JSON_HAVE_EXCEPTIONS ((JSONCPP_VERSION_MAJOR < 1 && \
JSONCPP_VERSION_MINOR < 10) || JSON_USE_EXCEPTION == 0)

/////////////////////////////////////////////////
std::time_t ParseDateTime(const std::string &_datetime)
{
Expand Down Expand Up @@ -78,7 +81,7 @@ bool ParseLicenseImpl(const Json::Value &_json,
if (_json.isMember("ID"))
_license.second = _json["ID"].asUInt();
}
#if JSONCPP_VERSION_MAJOR < 1 && JSONCPP_VERSION_MINOR < 10
#if GZ_JSON_HAVE_EXCEPTIONS == 1
catch (...)
{
std::string what;
Expand Down Expand Up @@ -109,7 +112,7 @@ std::vector<std::string> JSONParser::ParseTags(const Json::Value &_json)
for (auto tagIt = _json.begin(); tagIt != _json.end(); ++tagIt)
tags.push_back(tagIt->asString());
}
#if JSONCPP_VERSION_MAJOR < 1 && JSONCPP_VERSION_MINOR < 10
#if GZ_JSON_HAVE_EXCEPTIONS == 1
catch (...)
{
std::string what;
Expand Down Expand Up @@ -221,7 +224,7 @@ bool JSONParser::ParseModelImpl(
if (_json.isMember("version"))
_model.SetVersion(_json["version"].asUInt());
}
#if JSONCPP_VERSION_MAJOR < 1 && JSONCPP_VERSION_MINOR < 10
#if GZ_JSON_HAVE_EXCEPTIONS == 1
catch (...)
{
std::string what;
Expand Down Expand Up @@ -326,7 +329,7 @@ bool JSONParser::ParseWorldImpl(
if (_json.isMember("version"))
_world.SetVersion(_json["version"].asUInt());
}
#if JSONCPP_VERSION_MAJOR < 1 && JSONCPP_VERSION_MINOR < 10
#if GZ_JSON_HAVE_EXCEPTIONS == 1
catch (...)
{
std::string what;
Expand Down

0 comments on commit cb7030c

Please sign in to comment.