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 char const* what()
const throw()
override;
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)
194 #if defined(JSON_HAS_INT64)
201 #endif // defined(JSON_HAS_INT64)
204 #ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
207 enum DuplicationPolicy {
213 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
214 CZString(CZString
const& other);
215 #if JSON_HAS_RVALUE_REFERENCES
216 CZString(CZString&& other);
219 CZString& operator=(CZString other);
220 bool operator<(CZString
const& other)
const;
221 bool operator==(CZString
const& other)
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);
300 #if JSON_HAS_RVALUE_REFERENCES
310 void swap(
Value& other);
312 void swapPayload(
Value& other);
317 bool operator<(
const Value& other)
const;
318 bool operator<=(
const Value& other)
const;
319 bool operator>=(
const Value& other)
const;
320 bool operator>(
const Value& other)
const;
321 bool operator==(
const Value& other)
const;
322 bool operator!=(
const Value& other)
const;
323 int compare(
const Value& other)
const;
325 const char* asCString()
const;
326 std::string asString()
const;
331 char const** begin,
char const** end)
const;
332 #ifdef JSON_USE_CPPTL
333 CppTL::ConstString asConstString()
const;
337 #if defined(JSON_HAS_INT64)
338 Int64 asInt64()
const;
340 #endif // if defined(JSON_HAS_INT64)
343 float asFloat()
const;
344 double asDouble()
const;
350 bool isInt64()
const;
352 bool isUInt64()
const;
353 bool isIntegral()
const;
354 bool isDouble()
const;
355 bool isNumeric()
const;
356 bool isString()
const;
357 bool isArray()
const;
358 bool isObject()
const;
360 bool isConvertibleTo(
ValueType other)
const;
370 bool operator!()
const;
398 Value& operator[](
int index);
408 const Value& operator[](
int index)
const;
424 Value& operator[](
const char* key);
427 const Value& operator[](
const char* key)
const;
430 Value& operator[](
const std::string& key);
434 const Value& operator[](
const std::string& key)
const;
448 #ifdef JSON_USE_CPPTL
450 Value& operator[](
const CppTL::ConstString& key);
453 const Value& operator[](
const CppTL::ConstString& key)
const;
457 Value get(
const char* key,
const Value& defaultValue)
const;
461 Value get(
const char* begin,
const char* end,
const Value& defaultValue)
const;
465 Value get(
const std::string& key,
const Value& defaultValue)
const;
466 #ifdef JSON_USE_CPPTL
469 Value get(
const CppTL::ConstString& key,
const Value& defaultValue)
const;
474 Value const* find(
char const* begin,
char const* end)
const;
478 Value const* demand(
char const* begin,
char const* end);
486 Value removeMember(
const char* key);
490 Value removeMember(
const std::string& key);
493 bool removeMember(
const char* key,
Value* removed);
500 bool removeMember(std::string
const& key,
Value* removed);
502 bool removeMember(
const char* begin,
const char* end,
Value* removed);
513 bool isMember(
const char* key)
const;
516 bool isMember(
const std::string& key)
const;
518 bool isMember(
const char* begin,
const char* end)
const;
519 #ifdef JSON_USE_CPPTL
521 bool isMember(
const CppTL::ConstString& key)
const;
529 Members getMemberNames()
const;
540 void setComment(const
char* comment,
size_t len,
CommentPlacement placement);
547 std::
string toStyledString() const;
549 const_iterator begin() const;
550 const_iterator end() const;
557 void setOffsetStart(
size_t start);
558 void setOffsetLimit(
size_t limit);
559 size_t getOffsetStart() const;
560 size_t getOffsetLimit() const;
563 void initBasic(
ValueType type,
bool allocated = false);
565 Value& resolveReference(const
char* key);
566 Value& resolveReference(const
char* key, const
char* end);
572 void setComment(
const char* text,
size_t len);
595 unsigned int allocated_ : 1;
597 CommentInfo* comments_;
641 Path(
const std::string& path,
648 const Value& resolve(
const Value& root)
const;
655 typedef std::vector<const PathArgument*> InArgs;
656 typedef std::vector<PathArgument> Args;
658 void makePath(
const std::string& path,
const InArgs& in);
659 void addPathInArg(
const std::string& path,
661 InArgs::const_iterator& itInArg,
662 PathArgument::Kind kind);
663 void invalidPath(
const std::string& path,
int location);
696 std::string name()
const;
702 char const* memberName() const;
706 char const* memberName(
char const** end) const;
709 Value& deref() const;
715 difference_type computeDistance(const SelfType& other) const;
717 bool isEqual(const SelfType& other) const;
719 void copy(const SelfType& other);
722 Value::ObjectValues::iterator current_;
730 explicit ValueIteratorBase(const
Value::ObjectValues::iterator& current);
755 SelfType& operator=(
const ValueIteratorBase& other);
758 SelfType temp(*
this);
764 SelfType temp(*
this);
804 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
845 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
847 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
849 #endif // CPPTL_JSON_H_INCLUDED