diff options
-rw-r--r-- | libjsonpp/json.ll | 4 | ||||
-rw-r--r-- | libjsonpp/jsonFlexLexer.cpp | 33 | ||||
-rw-r--r-- | libjsonpp/jsonFlexLexer.h | 8 |
3 files changed, 11 insertions, 34 deletions
diff --git a/libjsonpp/json.ll b/libjsonpp/json.ll index 860b98c..6cf6302 100644 --- a/libjsonpp/json.ll +++ b/libjsonpp/json.ll @@ -157,6 +157,8 @@ json::jsonFlexLexer::jsonFlexLexer(std::istream & in, const std::string & enc) : encoding(enc) { yy_push_state(VALUE); - acceptValues.push(boost::bind(&jsonFlexLexer::RootValue, this, _1)); + acceptValues.push([this](const auto & value) { + return values.emplace(std::make_shared<Value>(value)).get(); + }); } diff --git a/libjsonpp/jsonFlexLexer.cpp b/libjsonpp/jsonFlexLexer.cpp index ec924c4..323e3ed 100644 --- a/libjsonpp/jsonFlexLexer.cpp +++ b/libjsonpp/jsonFlexLexer.cpp @@ -1,6 +1,5 @@ #include <FlexLexer.h> #include "jsonFlexLexer.h" -#include <boost/bind.hpp> #include <glibmm/convert.h> namespace json { @@ -10,30 +9,6 @@ namespace json { return values.top(); } - Value * - jsonFlexLexer::RootValue(const Value & value) - { - auto v = ValuePtr(new Value(value)); - values.push(v); - return v.get(); - } - - Value * - jsonFlexLexer::ArrayAppend(Array * array, const Value & value) - { - auto v = ValuePtr(new Value(value)); - array->push_back(v); - return v.get(); - } - - Value * - jsonFlexLexer::ObjectMember(Object * object, const Value & value) - { - auto v = ValuePtr(new Value(value)); - (*object)[name] = v; - return v.get(); - } - std::string jsonFlexLexer::encodeBuf() const { @@ -47,14 +22,18 @@ namespace json { jsonFlexLexer::BeginObject() { auto object = boost::get<Object>(acceptValues.top()(Object())); - acceptValues.push(boost::bind(&jsonFlexLexer::ObjectMember, this, object, _1)); + acceptValues.push([object,this](const auto & value) { + return object->insert_or_assign(name, std::make_shared<Value>(value)).first->second.get(); + }); } void jsonFlexLexer::BeginArray() { auto array = boost::get<Array>(acceptValues.top()(Array())); - acceptValues.push(boost::bind(&jsonFlexLexer::ArrayAppend, this, array, _1)); + acceptValues.push([array](const auto & value) { + return array->emplace_back(std::make_shared<Value>(value)).get(); + }); } void diff --git a/libjsonpp/jsonFlexLexer.h b/libjsonpp/jsonFlexLexer.h index e3be204..6ea1336 100644 --- a/libjsonpp/jsonFlexLexer.h +++ b/libjsonpp/jsonFlexLexer.h @@ -4,7 +4,7 @@ #include <string> #include "jsonpp.h" #include <stack> -#include <boost/function.hpp> +#include <functional> namespace json { class jsonFlexLexer : public yyFlexLexer { @@ -26,16 +26,12 @@ namespace json { void PushObject(); private: - Value * RootValue(const Value &); - Value * ArrayAppend(Array *, const Value &); - Value * ObjectMember(Object *, const Value &); - std::string encodeBuf() const; std::string buf, name, encoding; std::stack<ValuePtr> values; - typedef boost::function<Value *(const Value &)> AcceptValue; + typedef std::function<Value *(const Value &)> AcceptValue; std::stack<AcceptValue> acceptValues; }; } |