Skip to content

Commit

Permalink
Renamed Reader::getFormatedErrorMessages() to getFormattedErrorMessag…
Browse files Browse the repository at this point in the history
…es. Bug #3023708 (Formatted has 2 't'). The old member function is deprecated but still present for backward compatibility.
  • Loading branch information
blep committed May 1, 2011
1 parent 99043b3 commit b2e8ccc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
8 changes: 7 additions & 1 deletion NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
float (avoid lost of precision warning caused by used of asDouble()
to initialize a float).

* Reader

- Renamed Reader::getFormatedErrorMessages() to getFormattedErrorMessages.
Bug #3023708 (Formatted has 2 't'). The old member function is deprecated
but still present for backward compatibility.

* Tests

- Added test to ensure that the escape sequence "\/" is corrected handled
Expand All @@ -76,7 +82,7 @@

- Bug #3139678: stack buffer overflow when parsing a double with a
length of 32 characters.

* License

- See file LICENSE for details. Basically JsonCpp is now licensed under
Expand Down
2 changes: 1 addition & 1 deletion doc/jsoncpp.dox
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if ( !parsingSuccessful )
{
// report to the user the failure and their locations in the document.
std::cout << "Failed to parse configuration\n"
<< reader.getFormatedErrorMessages();
<< reader.getFormattedErrorMessages();
return;
}

Expand Down
8 changes: 8 additions & 0 deletions include/json/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6

#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
/// Indicates that the following function is deprecated.
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
#endif

#if !defined(JSONCPP_DEPRECATED)
# define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)

namespace Json {
typedef int Int;
Expand Down
9 changes: 9 additions & 0 deletions include/json/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ namespace Json {
* \return Formatted error message with the list of errors with their location in
* the parsed document. An empty string is returned if no error occurred
* during parsing.
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
*/
JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead")
std::string getFormatedErrorMessages() const;

/** \brief Returns a user friendly string that list errors in the parsed document.
* \return Formatted error message with the list of errors with their location in
* the parsed document. An empty string is returned if no error occurred
* during parsing.
*/
std::string getFormattedErrorMessages() const;

private:
enum TokenType
{
Expand Down
2 changes: 1 addition & 1 deletion src/jsontestrunner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ parseAndSaveValueTree( const std::string &input,
{
printf( "Failed to parse %s file: \n%s\n",
kind.c_str(),
reader.getFormatedErrorMessages().c_str() );
reader.getFormattedErrorMessages().c_str() );
return 1;
}

Expand Down
10 changes: 9 additions & 1 deletion src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,16 @@ Reader::getLocationLineAndColumn( Location location ) const
}


// Deprecated. Preserved for backward compatibility
std::string
Reader::getFormatedErrorMessages() const
{
return getFormattedErrorMessages();
}


std::string
Reader::getFormattedErrorMessages() const
{
std::string formattedMessage;
for ( Errors::const_iterator itError = errors_.begin();
Expand All @@ -862,7 +870,7 @@ std::istream& operator>>( std::istream &sin, Value &root )
Json::Reader reader;
bool ok = reader.parse(sin, root, true);
//JSON_ASSERT( ok );
if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
if (!ok) throw std::runtime_error(reader.getFormattedErrorMessages());
return sin;
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ duplicateStringValue( const char *value,
if ( length == unknown )
length = (unsigned int)strlen(value);
char *newString = static_cast<char *>( malloc( length + 1 ) );
JSON_ASSERT_MESSAGE( newString != 0, "Failed to allocate string value buffer" );
memcpy( newString, value, length );
newString[length] = 0;
return newString;
Expand Down Expand Up @@ -112,7 +113,7 @@ Value::CommentInfo::setComment( const char *text )
{
if ( comment_ )
releaseStringValue( comment_ );
JSON_ASSERT( text );
JSON_ASSERT( text != 0 );
JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /");
// It seems that /**/ style comments are acceptable as well.
comment_ = duplicateStringValue( text );
Expand Down

0 comments on commit b2e8ccc

Please sign in to comment.