Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 9 additions & 3 deletions include/lastjson/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ THE SOFTWARE.
#ifndef LASTJSON_PARSER_HPP__
#define LASTJSON_PARSER_HPP__

#include <boost/lexical_cast.hpp>
#ifdef LASTJSON_CXX11
# include <string>
#else
# include <boost/lexical_cast.hpp>
# define stoll(x) boost::lexical_cast<value::int_type>(x)
# define stod(x) boost::lexical_cast<value::float_type>(x)
#endif

#include "value.hpp"
#include "stringrep.hpp"
Expand Down Expand Up @@ -285,7 +291,7 @@ inline value parse_fragment(std::string::iterator & it, std::string::iterator en
}
}

return value(sign * boost::lexical_cast<value::float_type>(std::string(digits_begin, it)));
return value(sign * stod(std::string(digits_begin, it)));
}
else
{
Expand All @@ -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<value::int_type>(std::string(digits_begin, it)));
return value(sign * stoll(std::string(digits_begin, it)));
}
}
default:
Expand Down