mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-05-20 12:05:31 +02:00
Renamed Reader::getFormatedErrorMessages() to getFormattedErrorMessages. Bug #3023708 (Formatted has 2 't'). The old member function is deprecated but still present for backward compatibility.
This commit is contained in:
parent
99043b32b5
commit
b2e8cccbc6
6
NEWS.txt
6
NEWS.txt
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user