Skip to content

Commit 8386d3e

Browse files
committed
Added comments, pre- and post-condition for resize(), clear(), Value(ValueType).
1 parent 5674738 commit 8386d3e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

include/json/value.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ namespace Json {
166166
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
167167

168168
public:
169+
/** \brief Create a default Value of the given type.
170+
This is a very useful constructor.
171+
To create an empty array, pass arrayValue.
172+
To create an empty object, pass objectValue.
173+
Another Value can then be set to this one by assignment.
174+
This is useful since clear() and resize() will not alter types.
175+
*/
169176
Value( ValueType type = nullValue );
170177
Value( Int value );
171178
Value( UInt value );
@@ -230,11 +237,15 @@ namespace Json {
230237
UInt size() const;
231238

232239
/// Removes all object members and array elements.
240+
/// @pre type() is arrayValue, objectValue, or nullValue
241+
/// @post type() is unchanged
233242
void clear();
234243

235244
/// Resize the array to size elements.
236245
/// New elements are initialized to null.
237246
/// May only be called on nullValue or arrayValue.
247+
/// @pre type() is arrayValue or nullValue
248+
/// @post type() is arrayValue
238249
void resize( UInt size );
239250

240251
/// Access an array element (zero based index ).

0 commit comments

Comments
 (0)