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
8
NEWS.txt
8
NEWS.txt
@ -64,6 +64,12 @@
|
|||||||
float (avoid lost of precision warning caused by used of asDouble()
|
float (avoid lost of precision warning caused by used of asDouble()
|
||||||
to initialize a float).
|
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
|
* Tests
|
||||||
|
|
||||||
- Added test to ensure that the escape sequence "\/" is corrected handled
|
- Added test to ensure that the escape sequence "\/" is corrected handled
|
||||||
@ -76,7 +82,7 @@
|
|||||||
|
|
||||||
- Bug #3139678: stack buffer overflow when parsing a double with a
|
- Bug #3139678: stack buffer overflow when parsing a double with a
|
||||||
length of 32 characters.
|
length of 32 characters.
|
||||||
|
|
||||||
* License
|
* License
|
||||||
|
|
||||||
- See file LICENSE for details. Basically JsonCpp is now licensed under
|
- See file LICENSE for details. Basically JsonCpp is now licensed under
|
||||||
|
@ -46,7 +46,7 @@ if ( !parsingSuccessful )
|
|||||||
{
|
{
|
||||||
// report to the user the failure and their locations in the document.
|
// report to the user the failure and their locations in the document.
|
||||||
std::cout << "Failed to parse configuration\n"
|
std::cout << "Failed to parse configuration\n"
|
||||||
<< reader.getFormatedErrorMessages();
|
<< reader.getFormattedErrorMessages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,14 @@
|
|||||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||||
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
|
#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 {
|
namespace Json {
|
||||||
typedef int Int;
|
typedef int Int;
|
||||||
|
@ -72,9 +72,18 @@ namespace Json {
|
|||||||
* \return Formatted error message with the list of errors with their location in
|
* \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
|
* the parsed document. An empty string is returned if no error occurred
|
||||||
* during parsing.
|
* during parsing.
|
||||||
|
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||||
*/
|
*/
|
||||||
|
JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead")
|
||||||
std::string getFormatedErrorMessages() const;
|
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:
|
private:
|
||||||
enum TokenType
|
enum TokenType
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ parseAndSaveValueTree( const std::string &input,
|
|||||||
{
|
{
|
||||||
printf( "Failed to parse %s file: \n%s\n",
|
printf( "Failed to parse %s file: \n%s\n",
|
||||||
kind.c_str(),
|
kind.c_str(),
|
||||||
reader.getFormatedErrorMessages().c_str() );
|
reader.getFormattedErrorMessages().c_str() );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,8 +839,16 @@ Reader::getLocationLineAndColumn( Location location ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Deprecated. Preserved for backward compatibility
|
||||||
std::string
|
std::string
|
||||||
Reader::getFormatedErrorMessages() const
|
Reader::getFormatedErrorMessages() const
|
||||||
|
{
|
||||||
|
return getFormattedErrorMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string
|
||||||
|
Reader::getFormattedErrorMessages() const
|
||||||
{
|
{
|
||||||
std::string formattedMessage;
|
std::string formattedMessage;
|
||||||
for ( Errors::const_iterator itError = errors_.begin();
|
for ( Errors::const_iterator itError = errors_.begin();
|
||||||
@ -862,7 +870,7 @@ std::istream& operator>>( std::istream &sin, Value &root )
|
|||||||
Json::Reader reader;
|
Json::Reader reader;
|
||||||
bool ok = reader.parse(sin, root, true);
|
bool ok = reader.parse(sin, root, true);
|
||||||
//JSON_ASSERT( ok );
|
//JSON_ASSERT( ok );
|
||||||
if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
|
if (!ok) throw std::runtime_error(reader.getFormattedErrorMessages());
|
||||||
return sin;
|
return sin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ duplicateStringValue( const char *value,
|
|||||||
if ( length == unknown )
|
if ( length == unknown )
|
||||||
length = (unsigned int)strlen(value);
|
length = (unsigned int)strlen(value);
|
||||||
char *newString = static_cast<char *>( malloc( length + 1 ) );
|
char *newString = static_cast<char *>( malloc( length + 1 ) );
|
||||||
|
JSON_ASSERT_MESSAGE( newString != 0, "Failed to allocate string value buffer" );
|
||||||
memcpy( newString, value, length );
|
memcpy( newString, value, length );
|
||||||
newString[length] = 0;
|
newString[length] = 0;
|
||||||
return newString;
|
return newString;
|
||||||
@ -112,7 +113,7 @@ Value::CommentInfo::setComment( const char *text )
|
|||||||
{
|
{
|
||||||
if ( comment_ )
|
if ( comment_ )
|
||||||
releaseStringValue( comment_ );
|
releaseStringValue( comment_ );
|
||||||
JSON_ASSERT( text );
|
JSON_ASSERT( text != 0 );
|
||||||
JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /");
|
JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /");
|
||||||
// It seems that /**/ style comments are acceptable as well.
|
// It seems that /**/ style comments are acceptable as well.
|
||||||
comment_ = duplicateStringValue( text );
|
comment_ = duplicateStringValue( text );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user