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__)
182 #if defined(JSON_HAS_INT64)
189 #endif // defined(JSON_HAS_INT64)
192 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
195 enum DuplicationPolicy {
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;
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;
321 #endif // if defined(JSON_HAS_INT64)
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;
351 bool operator!()
const;
379 Value& operator[](
int index);
389 const Value& operator[](
int 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
431 Value& operator[](
const CppTL::ConstString& key);
434 const Value& operator[](
const CppTL::ConstString& key)
const;
438 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
450 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
455 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);
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
502 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);
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);
810 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
812 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
814 #endif // CPPTL_JSON_H_INCLUDED