diff --git a/TODO b/TODO index 7940841..140b7e4 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ TODO ==== -* Replace boost::lexical_cast with something else, so that last.json does not depend on Boost when C++11 libraries are available. * Serialising a lastjson::value to a stream uses the std::dec manipulator on the stream and therefore has a side effect on the stream. This should be avoided. * Add test cases - specifically destructive test cases, where lastjson must throw correctly. diff --git a/include/lastjson/parse.hpp b/include/lastjson/parse.hpp index 0a78fbe..404f178 100644 --- a/include/lastjson/parse.hpp +++ b/include/lastjson/parse.hpp @@ -23,7 +23,13 @@ THE SOFTWARE. #ifndef LASTJSON_PARSER_HPP__ #define LASTJSON_PARSER_HPP__ -#include +#ifdef LASTJSON_CXX11 +# include +#else +# include +# define stoll(x) boost::lexical_cast(x) +# define stod(x) boost::lexical_cast(x) +#endif #include "value.hpp" #include "stringrep.hpp" @@ -285,7 +291,7 @@ inline value parse_fragment(std::string::iterator & it, std::string::iterator en } } - return value(sign * boost::lexical_cast(std::string(digits_begin, it))); + return value(sign * stod(std::string(digits_begin, it))); } else { @@ -294,7 +300,7 @@ inline value parse_fragment(std::string::iterator & it, std::string::iterator en throw parser_error("invalid json data"); } - return value(sign * boost::lexical_cast(std::string(digits_begin, it))); + return value(sign * stoll(std::string(digits_begin, it))); } } default: