1+ // vim: ts=3 sts=3 sw=3 tw=0
12// Copyright 2011 Baptiste Lepilleur
23// Distributed under MIT license, or public domain if desired and
34// recognized in your jurisdiction.
@@ -91,7 +92,7 @@ duplicateStringValue( const char *value,
9192 length = Value::maxInt - 1 ;
9293
9394 char *newString = static_cast <char *>( malloc ( length + 1 ) );
94- JSON_ASSERT_MESSAGE ( newString != 0 , " Failed to allocate string value buffer" );
95+ JSON_ASSERT_MESSAGE ( newString != 0 , " in Json::Value::duplicateStringValue(): Failed to allocate string value buffer" );
9596 memcpy ( newString, value, length );
9697 newString[length] = 0 ;
9798 return newString;
@@ -155,7 +156,7 @@ Value::CommentInfo::setComment( const char *text )
155156 if ( comment_ )
156157 releaseStringValue ( comment_ );
157158 JSON_ASSERT ( text != 0 );
158- JSON_ASSERT_MESSAGE ( text[0 ]==' \0 ' || text[0 ]==' /' , " Comments must start with /" );
159+ JSON_ASSERT_MESSAGE ( text[0 ]==' \0 ' || text[0 ]==' /' , " in Json::Value::setComment(): Comments must start with /" );
159160 // It seems that /**/ style comments are acceptable as well.
160161 comment_ = duplicateStringValue ( text );
161162}
@@ -692,7 +693,7 @@ Value::operator !=( const Value &other ) const
692693const char *
693694Value::asCString () const
694695{
695- JSON_ASSERT ( type_ == stringValue );
696+ JSON_ASSERT_MESSAGE ( type_ == stringValue, " in Json::Value::asCString(): requires stringValue " );
696697 return value_.string_ ;
697698}
698699
@@ -1026,7 +1027,7 @@ Value::operator!() const
10261027void
10271028Value::clear ()
10281029{
1029- JSON_ASSERT ( type_ == nullValue || type_ == arrayValue || type_ == objectValue );
1030+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == arrayValue || type_ == objectValue, " in Json::Value::clear(): requires complex value " );
10301031
10311032 switch ( type_ )
10321033 {
@@ -1051,7 +1052,7 @@ Value::clear()
10511052void
10521053Value::resize ( ArrayIndex newSize )
10531054{
1054- JSON_ASSERT ( type_ == nullValue || type_ == arrayValue );
1055+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == arrayValue, " in Json::Value::resize(): requires arrayValue " );
10551056 if ( type_ == nullValue )
10561057 *this = Value ( arrayValue );
10571058#ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -1077,7 +1078,7 @@ Value::resize( ArrayIndex newSize )
10771078Value &
10781079Value::operator []( ArrayIndex index )
10791080{
1080- JSON_ASSERT ( type_ == nullValue || type_ == arrayValue );
1081+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == arrayValue, " in Json::Value::operator[](ArrayIndex): requires arrayValue " );
10811082 if ( type_ == nullValue )
10821083 *this = Value ( arrayValue );
10831084#ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -1098,15 +1099,15 @@ Value::operator[]( ArrayIndex index )
10981099Value &
10991100Value::operator []( int index )
11001101{
1101- JSON_ASSERT ( index >= 0 );
1102+ JSON_ASSERT_MESSAGE ( index >= 0 , " in Json::Value::operator[](int index): index cannot be negative " );
11021103 return (*this )[ ArrayIndex (index) ];
11031104}
11041105
11051106
11061107const Value &
11071108Value::operator []( ArrayIndex index ) const
11081109{
1109- JSON_ASSERT ( type_ == nullValue || type_ == arrayValue );
1110+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == arrayValue, " in Json::Value::operator[](ArrayIndex)const: requires arrayValue " );
11101111 if ( type_ == nullValue )
11111112 return null;
11121113#ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -1125,7 +1126,7 @@ Value::operator[]( ArrayIndex index ) const
11251126const Value &
11261127Value::operator []( int index ) const
11271128{
1128- JSON_ASSERT ( index >= 0 );
1129+ JSON_ASSERT_MESSAGE ( index >= 0 , " in Json::Value::operator[](int index) const: index cannot be negative " );
11291130 return (*this )[ ArrayIndex (index) ];
11301131}
11311132
@@ -1141,7 +1142,7 @@ Value &
11411142Value::resolveReference ( const char *key,
11421143 bool isStatic )
11431144{
1144- JSON_ASSERT ( type_ == nullValue || type_ == objectValue );
1145+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == objectValue, " in Json::Value::resolveReference(): requires objectValue " );
11451146 if ( type_ == nullValue )
11461147 *this = Value ( objectValue );
11471148#ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -1181,7 +1182,7 @@ Value::isValidIndex( ArrayIndex index ) const
11811182const Value &
11821183Value::operator []( const char *key ) const
11831184{
1184- JSON_ASSERT ( type_ == nullValue || type_ == objectValue );
1185+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == objectValue, " in Json::Value::operator[](char const*)const: requires objectValue " );
11851186 if ( type_ == nullValue )
11861187 return null;
11871188#ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -1259,7 +1260,7 @@ Value::get( const std::string &key,
12591260Value
12601261Value::removeMember ( const char * key )
12611262{
1262- JSON_ASSERT ( type_ == nullValue || type_ == objectValue );
1263+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == objectValue, " in Json::Value::removeMember(): requires objectValue " );
12631264 if ( type_ == nullValue )
12641265 return null;
12651266#ifndef JSON_VALUE_USE_INTERNAL_MAP
@@ -1323,7 +1324,7 @@ Value::isMember( const CppTL::ConstString &key ) const
13231324Value::Members
13241325Value::getMemberNames () const
13251326{
1326- JSON_ASSERT ( type_ == nullValue || type_ == objectValue );
1327+ JSON_ASSERT_MESSAGE ( type_ == nullValue || type_ == objectValue, " in Json::Value::getMemberNames(), value must be objectValue " );
13271328 if ( type_ == nullValue )
13281329 return Value::Members ();
13291330 Members members;
0 commit comments