From: Marcin Siodelski Date: Fri, 18 Apr 2014 16:11:48 +0000 (+0200) Subject: [3408] Addressed review comments. X-Git-Tag: trac2406_cl_base~1^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c180526d996cddb812af3f52b320fa2bde54dc4b;p=thirdparty%2Fkea.git [3408] Addressed review comments. --- diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 77e4c8157d..f833230db1 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -218,19 +218,34 @@ Element::create(const long long int i, const Position& pos) { return (ElementPtr(new IntElement(static_cast(i), pos))); } +ElementPtr +Element::create(const int i, const Position& pos) { + return (create(static_cast(i), pos)); +}; + +ElementPtr +Element::create(const long int i, const Position& pos) { + return (create(static_cast(i), pos)); +}; + ElementPtr Element::create(const double d, const Position& pos) { return (ElementPtr(new DoubleElement(d, pos))); } +ElementPtr +Element::create(const bool b, const Position& pos) { + return (ElementPtr(new BoolElement(b, pos))); +} + ElementPtr Element::create(const std::string& s, const Position& pos) { return (ElementPtr(new StringElement(s, pos))); } ElementPtr -Element::create(const bool b, const Position& pos) { - return (ElementPtr(new BoolElement(b, pos))); +Element::create(const char *s, const Position& pos) { + return (create(std::string(s), pos)); } ElementPtr @@ -412,7 +427,8 @@ fromStringstreamNumber(std::istream& in, const std::string& file, return (Element::create(boost::lexical_cast(number), Element::Position(line, start_pos))); } catch (const boost::bad_lexical_cast&) { - isc_throw(JSONError, std::string("Number overflow: ") + number); + throwJSONError(std::string("Number overflow: ") + number, + file, line, start_pos); } } else { try { diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index ef741e1258..0850abfa38 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -351,16 +351,11 @@ public: static ElementPtr create(const long long int i, const Position& pos = ZERO_POSITION()); static ElementPtr create(const int i, - const Position& pos = ZERO_POSITION()) { - return (create(static_cast(i), pos)); - }; + const Position& pos = ZERO_POSITION()); static ElementPtr create(const long int i, - const Position& pos = ZERO_POSITION()) { - return (create(static_cast(i), pos)); - }; + const Position& pos = ZERO_POSITION()); static ElementPtr create(const double d, const Position& pos = ZERO_POSITION()); - static ElementPtr create(const bool b, const Position& pos = ZERO_POSITION()); static ElementPtr create(const std::string& s, @@ -368,9 +363,7 @@ public: // need both std:string and char *, since c++ will match // bool before std::string when you pass it a char * static ElementPtr create(const char *s, - const Position& pos = ZERO_POSITION()) { - return (create(std::string(s), pos)); - } + const Position& pos = ZERO_POSITION()); /// \brief Creates an empty ListElement type ElementPtr. /// @@ -474,7 +467,7 @@ public: /// (C++ tries to convert integer type values and reference/pointer /// if value types do not match exactly) /// We decided the storage as int64_t, -/// three (long long, long, int) override function defintions +/// three (long long, long, int) override function definitions /// and cast int/long/long long to int64_t via long long. /// Therefore, call by value methods (create, setValue) have three /// (int,long,long long) definitions. Others use int64_t.