diff options
author | Milo Yip <miloyip@gmail.com> | 2016-04-23 15:11:05 +0300 |
---|---|---|
committer | Milo Yip <miloyip@gmail.com> | 2016-04-23 15:11:05 +0300 |
commit | b010f388d10a61cfe2b8640ca9e88e8f0c725b7f (patch) | |
tree | f3694d691f4dc49fb8034a74a0a3bcbc66f680c9 /example | |
parent | 05b2ed7532bcaa17f0e2794a7fab67155d3e5cd3 (diff) |
Change FilterKeyHandler from struct to class
Also disable copy constructor/assignment operator
Diffstat (limited to 'example')
-rw-r--r-- | example/filterkey/filterkey.cpp | 9 | ||||
-rw-r--r-- | example/filterkeydom/filterkeydom.cpp | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/example/filterkey/filterkey.cpp b/example/filterkey/filterkey.cpp index 14163625..c34a050d 100644 --- a/example/filterkey/filterkey.cpp +++ b/example/filterkey/filterkey.cpp @@ -15,7 +15,8 @@ using namespace rapidjson; // This handler forwards event into an output handler, with filtering the descendent events of specified key. template <typename OutputHandler> -struct FilterKeyHandler { +class FilterKeyHandler { +public: typedef char Ch; FilterKeyHandler(OutputHandler& outputHandler, const Ch* keyString, SizeType keyLength) : @@ -87,12 +88,16 @@ struct FilterKeyHandler { return outputHandler_.EndArray(elementCount) && EndValue(); } +private: + FilterKeyHandler(const FilterKeyHandler&); + FilterKeyHandler& operator=(const FilterKeyHandler&); + bool EndValue() { if (filterValueDepth_ == 1) // Just at the end of value after filtered key filterValueDepth_ = 0; return true; } - + OutputHandler& outputHandler_; const char* keyString_; const SizeType keyLength_; diff --git a/example/filterkeydom/filterkeydom.cpp b/example/filterkeydom/filterkeydom.cpp index aba50bd0..cd6119f6 100644 --- a/example/filterkeydom/filterkeydom.cpp +++ b/example/filterkeydom/filterkeydom.cpp @@ -16,7 +16,8 @@ using namespace rapidjson; // This handler forwards event into an output handler, with filtering the descendent events of specified key. template <typename OutputHandler> -struct FilterKeyHandler { +class FilterKeyHandler { +public: typedef char Ch; FilterKeyHandler(OutputHandler& outputHandler, const Ch* keyString, SizeType keyLength) : @@ -88,12 +89,16 @@ struct FilterKeyHandler { return outputHandler_.EndArray(elementCount) && EndValue(); } +private: + FilterKeyHandler(const FilterKeyHandler&); + FilterKeyHandler& operator=(const FilterKeyHandler&); + bool EndValue() { if (filterValueDepth_ == 1) // Just at the end of value after filtered key filterValueDepth_ = 0; return true; } - + OutputHandler& outputHandler_; const char* keyString_; const SizeType keyLength_; @@ -122,6 +127,9 @@ public: const ParseResult& GetParseResult() const { return parseResult_; } private: + FilterKeyReader(const FilterKeyReader&); + FilterKeyReader& operator=(const FilterKeyReader&); + InputStream& is_; const char* keyString_; const SizeType keyLength_; |