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)
165 static const LargestInt minLargestInt;
179 #if defined(JSON_HAS_INT64)
180 static const Int64 minInt64;
186 #endif // defined(JSON_HAS_INT64)
189 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
192 enum DuplicationPolicy {
197 CZString(ArrayIndex index);
198 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
199 CZString(CZString
const& other);
201 CZString& operator=(CZString other);
202 bool operator<(CZString
const& other)
const;
203 bool operator==(CZString
const& other)
const;
204 ArrayIndex index()
const;
206 char const* data()
const;
207 unsigned length()
const;
208 bool isStaticString()
const;
211 void swap(CZString& other);
213 struct StringStorage {
214 DuplicationPolicy policy_: 2;
215 unsigned length_: 30;
221 StringStorage storage_;
226 #ifndef JSON_USE_CPPTL_SMALLMAP
227 typedef std::map<CZString, Value> ObjectValues;
229 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
230 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
231 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
252 #if defined(JSON_HAS_INT64)
255 #endif // if defined(JSON_HAS_INT64)
257 Value(
const char* value);
258 Value(
const char* beginValue,
const char* endValue);
275 Value(
const std::string& value);
276 #ifdef JSON_USE_CPPTL
277 Value(
const CppTL::ConstString& value);
288 void swap(
Value& other);
290 void swapPayload(
Value& other);
295 bool operator<(
const Value& other)
const;
296 bool operator<=(
const Value& other)
const;
297 bool operator>=(
const Value& other)
const;
298 bool operator>(
const Value& other)
const;
299 bool operator==(
const Value& other)
const;
300 bool operator!=(
const Value& other)
const;
301 int compare(
const Value& other)
const;
303 const char* asCString()
const;
304 std::string asString()
const;
309 char const** str,
char const** end)
const;
310 #ifdef JSON_USE_CPPTL
311 CppTL::ConstString asConstString()
const;
315 #if defined(JSON_HAS_INT64)
316 Int64 asInt64()
const;
317 UInt64 asUInt64()
const;
318 #endif // if defined(JSON_HAS_INT64)
319 LargestInt asLargestInt()
const;
320 LargestUInt asLargestUInt()
const;
321 float asFloat()
const;
322 double asDouble()
const;
328 bool isInt64()
const;
330 bool isUInt64()
const;
331 bool isIntegral()
const;
332 bool isDouble()
const;
333 bool isNumeric()
const;
334 bool isString()
const;
335 bool isArray()
const;
336 bool isObject()
const;
338 bool isConvertibleTo(
ValueType other)
const;
341 ArrayIndex size()
const;
348 bool operator!()
const;
360 void resize(ArrayIndex size);
368 Value& operator[](ArrayIndex index);
376 Value& operator[](
int index);
381 const Value& operator[](ArrayIndex index)
const;
386 const Value& operator[](
int index)
const;
391 Value get(ArrayIndex index,
const Value& defaultValue)
const;
393 bool isValidIndex(ArrayIndex index)
const;
402 Value& operator[](
const char* key);
405 const Value& operator[](
const char* key)
const;
408 Value& operator[](
const std::string& key);
412 const Value& operator[](
const std::string& key)
const;
426 #ifdef JSON_USE_CPPTL
427 Value& operator[](
const CppTL::ConstString& key);
431 const Value& operator[](
const CppTL::ConstString& key)
const;
433 Value get(
const char* key,
const Value& defaultValue)
const;
439 Value get(
const char* key,
const char* end,
const Value& defaultValue)
const;
443 Value get(
const std::string& key,
const Value& defaultValue)
const;
444 #ifdef JSON_USE_CPPTL
445 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
449 Value const* find(
char const* key,
char const* end)
const;
456 Value const* demand(
char const* key,
char const* end);
464 Value removeMember(
const char* key);
468 Value removeMember(
const std::string& key);
471 bool removeMember(
const char* key,
Value* removed);
478 bool removeMember(std::string
const& key,
Value* removed);
480 bool removeMember(
const char* key,
const char* end,
Value* removed);
487 bool removeIndex(ArrayIndex i,
Value* removed);
491 bool isMember(
const char* key)
const;
494 bool isMember(
const std::string& key)
const;
496 bool isMember(
const char* key,
const char* end)
const;
497 #ifdef JSON_USE_CPPTL
498 bool isMember(
const CppTL::ConstString& key)
const;
507 Members getMemberNames()
const;
517 void setComment(
const char* comment,
size_t len,
CommentPlacement placement);
524 std::string toStyledString()
const;
526 const_iterator begin()
const;
527 const_iterator end()
const;
534 void setOffsetStart(
size_t start);
535 void setOffsetLimit(
size_t limit);
536 size_t getOffsetStart()
const;
537 size_t getOffsetLimit()
const;
540 void initBasic(
ValueType type,
bool allocated =
false);
542 Value& resolveReference(
const char* key);
543 Value& resolveReference(
const char* key,
const char* end);
549 void setComment(
const char* text,
size_t len);
572 unsigned int allocated_ : 1;
574 CommentInfo* comments_;
618 Path(
const std::string& path,
625 const Value& resolve(
const Value& root)
const;
632 typedef std::vector<const PathArgument*> InArgs;
633 typedef std::vector<PathArgument> Args;
635 void makePath(
const std::string& path,
const InArgs& in);
636 void addPathInArg(
const std::string& path,
638 InArgs::const_iterator& itInArg,
639 PathArgument::Kind kind);
640 void invalidPath(
const std::string& path,
int location);
658 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
660 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
662 difference_type
operator-(
const SelfType& other)
const {
676 std::string name()
const;
682 char const* memberName() const;
686 char const* memberName(
char const** end) const;
689 Value& deref() const;
695 difference_type computeDistance(const SelfType& other) const;
697 bool isEqual(const SelfType& other) const;
699 void copy(const SelfType& other);
702 Value::ObjectValues::iterator current_;
728 SelfType& operator=(
const ValueIteratorBase& other);
731 SelfType temp(*
this);
737 SelfType temp(*
this);
777 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
779 SelfType& operator=(
const SelfType& other);
782 SelfType temp(*
this);
788 SelfType temp(*
this);
818 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
820 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
822 #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.
static const Value & null
We regret this reference to a global instance; prefer the simpler 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
just a kludge for binary-compatibility; same as null
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.