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)
44 virtual char const* what()
const throw();
120 operator const char*()
const {
return c_str_; }
122 const char*
c_str()
const {
return c_str_; }
170 #if defined(JSON_HAS_INT64)
173 #endif // defined(JSON_HAS_INT64)
180 static const LargestInt minLargestInt;
194 #if defined(JSON_HAS_INT64)
195 static const Int64 minInt64;
201 #endif // defined(JSON_HAS_INT64)
204 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
207 enum DuplicationPolicy {
212 CZString(ArrayIndex index);
213 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
214 CZString(CZString
const& other);
216 CZString& operator=(CZString other);
217 bool operator<(CZString
const& other)
const;
218 bool operator==(CZString
const& other)
const;
219 ArrayIndex index()
const;
221 char const* data()
const;
222 unsigned length()
const;
223 bool isStaticString()
const;
226 void swap(CZString& other);
228 struct StringStorage {
230 unsigned length_: 30;
236 StringStorage storage_;
241 #ifndef JSON_USE_CPPTL_SMALLMAP
242 typedef std::map<CZString, Value> ObjectValues;
244 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
245 #endif // ifndef JSON_USE_CPPTL_SMALLMAP
246 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
267 #if defined(JSON_HAS_INT64)
270 #endif // if defined(JSON_HAS_INT64)
272 Value(
const char* value);
273 Value(
const char* begin,
const char* end);
290 Value(
const std::string& value);
291 #ifdef JSON_USE_CPPTL
292 Value(
const CppTL::ConstString& value);
303 void swap(
Value& other);
305 void swapPayload(
Value& other);
310 bool operator<(
const Value& other)
const;
311 bool operator<=(
const Value& other)
const;
312 bool operator>=(
const Value& other)
const;
313 bool operator>(
const Value& other)
const;
314 bool operator==(
const Value& other)
const;
315 bool operator!=(
const Value& other)
const;
316 int compare(
const Value& other)
const;
318 const char* asCString()
const;
319 std::string asString()
const;
324 char const** begin,
char const** end)
const;
325 #ifdef JSON_USE_CPPTL
326 CppTL::ConstString asConstString()
const;
330 #if defined(JSON_HAS_INT64)
331 Int64 asInt64()
const;
332 UInt64 asUInt64()
const;
333 #endif // if defined(JSON_HAS_INT64)
334 LargestInt asLargestInt()
const;
335 LargestUInt asLargestUInt()
const;
336 float asFloat()
const;
337 double asDouble()
const;
343 bool isInt64()
const;
345 bool isUInt64()
const;
346 bool isIntegral()
const;
347 bool isDouble()
const;
348 bool isNumeric()
const;
349 bool isString()
const;
350 bool isArray()
const;
351 bool isObject()
const;
353 bool isConvertibleTo(
ValueType other)
const;
356 ArrayIndex size()
const;
363 bool operator!()
const;
375 void resize(ArrayIndex size);
383 Value& operator[](ArrayIndex index);
391 Value& operator[](
int index);
396 const Value& operator[](ArrayIndex index)
const;
401 const Value& operator[](
int index)
const;
406 Value get(ArrayIndex index,
const Value& defaultValue)
const;
408 bool isValidIndex(ArrayIndex index)
const;
417 Value& operator[](
const char* key);
420 const Value& operator[](
const char* key)
const;
423 Value& operator[](
const std::string& key);
427 const Value& operator[](
const std::string& key)
const;
441 #ifdef JSON_USE_CPPTL
442 Value& operator[](
const CppTL::ConstString& key);
446 const Value& operator[](
const CppTL::ConstString& key)
const;
448 Value get(
const char* key,
const Value& defaultValue)
const;
454 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
458 Value get(
const std::string& key,
const Value& defaultValue)
const;
459 #ifdef JSON_USE_CPPTL
460 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
464 Value const* find(
char const* begin,
char const* end)
const;
471 Value const* demand(
char const* begin,
char const* end);
479 Value removeMember(
const char* key);
483 Value removeMember(
const std::string& key);
486 bool removeMember(
const char* key,
Value* removed);
493 bool removeMember(std::string
const& key,
Value* removed);
495 bool removeMember(
const char* begin,
const char* end,
Value* removed);
502 bool removeIndex(ArrayIndex i,
Value* removed);
506 bool isMember(
const char* key)
const;
509 bool isMember(
const std::string& key)
const;
511 bool isMember(
const char* begin,
const char* end)
const;
512 #ifdef JSON_USE_CPPTL
513 bool isMember(
const CppTL::ConstString& key)
const;
522 Members getMemberNames()
const;
533 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
540 std::
string toStyledString() const;
542 const_iterator begin() const;
543 const_iterator end() const;
550 void setOffsetStart(
size_t start);
551 void setOffsetLimit(
size_t limit);
552 size_t getOffsetStart() const;
553 size_t getOffsetLimit() const;
556 void initBasic(
ValueType type,
bool allocated = false);
558 Value& resolveReference(const
char* key);
559 Value& resolveReference(const
char* key, const
char* end);
565 void setComment(
const char* text,
size_t len);
588 unsigned int allocated_ : 1;
590 CommentInfo* comments_;
634 Path(
const std::string& path,
641 const Value& resolve(
const Value& root)
const;
648 typedef std::vector<const PathArgument*> InArgs;
649 typedef std::vector<PathArgument> Args;
651 void makePath(
const std::string& path,
const InArgs& in);
652 void addPathInArg(
const std::string& path,
654 InArgs::const_iterator& itInArg,
655 PathArgument::Kind kind);
656 void invalidPath(
const std::string& path,
int location);
671 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
673 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
675 difference_type
operator-(
const SelfType& other)
const {
689 std::string name()
const;
695 char const* memberName() const;
699 char const* memberName(
char const** end) const;
702 Value& deref() const;
708 difference_type computeDistance(const SelfType& other) const;
710 bool isEqual(const SelfType& other) const;
712 void copy(const SelfType& other);
715 Value::ObjectValues::iterator current_;
723 explicit ValueIteratorBase(const
Value::ObjectValues::iterator& current);
747 SelfType& operator=(
const ValueIteratorBase& other);
750 SelfType temp(*
this);
756 SelfType temp(*
this);
796 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
798 SelfType& operator=(
const SelfType& other);
801 SelfType temp(*
this);
807 SelfType temp(*
this);
837 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
839 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
841 #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
Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
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
Exceptions which the user cannot easily avoid.
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
Base class for all exceptions we throw.
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.