Lines Matching +full:a +full:- +full:string +full:- +full:with +full:- +full:nulls

1 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
14 // a) suppress false positives from static code analysis
24 // Support for '= delete' with template declarations was a late addition
46 #include <string>
49 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
69 Exception(String msg);
74 String msg_;
79 * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
85 RuntimeError(String const& msg);
90 * These are precondition-violations (user bugs) and internal errors (our bugs).
96 LogicError(String const& msg);
101 JSONCPP_NORETURN void throwRuntimeError(String const& msg);
103 JSONCPP_NORETURN void throwLogicError(String const& msg);
105 /** \brief Type of the value held by a Value object.
112 stringValue, ///< UTF-8 string value
119 commentBefore = 0, ///< a comment placed on the line before a value
120 commentAfterOnSameLine, ///< a comment just after a value on the same line
121 commentAfter, ///< a comment on the line after a value (only make sense for
129 significantDigits = 0, ///< we set max number of significant digits in string
130 decimalPlaces ///< we set max number of digits after "." in string
133 /** \brief Lightweight wrapper to tag static string.
136 * StaticString and avoid the cost of string duplication when storing the
137 * string or the member name.
159 /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
161 * This class is a discriminated union wrapper that can represents a:
162 * - signed integer [range: Value::minInt - Value::maxInt]
163 * - unsigned integer (range: 0 - Value::maxUInt)
164 * - double
165 * - UTF-8 string
166 * - boolean
167 * - 'null'
168 * - an ordered list of Value
169 * - collection of name/value pairs (javascript object)
171 * The type of the held value is represented by a #ValueType and
176 * Non-const methods will automatically create the a #nullValue element
179 * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
187 * \note #Value string-length fit in size_t, but keys must be < 2^30.
188 * (The reason is an implementation detail.) A #CharReader will raise an
189 * exception if a bound is exceeded to avoid security holes in your app,
197 using Members = std::vector<String>;
211 using value_type = std::string;
222 /// Minimum signed integer value that can be stored in a Json::Value.
224 LargestInt(~(LargestUInt(-1) / 2));
225 /// Maximum signed integer value that can be stored in a Json::Value.
226 static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
227 /// Maximum unsigned integer value that can be stored in a Json::Value.
228 static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
230 /// Minimum signed int value that can be stored in a Json::Value.
231 static constexpr Int minInt = Int(~(UInt(-1) / 2));
232 /// Maximum signed int value that can be stored in a Json::Value.
233 static constexpr Int maxInt = Int(UInt(-1) / 2);
234 /// Maximum unsigned int value that can be stored in a Json::Value.
235 static constexpr UInt maxUInt = UInt(-1);
238 /// Minimum signed 64 bits int value that can be stored in a Json::Value.
239 static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
240 /// Maximum signed 64 bits int value that can be stored in a Json::Value.
241 static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
242 /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
243 static constexpr UInt64 maxUInt64 = UInt64(-1);
245 /// Default precision for real value for string representation.
247 // The constant is hard-coded because some compiler have trouble
248 // converting Value::maxUInt64 to a double correctly (AIX/xlC).
249 // Assumes that UInt64 is a 64 bits integer.
287 char const* cstr_; // actually, a prefixed string, unless policy is noDup
300 * \brief Create a default Value of the given type.
302 * This is a very useful constructor.
323 Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
326 * \brief Constructs a value from a static string.
328 * Like other value string constructor but do not duplicate the string for
329 * internal storage. The given string must remain alive after the call to
332 * \note This works only for null-terminated strings. (We cannot change the
343 Value(const String& value);
381 String asString() const; ///< Embedded zeroes are possible.
382 /** Get raw char* of string-value.
383 * \return false if !string. (Seg-fault if str or end are NULL.)
444 /// this from the operator[] which takes a string.)
452 /// this from the operator[] which takes a string.)
472 /// Access an object value by name, create a null member if it does not exist.
473 /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
476 /// Access an object value by name, returns null if there is no member with
479 /// Access an object value by name, create a null member if it does not exist.
480 /// \param key may contain embedded nulls.
481 Value& operator[](const String& key);
482 /// Access an object value by name, returns null if there is no member with
484 /// \param key may contain embedded nulls.
485 const Value& operator[](const String& key) const;
486 /** \brief Access an object value by name, create a null member if it does not
504 /// \note key may contain embedded nulls.
509 /// \param key may contain embedded nulls.
510 Value get(const String& key, const Value& defaultValue) const;
513 /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
515 /// Most general and efficient version of object-mutators.
516 /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
517 /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
526 /// \param key may contain embedded nulls.
527 void removeMember(const String& key);
529 /// but 'key' is null-terminated.
534 * \param key may contain embedded nulls.
537 bool removeMember(String const& key, Value* removed);
538 /// Same as removeMember(String const& key, Value* removed)
548 /// Return true if the object has a member named key.
549 /// \note 'key' must be null-terminated.
551 /// Return true if the object has a member named key.
552 /// \param key may contain embedded nulls.
553 bool isMember(const String& key) const;
554 /// Same as isMember(String const& key)const
557 /// \brief Return a list of the member names.
565 JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
567 setComment(String(comment, strlen(comment)), placement); in setComment()
571 setComment(String(comment, len), placement); in setComment()
574 void setComment(String comment, CommentPlacement placement);
577 String getComment(CommentPlacement placement) const;
579 String toStyledString() const;
628 // Really a ValueType, but types should agree for bitfield packing.
630 // Unless allocated_, string_ must be null-terminated.
642 String get(CommentPlacement slot) const;
643 void set(CommentPlacement slot, String comment);
646 using Array = std::array<String, numberOfCommentPlacement>;
677 template <> inline String Value::as<String>() const { return asString(); }
678 template <> inline bool Value::is<String>() const { return isString(); }
680 /// These `as` specializations are type conversions, and do not have a
688 * access a node.
697 PathArgument(String key);
701 String key_;
706 /** \brief Experimental and untested: represents a "path" to access a node.
709 * - "." => root node
710 * - ".[n]" => elements at index 'n' of root node (an array value)
711 * - ".name" => member named 'name' of root node (an object value)
712 * - ".name1.name2.name3"
713 * - ".[0][1][2].name1[3]"
714 * - ".%" => member name is provided as parameter
715 * - ".[%]" => index is provided as parameter
719 Path(const String& path, const PathArgument& a1 = PathArgument(),
727 /// Creates the "path" to access the specified node and returns a reference on
735 void makePath(const String& path, const InArgs& in);
736 void addPathInArg(const String& path, const InArgs& in,
738 static void invalidPath(const String& path, int location);
757 difference_type operator-(const SelfType& other) const {
761 /// Return either the index or the member name of the referenced value as a
765 /// Return the index of the referenced Value, or -1 if it is not an
772 String name() const;
776 /// \deprecated This cannot be used for UTF-8 strings, since there can be
777 /// embedded nulls.
782 /// \note Better version than memberName(). Allows embedded nulls.
786 /*! Internal utility functions to assist with implementing
787 * other iterator functions. The const and non-const versions
789 * current_ member variable in a way that can often be
807 // Indicates that iterator is for a null value.
848 SelfType operator--(int) {
850 --*this;
854 SelfType& operator--() {
866 pointer operator->() const { return &deref(); }
900 SelfType operator--(int) {
902 --*this;
906 SelfType& operator--() {
916 /*! The return value of non-const iterators can be
922 pointer operator->() { return &deref(); }
925 inline void swap(Value& a, Value& b) { a.swap(b); } in swap() argument