diff options
-rw-r--r-- | libjsonpp/jsonFlexLexer.cpp | 4 | ||||
-rw-r--r-- | libjsonpp/jsonpp.h | 4 | ||||
-rw-r--r-- | libjsonpp/parse.cpp | 2 | ||||
-rw-r--r-- | libjsonpp/serialize.cpp | 6 | ||||
-rw-r--r-- | libjsonpp/testEncoding.cpp | 2 | ||||
-rw-r--r-- | libjsonpp/testParse.cpp | 72 |
6 files changed, 45 insertions, 45 deletions
diff --git a/libjsonpp/jsonFlexLexer.cpp b/libjsonpp/jsonFlexLexer.cpp index 323e3ed..b761eb1 100644 --- a/libjsonpp/jsonFlexLexer.cpp +++ b/libjsonpp/jsonFlexLexer.cpp @@ -21,7 +21,7 @@ namespace json { void jsonFlexLexer::BeginObject() { - auto object = boost::get<Object>(acceptValues.top()(Object())); + auto object = std::get_if<Object>(acceptValues.top()(Object())); acceptValues.push([object,this](const auto & value) { return object->insert_or_assign(name, std::make_shared<Value>(value)).first->second.get(); }); @@ -30,7 +30,7 @@ namespace json { void jsonFlexLexer::BeginArray() { - auto array = boost::get<Array>(acceptValues.top()(Array())); + auto array = std::get_if<Array>(acceptValues.top()(Array())); acceptValues.push([array](const auto & value) { return array->emplace_back(std::make_shared<Value>(value)).get(); }); diff --git a/libjsonpp/jsonpp.h b/libjsonpp/jsonpp.h index 5845ec4..7e5a393 100644 --- a/libjsonpp/jsonpp.h +++ b/libjsonpp/jsonpp.h @@ -3,7 +3,7 @@ #include <glibmm/ustring.h> #include <memory> -#include <boost/variant.hpp> +#include <variant> #include <map> #include <list> #include <stdexcept> @@ -23,7 +23,7 @@ namespace json { typedef std::shared_ptr<Value> ValuePtr; typedef std::map<std::string, ValuePtr> Object; typedef std::list<ValuePtr> Array; - typedef boost::variant<Null, String, Number, Object, Array, Boolean> VT; + typedef std::variant<Null, String, Number, Object, Array, Boolean> VT; class Value : public VT { public: Value() : VT(Null()) { } diff --git a/libjsonpp/parse.cpp b/libjsonpp/parse.cpp index 3c5189b..5dca4e8 100644 --- a/libjsonpp/parse.cpp +++ b/libjsonpp/parse.cpp @@ -24,7 +24,7 @@ namespace json { } Object parseObject(const Glib::ustring & s) { - return boost::get<Object>(parseValue(s)); + return std::get<Object>(parseValue(s)); } Value parseValue(Glib::ustring::const_iterator & s) { diff --git a/libjsonpp/serialize.cpp b/libjsonpp/serialize.cpp index 7c5cd06..e0d24eb 100644 --- a/libjsonpp/serialize.cpp +++ b/libjsonpp/serialize.cpp @@ -7,7 +7,7 @@ namespace json { const std::string null("null"); const std::string utf8("utf-8"); - class JsonSerialize : public boost::static_visitor<> { + class JsonSerialize { public: JsonSerialize(std::ostream & out, const std::string & encoding) : s(out), @@ -17,8 +17,8 @@ namespace json { << std::setfill('0') // for String \uNNNN ; } - void operator()(const Value & v) const { - boost::apply_visitor(*this, v); + void operator()(const VT & v) const { + std::visit(*this, v); } void operator()(const std::string & str) const { (*this)(str, e); diff --git a/libjsonpp/testEncoding.cpp b/libjsonpp/testEncoding.cpp index a983bdf..f13afb7 100644 --- a/libjsonpp/testEncoding.cpp +++ b/libjsonpp/testEncoding.cpp @@ -22,7 +22,7 @@ BOOST_AUTO_TEST_CASE( parse_latin1 ) { std::stringstream ss("\"A \xD9\xF1\xEE\xE7\xF4\xD0\xE8 string.\""); BOOST_REQUIRE_EQUAL(19, ss.str().length()); - BOOST_REQUIRE_EQUAL("A ÙñîçôÐè string.", boost::get<Glib::ustring>(json::parseValue(ss, "latin1"))); + BOOST_REQUIRE_EQUAL("A ÙñîçôÐè string.", std::get<Glib::ustring>(json::parseValue(ss, "latin1"))); } BOOST_AUTO_TEST_CASE( write_latin1 ) diff --git a/libjsonpp/testParse.cpp b/libjsonpp/testParse.cpp index 30cf85e..aa086e9 100644 --- a/libjsonpp/testParse.cpp +++ b/libjsonpp/testParse.cpp @@ -12,13 +12,13 @@ const boost::filesystem::path root(XSTR(ROOT)); BOOST_AUTO_TEST_CASE( parse_bool_true ) { const Glib::ustring val(" true "); - BOOST_REQUIRE_EQUAL(true, boost::get<bool>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL(true, std::get<bool>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_bool_false ) { const Glib::ustring val(" false "); - BOOST_REQUIRE_EQUAL(false, boost::get<bool>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL(false, std::get<bool>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_invalid_value ) @@ -30,69 +30,69 @@ BOOST_AUTO_TEST_CASE( parse_invalid_value ) BOOST_AUTO_TEST_CASE( parse_int_1 ) { const Glib::ustring val(" 1 "); - BOOST_REQUIRE_EQUAL(1, boost::get<json::Number>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL(1, std::get<json::Number>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_int_neg48 ) { const Glib::ustring val(" -48 "); - BOOST_REQUIRE_EQUAL(-48, boost::get<json::Number>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL(-48, std::get<json::Number>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_int_48 ) { const Glib::ustring val(" 48 "); - BOOST_REQUIRE_EQUAL(48, boost::get<json::Number>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL(48, std::get<json::Number>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_float_pi ) { const Glib::ustring val(" 3.14159265359 "); - BOOST_REQUIRE_CLOSE(3.14159, boost::get<json::Number>(json::parseValue(val)), 0.001); + BOOST_REQUIRE_CLOSE(3.14159, std::get<json::Number>(json::parseValue(val)), 0.001); } BOOST_AUTO_TEST_CASE( parse_array ) { const Glib::ustring val(" [ 1, 2, 3, [ 4, 5 ], {\"val1\": 6, \"val2\": [7, 8]}, 9, 10 ] "); - auto arr = boost::get<json::Array>(json::parseValue(val)); + auto arr = std::get<json::Array>(json::parseValue(val)); BOOST_REQUIRE_EQUAL(7, arr.size()); auto itr = arr.begin(); - BOOST_REQUIRE_EQUAL(1, boost::get<json::Number>(**itr++)); - BOOST_REQUIRE_EQUAL(2, boost::get<json::Number>(**itr++)); - BOOST_REQUIRE_EQUAL(3, boost::get<json::Number>(**itr++)); - boost::get<json::Array>(**itr++); - boost::get<json::Object>(**itr++); - BOOST_REQUIRE_EQUAL(9, boost::get<json::Number>(**itr++)); - BOOST_REQUIRE_EQUAL(10, boost::get<json::Number>(**itr++)); + BOOST_REQUIRE_EQUAL(1, std::get<json::Number>(**itr++)); + BOOST_REQUIRE_EQUAL(2, std::get<json::Number>(**itr++)); + BOOST_REQUIRE_EQUAL(3, std::get<json::Number>(**itr++)); + std::get<json::Array>(**itr++); + std::get<json::Object>(**itr++); + BOOST_REQUIRE_EQUAL(9, std::get<json::Number>(**itr++)); + BOOST_REQUIRE_EQUAL(10, std::get<json::Number>(**itr++)); } BOOST_AUTO_TEST_CASE( parse_array_of_strings ) { const Glib::ustring val(" [ \"en\", \"de\", \"ro\", \"es\", \"fa\" ] "); - boost::get<json::Array>(json::parseValue(val)); + std::get<json::Array>(json::parseValue(val)); } BOOST_AUTO_TEST_CASE( parse_null ) { const Glib::ustring val(" null "); - boost::get<json::Null>(json::parseValue(val)); + std::get<json::Null>(json::parseValue(val)); } BOOST_AUTO_TEST_CASE( parse_empty_array ) { const Glib::ustring val(" [ ] "); - BOOST_REQUIRE(boost::get<json::Array>(json::parseValue(val)).empty()); + BOOST_REQUIRE(std::get<json::Array>(json::parseValue(val)).empty()); } BOOST_AUTO_TEST_CASE( parse_empty_arrary_in_object ) { const Glib::ustring val(" { \"v1\": [ ], \"v2\": 100 } "); auto value = json::parseValue(val); - BOOST_REQUIRE_EQUAL(3, value.which()); - auto obj = boost::get<json::Object>(value); + BOOST_REQUIRE_EQUAL(3, value.index()); + auto obj = std::get<json::Object>(value); BOOST_REQUIRE_EQUAL(2, obj.size()); - BOOST_REQUIRE(boost::get<json::Array>(*obj["v1"]).empty()); - BOOST_REQUIRE_EQUAL(100, boost::get<json::Number>(*obj["v2"])); + BOOST_REQUIRE(std::get<json::Array>(*obj["v1"]).empty()); + BOOST_REQUIRE_EQUAL(100, std::get<json::Number>(*obj["v2"])); } BOOST_AUTO_TEST_CASE( parse_broken_array ) @@ -111,27 +111,27 @@ BOOST_AUTO_TEST_CASE( parse_object ) { const Glib::ustring val(" { \"a\": 1, \"b\": 2 } "); auto value = json::parseValue(val); - BOOST_REQUIRE_EQUAL(3, value.which()); - auto obj = boost::get<json::Object>(value); + BOOST_REQUIRE_EQUAL(3, value.index()); + auto obj = std::get<json::Object>(value); BOOST_REQUIRE_EQUAL(2, obj.size()); - BOOST_REQUIRE_EQUAL(1, boost::get<json::Number>(*obj["a"])); - BOOST_REQUIRE_EQUAL(2, boost::get<json::Number>(*obj["b"])); + BOOST_REQUIRE_EQUAL(1, std::get<json::Number>(*obj["a"])); + BOOST_REQUIRE_EQUAL(2, std::get<json::Number>(*obj["b"])); } BOOST_AUTO_TEST_CASE( parse_string_simple ) { const Glib::ustring val(" \"simple string\" "); - BOOST_REQUIRE_EQUAL("simple string", boost::get<json::String>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL("simple string", std::get<json::String>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_object_withStringContainingQuote ) { const Glib::ustring val(" { \"key1\": \"value1\", \"key2\": \"value\\\"2\\\"\", \"key3\": 3 } "); - auto obj = boost::get<json::Object>(json::parseValue(val)); + auto obj = std::get<json::Object>(json::parseValue(val)); BOOST_REQUIRE_EQUAL(3, obj.size()); - BOOST_REQUIRE_EQUAL("value1", boost::get<json::String>(*obj["key1"])); - BOOST_REQUIRE_EQUAL("value\"2\"", boost::get<json::String>(*obj["key2"])); - BOOST_REQUIRE_EQUAL(3, boost::get<json::Number>(*obj["key3"])); + BOOST_REQUIRE_EQUAL("value1", std::get<json::String>(*obj["key1"])); + BOOST_REQUIRE_EQUAL("value\"2\"", std::get<json::String>(*obj["key2"])); + BOOST_REQUIRE_EQUAL(3, std::get<json::Number>(*obj["key3"])); } BOOST_AUTO_TEST_CASE( parse_string_invalid_missingOpeningQuote ) @@ -143,25 +143,25 @@ BOOST_AUTO_TEST_CASE( parse_string_invalid_missingOpeningQuote ) BOOST_AUTO_TEST_CASE( parse_string_escapedQuote ) { const Glib::ustring val(" \"A \\\"quoted\\\" string.\" "); - BOOST_REQUIRE_EQUAL("A \"quoted\" string.", boost::get<json::String>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL("A \"quoted\" string.", std::get<json::String>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_string_escapedWhitespace ) { const Glib::ustring val(" \"A whitespace\\t\\r\\n\\b\\f string.\" "); - BOOST_REQUIRE_EQUAL("A whitespace\t\r\n\b\f string.", boost::get<json::String>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL("A whitespace\t\r\n\b\f string.", std::get<json::String>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_string_escapedSlashes ) { const Glib::ustring val(" \"A whitespace\\\\ \\/ string.\" "); - BOOST_REQUIRE_EQUAL("A whitespace\\ / string.", boost::get<json::String>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL("A whitespace\\ / string.", std::get<json::String>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_string_literalUnicode ) { const Glib::ustring val(" \"A Űņĩćőđē string.\" "); - BOOST_REQUIRE_EQUAL("A Űņĩćőđē string.", boost::get<json::String>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL("A Űņĩćőđē string.", std::get<json::String>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_string_unknownEscape ) @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE( parse_string_shortUnicodeEscape ) BOOST_AUTO_TEST_CASE( parse_string_escapedUnicode ) { const Glib::ustring val(" \"A \\u0170\\u0146\\u0129\\u0107\\u0151\\u0111\\u0113 string.\" "); - BOOST_REQUIRE_EQUAL("A Űņĩćőđē string.", boost::get<json::String>(json::parseValue(val))); + BOOST_REQUIRE_EQUAL("A Űņĩćőđē string.", std::get<json::String>(json::parseValue(val))); } BOOST_AUTO_TEST_CASE( parse_sample_complexFile1 ) @@ -198,6 +198,6 @@ BOOST_AUTO_TEST_CASE( parse_from_itr ) { const Glib::ustring val(" \"A \\u0170\\u0146\\u0129\\u0107\\u0151\\u0111\\u0113 string.\" "); auto itr = val.begin(); - BOOST_REQUIRE_EQUAL("A Űņĩćőđē string.", boost::get<json::String>(json::parseValue(itr))); + BOOST_REQUIRE_EQUAL("A Űņĩćőđē string.", std::get<json::String>(json::parseValue(itr))); } |