-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rapidjson parity #205
Merged
Merged
Rapidjson parity #205
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
131eabe
initial
ccaraman a6c4233
two
ccaraman a96e8b8
building!
ccaraman 0934352
cleanish
ccaraman 0304a73
fix headers
ccaraman d5f629a
clean
ccaraman 7759382
destructor
ccaraman dd52b40
fmt format
ccaraman 9d21f6a
documentation
ccaraman 4e43247
reference
ccaraman 25ed966
shared ptr
ccaraman 84f0976
address prr
ccaraman 9065001
comments
ccaraman ba21f10
push
ccaraman c93eca2
finally
ccaraman 424f6db
merge
ccaraman 64bf2db
one more
ccaraman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#pragma once | ||
|
||
#include "envoy/common/exception.h" | ||
#include "envoy/common/pure.h" | ||
|
||
namespace Json { | ||
class Object; | ||
|
||
typedef std::unique_ptr<Object> ObjectPtr; | ||
|
||
// @return false if immediate exit from iteration required. | ||
typedef std::function<bool(const std::string&, const Object&)> ObjectCallback; | ||
|
||
/** | ||
* Exception thrown when a JSON error occurs. | ||
*/ | ||
class Exception : public EnvoyException { | ||
public: | ||
Exception(const std::string& message) : EnvoyException(message) {} | ||
}; | ||
|
||
/** | ||
* Wraps an individual JSON node. | ||
*/ | ||
class Object { | ||
public: | ||
virtual ~Object() {} | ||
|
||
/** | ||
* Convert a generic object into an array of objects. This is useful for dealing | ||
* with arrays of arrays. | ||
* @return std::vector<ObjectPtr> the converted object. | ||
*/ | ||
virtual std::vector<ObjectPtr> asObjectArray() const PURE; | ||
|
||
/** | ||
* Get a boolean value by name. | ||
* @param name supplies the key name. | ||
* @return bool the value. | ||
*/ | ||
virtual bool getBoolean(const std::string& name) const PURE; | ||
|
||
/** | ||
* Get a boolean value by name. | ||
* @param name supplies the key name. | ||
* @param default_value supplies the value to return if the name does not exist. | ||
* @return bool the value. | ||
*/ | ||
virtual bool getBoolean(const std::string& name, bool default_value) const PURE; | ||
|
||
/** | ||
* Get an integer value by name. | ||
* @param name supplies the key name. | ||
* @return int64_t the value. | ||
*/ | ||
virtual int64_t getInteger(const std::string& name) const PURE; | ||
|
||
/** | ||
* Get an integer value by name or return a default if name does not exist. | ||
* @param name supplies the key name. | ||
* @param default_value supplies the value to return if name does not exist. | ||
* @return int64_t the value. | ||
*/ | ||
virtual int64_t getInteger(const std::string& name, int64_t default_value) const PURE; | ||
|
||
/** | ||
* Get a sub-object by name. | ||
* @param name supplies the key name. | ||
* @param allow_empty supplies whether to return an empty object if the key does not | ||
* exist. | ||
* @return ObjectObjectPtr the sub-object. | ||
*/ | ||
virtual ObjectPtr getObject(const std::string& name, bool allow_empty = false) const PURE; | ||
|
||
/** | ||
* Get an array by name. | ||
* @param name supplies the key name. | ||
* @return std::vector<ObjectPtr> the array of JSON objects. | ||
*/ | ||
virtual std::vector<ObjectPtr> getObjectArray(const std::string& name) const PURE; | ||
|
||
/** | ||
* Get a string value by name. | ||
* @param name supplies the key name. | ||
* @return std::string the value. | ||
*/ | ||
virtual std::string getString(const std::string& name) const PURE; | ||
|
||
/** | ||
* Get a string value by name or return a default if name does not exist. | ||
* @param name supplies the key name. | ||
* @param default_value supplies the value to return if name does not exist. | ||
* @return std::string the value. | ||
*/ | ||
virtual std::string getString(const std::string& name, | ||
const std::string& default_value) const PURE; | ||
|
||
/** | ||
* Get a string array by name. | ||
* @param name supplies the key name. | ||
* @return std::vector<std::string> the array of strings. | ||
*/ | ||
virtual std::vector<std::string> getStringArray(const std::string& name) const PURE; | ||
|
||
/** | ||
* Get a double value by name. | ||
* @param name supplies the key name. | ||
* @return double the value. | ||
*/ | ||
virtual double getDouble(const std::string& name) const PURE; | ||
|
||
/** | ||
* Get a double value by name. | ||
* @param name supplies the key name. | ||
* @param default_value supplies the value to return if name does not exist. | ||
* @return double the value. | ||
*/ | ||
virtual double getDouble(const std::string& name, double default_value) const PURE; | ||
|
||
/** | ||
* Iterate over key-value pairs in an Object and call callback on each pair. | ||
*/ | ||
virtual void iterate(const ObjectCallback& callback) const PURE; | ||
|
||
/** | ||
* @return TRUE if the Object contains the key. | ||
* @param name supplies the key name to lookup. | ||
*/ | ||
virtual bool hasObject(const std::string& name) const PURE; | ||
}; | ||
|
||
} // Json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove everything related to jansson with the pr for Jira 615