6 #ifndef CPPTL_JSON_H_INCLUDED
7 #define CPPTL_JSON_H_INCLUDED
9 #if !defined(JSON_IS_AMALGAMATION)
11 #endif // if !defined(JSON_IS_AMALGAMATION)
16 #ifndef JSON_USE_CPPTL_SMALLMAP
19 #include <cpptl/smallmap.h>
22 #include <cpptl/forwards.h>
27 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
29 #pragma warning(disable : 4251)
30 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
105 operator const char*()
const {
return c_str_; }
107 const char*
c_str()
const {
return c_str_; }
155 #if defined(JSON_HAS_INT64)
158 #endif // defined(JSON_HAS_INT64)
164 #if !defined(__ARMEL__)
165 static const Value null;
168 static const LargestInt minLargestInt;
182 #if defined(JSON_HAS_INT64)
183 static const Int64 minInt64;
189 #endif // defined(JSON_HAS_INT64)
192 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
195 enum DuplicationPolicy {
200 CZString(ArrayIndex index);
201 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
202 CZString(CZString
const& other);
204 CZString& operator=(CZString other);
205 bool operator<(CZString
const& other)
const;
206 bool operator==(CZString
const& other)
const;
207 ArrayIndex index()
const;
209 char const* data()
const;
210 unsigned length()
const;
211 bool isStaticString()
const;
214 void swap(CZString& other);
216 struct StringStorage {
217 DuplicationPolicy policy_: 2;
218 unsigned length_: 30;
224 StringStorage storage_;
229 #ifndef JSON_USE_CPPTL_SMALLMAP
230 typedef std::map<CZString, Value> ObjectValues;
232 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
233 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
234 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
255 #if defined(JSON_HAS_INT64)
258 #endif // if defined(JSON_HAS_INT64)
260 Value(
const char* value);
261 Value(
const char* beginValue,
const char* endValue);
278 Value(
const std::string& value);
279 #ifdef JSON_USE_CPPTL
280 Value(
const CppTL::ConstString& value);
291 void swap(
Value& other);
293 void swapPayload(
Value& other);
298 bool operator<(
const Value& other)
const;
299 bool operator<=(
const Value& other)
const;
300 bool operator>=(
const Value& other)
const;
301 bool operator>(
const Value& other)
const;
302 bool operator==(
const Value& other)
const;
303 bool operator!=(
const Value& other)
const;
304 int compare(
const Value& other)
const;
306 const char* asCString()
const;
307 std::string asString()
const;
312 char const** str,
char const** end)
const;
313 #ifdef JSON_USE_CPPTL
314 CppTL::ConstString asConstString()
const;
318 #if defined(JSON_HAS_INT64)
319 Int64 asInt64()
const;
320 UInt64 asUInt64()
const;
321 #endif // if defined(JSON_HAS_INT64)
322 LargestInt asLargestInt()
const;
323 LargestUInt asLargestUInt()
const;
324 float asFloat()
const;
325 double asDouble()
const;
331 bool isInt64()
const;
333 bool isUInt64()
const;
334 bool isIntegral()
const;
335 bool isDouble()
const;
336 bool isNumeric()
const;
337 bool isString()
const;
338 bool isArray()
const;
339 bool isObject()
const;
341 bool isConvertibleTo(
ValueType other)
const;
344 ArrayIndex size()
const;
351 bool operator!()
const;
363 void resize(ArrayIndex size);
371 Value& operator[](ArrayIndex index);
379 Value& operator[](
int index);
384 const Value& operator[](ArrayIndex index)
const;
389 const Value& operator[](
int index)
const;
394 Value get(ArrayIndex index,
const Value& defaultValue)
const;
396 bool isValidIndex(ArrayIndex index)
const;
405 Value& operator[](
const char* key);
408 const Value& operator[](
const char* key)
const;
411 Value& operator[](
const std::string& key);
415 const Value& operator[](
const std::string& key)
const;
429 #ifdef JSON_USE_CPPTL
430 Value& operator[](
const CppTL::ConstString& key);
434 const Value& operator[](
const CppTL::ConstString& key)
const;
436 Value get(
const char* key,
const Value& defaultValue)
const;
442 Value get(
const char* key,
const char* end,
const Value& defaultValue)
const;
446 Value get(
const std::string& key,
const Value& defaultValue)
const;
447 #ifdef JSON_USE_CPPTL
448 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
452 Value const* find(
char const* key,
char const* end)
const;
459 Value const* demand(
char const* key,
char const* end);
467 Value removeMember(
const char* key);
471 Value removeMember(
const std::string& key);
474 bool removeMember(
const char* key,
Value* removed);
481 bool removeMember(std::string
const& key,
Value* removed);
483 bool removeMember(
const char* key,
const char* end,
Value* removed);
490 bool removeIndex(ArrayIndex i,
Value* removed);
494 bool isMember(
const char* key)
const;
497 bool isMember(
const std::string& key)
const;
499 bool isMember(
const char* key,
const char* end)
const;
500 #ifdef JSON_USE_CPPTL
501 bool isMember(
const CppTL::ConstString& key)
const;
510 Members getMemberNames()
const;
521 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
528 std::
string toStyledString() const;
530 const_iterator begin() const;
531 const_iterator end() const;
537 void initBasic(
ValueType type,
bool allocated = false);
539 Value& resolveReference(const
char* key);
540 Value& resolveReference(const
char* key, const
char* end);
546 void setComment(
const char* text,
size_t len);
569 unsigned int allocated_ : 1;
571 CommentInfo* comments_;
610 Path(
const std::string& path,
617 const Value& resolve(
const Value& root)
const;
624 typedef std::vector<const PathArgument*> InArgs;
625 typedef std::vector<PathArgument> Args;
627 void makePath(
const std::string& path,
const InArgs& in);
628 void addPathInArg(
const std::string& path,
630 InArgs::const_iterator& itInArg,
631 PathArgument::Kind kind);
632 void invalidPath(
const std::string& path,
int location);
650 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
652 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
654 difference_type
operator-(
const SelfType& other)
const {
668 std::string name()
const;
674 char const* memberName() const;
678 char const* memberName(
char const** end) const;
681 Value& deref() const;
687 difference_type computeDistance(const SelfType& other) const;
689 bool isEqual(const SelfType& other) const;
691 void copy(const SelfType& other);
694 Value::ObjectValues::iterator current_;
720 SelfType& operator=(
const ValueIteratorBase& other);
723 SelfType temp(*
this);
729 SelfType temp(*
this);
769 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
771 SelfType& operator=(
const SelfType& other);
774 SelfType temp(*
this);
780 SelfType temp(*
this);
810 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
812 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
814 #endif // CPPTL_JSON_H_INCLUDED
#define JSONCPP_DEPRECATED(message)
pointer operator->() const
#define JSON_API
If defined, indicates that the source file is amalgated to prevent private header inclusion...
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
reference operator*() const
std::vector< std::string > Members
base class for Value iterators.
array value (ordered list)
void throwLogicError(std::string const &msg)
used internally
Json::ArrayIndex ArrayIndex
object value (collection of name/value pairs).
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Lightweight wrapper to tag static string.
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Json::LargestUInt LargestUInt
difference_type computeDistance(const SelfType &other) const
bool operator!=(const SelfType &other) const
const iterator for object and array value.
Experimental and untested: represents an element of the "path" to access a node.
StaticString(const char *czstring)
ValueConstIterator SelfType
static const Value & nullRef
ValueConstIterator const_iterator
JSON (JavaScript Object Notation).
ValueIteratorBase SelfType
void swap(Value &other)
Swap everything.
Experimental and untested: represents a "path" to access a node.
Json::LargestInt LargestInt
const char * c_str() const
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
void throwRuntimeError(std::string const &msg)
used internally
std::bidirectional_iterator_tag iterator_category
difference_type operator-(const SelfType &other) const
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
reference operator*() const
a comment on the line after a value (only make sense for
Iterator for object and array value.
ValueType
Type of the value held by a Value object.
a comment placed on the line before a value
a comment just after a value on the same line
bool operator==(const SelfType &other) const
pointer operator->() const
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.