Go to the documentation of this file.
    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) 
   18 #ifndef JSON_USE_CPPTL_SMALLMAP 
   21 #include <cpptl/smallmap.h> 
   24 #include <cpptl/forwards.h> 
   29 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 
   31 #pragma warning(disable : 4251) 
   32 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 
   40 #if JSON_USE_EXCEPTION 
  134   operator const char*() 
const { 
return c_str_; }
 
  136   const char* 
c_str()
 const { 
return c_str_; }
 
  185 #if defined(JSON_HAS_INT64) 
  188 #endif // defined(JSON_HAS_INT64) 
  203   static Value const& nullSingleton();
 
  219 #if defined(JSON_HAS_INT64) 
  220   static const Int64 minInt64;
 
  226 #endif // defined(JSON_HAS_INT64) 
  239 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 
  242     enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
 
  244     CZString(
char const* str, 
unsigned length, DuplicationPolicy allocate);
 
  245     CZString(CZString 
const& other);
 
  246     CZString(CZString&& other);
 
  248     CZString& operator=(
const CZString& other);
 
  249     CZString& operator=(CZString&& other);
 
  251     bool operator<(CZString 
const& other) 
const;
 
  255     char const* data() 
const;
 
  256     unsigned length() 
const;
 
  257     bool isStaticString() 
