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) 179 #if !defined(__ARMEL__) 180 static const Value null;
183 static const LargestInt minLargestInt;
197 #if defined(JSON_HAS_INT64) 198 static const Int64 minInt64;
204 #endif // defined(JSON_HAS_INT64) 207 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 210 enum DuplicationPolicy {
215 CZString(ArrayIndex index);
216 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
217 CZString(CZString
const& other);
219 CZString& operator=(CZString other);
220 bool operator<(CZString
const& other)
const;
221 bool operator==(CZString
const& other)
const;
222 ArrayIndex index()
const;
224 char const* data()
const;
225 unsigned length()
const;
226 bool isStaticString()
const;
229 void swap(CZString& other);
231 struct StringStorage {
233 unsigned length_: 30;
239 StringStorage storage_;
244 #ifndef JSON_USE_CPPTL_SMALLMAP 245 typedef std::map<CZString, Value> ObjectValues;
247 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
248 #endif // ifndef JSON_USE_CPPTL_SMALLMAP 249 #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 270 #if defined(JSON_HAS_INT64) 273 #endif // if defined(JSON_HAS_INT64) 275 Value(
const char* value);
276 Value(
const char* begin,
const char* end);
293 Value(
const std::string& value);
294 #ifdef JSON_USE_CPPTL 295 Value(
const CppTL::ConstString& value);
306 void swap(
Value& other);
308 void swapPayload(
Value& other);
313 bool operator<(
const Value& other)
const;
314 bool operator<=(
const Value& other)
const;
315 bool operator>=(
const Value& other)
const;
316 bool operator>(
const Value& other)
const;
317 bool operator==(
const Value& other)
const;
318 bool operator!=(
const Value& other)
const;
319 int compare(
const Value& other)
const;
321 const char* asCString()
const;
322 std::string asString()
const;
327 char const** begin,
char const** end)
const;
328 #ifdef JSON_USE_CPPTL 329 CppTL::ConstString asConstString()
const;
333 #if defined(JSON_HAS_INT64) 334 Int64 asInt64()
const;
335 UInt64 asUInt64()
const;
336 #endif // if defined(JSON_HAS_INT64) 337 LargestInt asLargestInt()
const;
338 LargestUInt asLargestUInt()
const;
339 float asFloat()
const;
340 double asDouble()
const;
346 bool isInt64()
const;
348 bool isUInt64()
const;
349 bool isIntegral()
const;
350 bool isDouble()
const;
351 bool isNumeric()
const;
352 bool isString()
const;
353 bool isArray()
const;
354 bool isObject()
const;
356 bool isConvertibleTo(
ValueType other)
const;
359 ArrayIndex size()
const;
366 bool operator!()
const;
378 void resize(ArrayIndex size);
386 Value& operator[](ArrayIndex index);
394 Value& operator[](
int index);
399 const Value& operator[](ArrayIndex index)
const;
404 const Value& operator[](
int index)
const;
409 Value get(ArrayIndex index,
const Value& defaultValue)
const;
411 bool isValidIndex(ArrayIndex index)
const;
420 Value& operator[](
const char* key);
423 const Value& operator[](
const char* key)
const;
426 Value& operator[](
const std::string& key);
430 const Value& operator[](
const std::string& key)
const;
444 #ifdef JSON_USE_CPPTL 445 Value& operator[](
const CppTL::ConstString& key);
449 const Value& operator[](
const CppTL::ConstString& key)
const;
451 Value get(
const char* key,
const Value& defaultValue)
const;
457 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
461 Value get(
const std::string& key,
const Value& defaultValue)
const;
462 #ifdef JSON_USE_CPPTL 463 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
467 Value const* find(
char const* begin,
char const* end)
const;
474 Value const* demand(
char const* begin,
char const* end);
482 Value removeMember(
const char* key);
486 Value removeMember(
const std::string& key);
489 bool removeMember(
const char* key,
Value* removed);
496 bool removeMember(std::string
const& key,
Value* removed);
498 bool removeMember(
const char* begin,
const char* end,
Value* removed);
505 bool removeIndex(ArrayIndex i,
Value* removed);
509 bool isMember(
const char* key)
const;
512 bool isMember(
const std::string& key)
const;
514 bool isMember(
const char* begin,
const char* end)
const;
515 #ifdef JSON_USE_CPPTL 516 bool isMember(
const CppTL::ConstString& key)
const;
525 Members getMemberNames()
const;
536 void setComment(
const char* comment,
size_t len,
CommentPlacement placement);
543 std::string toStyledString()
const;
545 const_iterator begin()
const;
546 const_iterator end()
const;
552 void initBasic(
ValueType type,
bool allocated =
false);
554 Value& resolveReference(
const char* key);
555 Value& resolveReference(
const char* key,
const char* end);
561 void setComment(
const char* text,
size_t len);
584 unsigned int allocated_ : 1;
586 CommentInfo* comments_;
625 Path(
const std::string& path,
632 const Value& resolve(
const Value& root)
const;
639 typedef std::vector<const PathArgument*> InArgs;
640 typedef std::vector<PathArgument> Args;
642 void makePath(
const std::string& path,
const InArgs& in);
643 void addPathInArg(
const std::string& path,
645 InArgs::const_iterator& itInArg,
646 PathArgument::Kind kind);
647 void invalidPath(
const std::string& path,
int location);
662 bool operator==(
const SelfType& other)
const {
return isEqual(other); }
664 bool operator!=(
const SelfType& other)
const {
return !isEqual(other); }
666 difference_type
operator-(
const SelfType& other)
const {
680 std::string name()
const;
686 char const* memberName()
const;
690 char const* memberName(
char const** end)
const;
693 Value& deref()
const;
699 difference_type computeDistance(
const SelfType& other)
const;
701 bool isEqual(
const SelfType& other)
const;
703 void copy(
const SelfType& other);
706 Value::ObjectValues::iterator current_;
741 SelfType temp(*
this);
747 SelfType temp(*
this);
787 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
789 SelfType& operator=(
const SelfType& other);
792 SelfType temp(*
this);
798 SelfType temp(*
this);
828 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 830 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 832 #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
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
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
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
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.