mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-05-17 11:30:13 +02:00
setComment() will assert if comment does not start with / (or if it were NULL, which would have seg-faulted before).
This commit is contained in:
parent
8386d3efe1
commit
ca21256395
@ -317,8 +317,10 @@ namespace Json {
|
|||||||
// EnumValues enumValues() const;
|
// EnumValues enumValues() const;
|
||||||
//# endif
|
//# endif
|
||||||
|
|
||||||
|
/// Comments must be //... or /* ... */
|
||||||
void setComment( const char *comment,
|
void setComment( const char *comment,
|
||||||
CommentPlacement placement );
|
CommentPlacement placement );
|
||||||
|
/// Comments must be //... or /* ... */
|
||||||
void setComment( const std::string &comment,
|
void setComment( const std::string &comment,
|
||||||
CommentPlacement placement );
|
CommentPlacement placement );
|
||||||
bool hasComment( CommentPlacement placement ) const;
|
bool hasComment( CommentPlacement placement ) const;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <iostream>
|
||||||
#include <json/value.h>
|
#include <json/value.h>
|
||||||
#include <json/writer.h>
|
#include <json/writer.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -149,6 +150,9 @@ Value::CommentInfo::setComment( const char *text )
|
|||||||
{
|
{
|
||||||
if ( comment_ )
|
if ( comment_ )
|
||||||
valueAllocator()->releaseStringValue( comment_ );
|
valueAllocator()->releaseStringValue( comment_ );
|
||||||
|
JSON_ASSERT( text );
|
||||||
|
JSON_ASSERT_MESSAGE( text[0]==NULL || text[0]=='/', "Comments must start with /");
|
||||||
|
// It seems that /**/ style comments are acceptable as well.
|
||||||
comment_ = valueAllocator()->duplicateStringValue( text );
|
comment_ = valueAllocator()->duplicateStringValue( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user