const;
 
  260     void swap(CZString& other);
 
  262     struct StringStorage {
 
  263       unsigned policy_ : 2;
 
  264       unsigned length_ : 30; 
 
  270       StringStorage storage_;
 
  275 #ifndef JSON_USE_CPPTL_SMALLMAP 
  276   typedef std::map<CZString, Value> ObjectValues;
 
  278   typedef CppTL::SmallMap<CZString, Value> ObjectValues;
 
  279 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 
  280 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 
  301 #if defined(JSON_HAS_INT64) 
  304 #endif // if defined(JSON_HAS_INT64) 
  306   Value(
const char* value); 
 
  307   Value(
const char* begin, 
const char* end); 
 
  325 #ifdef JSON_USE_CPPTL 
  327   Value(
const CppTL::ConstString& value);
 
  342   void swapPayload(
Value& other);
 
  345   void copy(
const Value& other);
 
  347   void copyPayload(
const Value& other);
 
  352   bool operator<(
const Value& other) 
const;
 
  353   bool operator<=(
const Value& other) 
const;
 
  354   bool operator>=(
const Value& other) 
const;
 
  355   bool operator>(
const Value& other) 
const;
 
  358   int compare(
const Value& other) 
const;
 
  360   const char* asCString() 
const; 
 
  361 #if JSONCPP_USING_SECURE_MEMORY 
  362   unsigned getCStringLength() 
const; 
 
  369   bool getString(
char const** begin, 
char const** end) 
const;
 
  370 #ifdef JSON_USE_CPPTL 
  371   CppTL::ConstString asConstString() 
const;
 
  375 #if defined(JSON_HAS_INT64) 
  376   Int64 asInt64() 
const;
 
  378 #endif // if defined(JSON_HAS_INT64) 
  381   float asFloat() 
const;
 
  382   double asDouble() 
const;
 
  388   bool isInt64() 
const;
 
  390   bool isUInt64() 
const;
 
  391   bool isIntegral() 
const;
 
  392   bool isDouble() 
const;
 
  393   bool isNumeric() 
const;
 
  394   bool isString() 
const;
 
  395   bool isArray() 
const;
 
  396   bool isObject() 
const;
 
  398   bool isConvertibleTo(
ValueType other) 
const;
 
  436   Value& operator[](
int index);
 
  446   const Value& operator[](
int index) 
const;
 
  463   Value& operator[](
const char* key);
 
  466   const Value& operator[](
const char* key) 
const;
 
  488 #ifdef JSON_USE_CPPTL 
  489   Value& operator[](
const CppTL::ConstString& key);
 
  493   const Value& operator[](
const CppTL::ConstString& key) 
const;
 
  495   Value get(
const char* key, 
const Value& defaultValue) 
const;
 
  502   get(
const char* begin, 
const char* end, 
const Value& defaultValue) 
const;
 
  507 #ifdef JSON_USE_CPPTL 
  508   Value get(
const CppTL::ConstString& key, 
const Value& defaultValue) 
const;
 
  512   Value const* find(
char const* begin, 
char const* end) 
const;
 
  519   Value* demand(
char const* begin, 
char const* end);
 
  525   void removeMember(
const char* key);
 
  528   void removeMember(
const String& key);
 
  531   bool removeMember(
const char* key, 
Value* removed);
 
  538   bool removeMember(
String const& key, 
Value* removed);
 
  540   bool removeMember(
const char* begin, 
const char* end, 
Value* removed);
 
  551   bool isMember(
const char* key) 
const;
 
  554   bool isMember(
const String& key) 
const;
 
  556   bool isMember(
const char* begin, 
const char* end) 
const;
 
  557 #ifdef JSON_USE_CPPTL 
  558   bool isMember(
const CppTL::ConstString& key) 
const;
 
  567   Members getMemberNames() 
const;
 
  577     setComment(
String(comment, strlen(comment)), placement);
 
  581     setComment(
String(comment, len), placement);
 
  589   String toStyledString() 
const;
 
  591   const_iterator begin() 
const;
 
  592   const_iterator end() 
const;
 
  599   void setOffsetStart(ptrdiff_t start);
 
  600   void setOffsetLimit(ptrdiff_t limit);
 
  601   ptrdiff_t getOffsetStart() 
const;
 
  602   ptrdiff_t getOffsetLimit() 
const;
 
  606     bits_.value_type_ = static_cast<unsigned char>(v);
 
  608   bool isAllocated()
 const { 
return bits_.allocated_; }
 
  609   void setIsAllocated(
bool v) { bits_.allocated_ = v; }
 
  611   void initBasic(
ValueType type, 
bool allocated = 
false);
 
  612   void dupPayload(
const Value& other);
 
  613   void releasePayload();
 
  614   void dupMeta(
const Value& other);
 
  616   Value& resolveReference(
const char* key);
 
  617   Value& resolveReference(
const char* key, 
const char* end);
 
  646     Comments() = 
default;
 
  647     Comments(
const Comments& that);
 
  648     Comments(Comments&& that);
 
  649     Comments& operator=(
const Comments& that);
 
  650     Comments& operator=(Comments&& that);
 
  656     using Array = std::array<String, numberOfCommentPlacement>;
 
  657     std::unique_ptr<Array> ptr_;
 
  680   enum Kind { kindNone = 0, kindIndex, kindKey };
 
  683   Kind kind_{kindNone};
 
  706   const Value& resolve(
const Value& root) 
const;
 
  713   typedef std::vector<const PathArgument*> InArgs;
 
  714   typedef std::vector<PathArgument> Args;
 
  716   void makePath(
const String& path, 
const InArgs& in);
 
  717   void addPathInArg(
const String& path,
 
  719                     InArgs::const_iterator& itInArg,
 
  720                     PathArgument::Kind kind);
 
  721   static void invalidPath(
const String& path, 
int location);
 
  762   char const* memberName() const;
 
  766   char const* memberName(
char const** end) const;
 
  769   Value& deref() const;
 
  775   difference_type computeDistance(const SelfType& other) const;
 
  777   bool isEqual(const SelfType& other) const;
 
  779   void copy(const SelfType& other);
 
  782   Value::ObjectValues::iterator current_;
 
  790   explicit ValueIteratorBase(
const Value::ObjectValues::iterator& current);
 
  865   explicit ValueIterator(
const Value::ObjectValues::iterator& current);
 
  903 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 
  905 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 
  907 #endif // CPPTL_JSON_H_INCLUDED 
  
bool operator!=(const SelfType &other) const
pointer operator->() const
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
ValueType
Type of the value held by a Value object.
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.
#define JSONCPP_OP_EXPLICIT
we set max number of significant digits in string
a comment just after a value on the same line
const iterator for object and array value.
reference operator*() const
bool operator==(const SelfType &other) const
a comment placed on the line before a value
Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
Iterator for object and array value.
bool operator==(const SecureAllocator< T > &, const SecureAllocator< U > &)
difference_type computeDistance(const SelfType &other) const
Experimental and untested: represents a "path" to access a node.
a comment on the line after a value (only make sense for
we set max number of digits after "." in string
bool operator!=(const SecureAllocator< T > &, const SecureAllocator< U > &)
array value (ordered list)
PrecisionType
Type of precision for formatting of real values.
ValueIteratorBase SelfType
ValueConstIterator SelfType
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
void swap(Value &other)
Swap everything.
Base class for all exceptions we throw.
void throwRuntimeError(String const &msg)
used internally
StaticString(const char *czstring)
Experimental and untested: represents an element of the "path" to access a node.
static const UInt defaultRealPrecision
Default precision for real value for string representation.
void throwLogicError(String const &msg)
used internally
#define JSONCPP_DEPRECATED(message)
std::bidirectional_iterator_tag iterator_category
Json::LargestInt LargestInt
void swap(Value &a, Value &b)
JSON (JavaScript Object Notation).
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion.
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
const typedef Value value_type
ValueConstIterator const_iterator
base class for Value iterators.
object value (collection of name/value pairs).
const char * c_str() const
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
static const Value & nullRef
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
Json::LargestUInt LargestUInt
Json::ArrayIndex ArrayIndex
const typedef Value & reference
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
reference operator*() const
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
const typedef Value * pointer
difference_type operator-(const SelfType &other) const
pointer operator->() const
Lightweight wrapper to tag static string.
std::vector< String > Members
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Exceptions which the user cannot easily avoid.