mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-23 16:52:43 +02:00
revert 'Add public semantic error reporting'
for binary-compatibility with 0.6.0 issue #147 was #57
This commit is contained in:
parent
1c4f6a2d79
commit
a9d06d2650
@ -132,29 +132,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::vector<StructuredError> getStructuredErrors() const;
|
std::vector<StructuredError> getStructuredErrors() const;
|
||||||
|
|
||||||
/** \brief Add a semantic error message.
|
|
||||||
* \param value JSON Value location associated with the error
|
|
||||||
* \param message The error message.
|
|
||||||
* \return \c true if the error was successfully added, \c false if the
|
|
||||||
* Value offset exceeds the document size.
|
|
||||||
*/
|
|
||||||
bool pushError(const Value& value, const std::string& message);
|
|
||||||
|
|
||||||
/** \brief Add a semantic error message with extra context.
|
|
||||||
* \param value JSON Value location associated with the error
|
|
||||||
* \param message The error message.
|
|
||||||
* \param extra Additional JSON Value location to contextualize the error
|
|
||||||
* \return \c true if the error was successfully added, \c false if either
|
|
||||||
* Value offset exceeds the document size.
|
|
||||||
*/
|
|
||||||
bool pushError(const Value& value, const std::string& message, const Value& extra);
|
|
||||||
|
|
||||||
/** \brief Return whether there are any errors.
|
|
||||||
* \return \c true if there are no errors to report \c false if
|
|
||||||
* errors have occurred.
|
|
||||||
*/
|
|
||||||
bool good() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum TokenType {
|
enum TokenType {
|
||||||
tokenEndOfStream = 0,
|
tokenEndOfStream = 0,
|
||||||
|
@ -864,45 +864,8 @@ std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
|
|||||||
}
|
}
|
||||||
return allErrors;
|
return allErrors;
|
||||||
}
|
}
|
||||||
|
// Reader
|
||||||
bool Reader::pushError(const Value& value, const std::string& message) {
|
/////////////////////////
|
||||||
size_t length = end_ - begin_;
|
|
||||||
if(value.getOffsetStart() > length
|
|
||||||
|| value.getOffsetLimit() > length)
|
|
||||||
return false;
|
|
||||||
Token token;
|
|
||||||
token.type_ = tokenError;
|
|
||||||
token.start_ = begin_ + value.getOffsetStart();
|
|
||||||
token.end_ = end_ + value.getOffsetLimit();
|
|
||||||
ErrorInfo info;
|
|
||||||
info.token_ = token;
|
|
||||||
info.message_ = message;
|
|
||||||
info.extra_ = 0;
|
|
||||||
errors_.push_back(info);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) {
|
|
||||||
size_t length = end_ - begin_;
|
|
||||||
if(value.getOffsetStart() > length
|
|
||||||
|| value.getOffsetLimit() > length
|
|
||||||
|| extra.getOffsetLimit() > length)
|
|
||||||
return false;
|
|
||||||
Token token;
|
|
||||||
token.type_ = tokenError;
|
|
||||||
token.start_ = begin_ + value.getOffsetStart();
|
|
||||||
token.end_ = begin_ + value.getOffsetLimit();
|
|
||||||
ErrorInfo info;
|
|
||||||
info.token_ = token;
|
|
||||||
info.message_ = message;
|
|
||||||
info.extra_ = begin_ + extra.getOffsetStart();
|
|
||||||
errors_.push_back(info);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Reader::good() const {
|
|
||||||
return !errors_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// exact copy of Features
|
// exact copy of Features
|
||||||
class OurFeatures {
|
class OurFeatures {
|
||||||
@ -953,9 +916,6 @@ public:
|
|||||||
bool collectComments = true);
|
bool collectComments = true);
|
||||||
std::string getFormattedErrorMessages() const;
|
std::string getFormattedErrorMessages() const;
|
||||||
std::vector<StructuredError> getStructuredErrors() const;
|
std::vector<StructuredError> getStructuredErrors() const;
|
||||||
bool pushError(const Value& value, const std::string& message);
|
|
||||||
bool pushError(const Value& value, const std::string& message, const Value& extra);
|
|
||||||
bool good() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OurReader(OurReader const&); // no impl
|
OurReader(OurReader const&); // no impl
|
||||||
@ -1823,45 +1783,6 @@ std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
|
|||||||
return allErrors;
|
return allErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OurReader::pushError(const Value& value, const std::string& message) {
|
|
||||||
size_t length = end_ - begin_;
|
|
||||||
if(value.getOffsetStart() > length
|
|
||||||
|| value.getOffsetLimit() > length)
|
|
||||||
return false;
|
|
||||||
Token token;
|
|
||||||
token.type_ = tokenError;
|
|
||||||
token.start_ = begin_ + value.getOffsetStart();
|
|
||||||
token.end_ = end_ + value.getOffsetLimit();
|
|
||||||
ErrorInfo info;
|
|
||||||
info.token_ = token;
|
|
||||||
info.message_ = message;
|
|
||||||
info.extra_ = 0;
|
|
||||||
errors_.push_back(info);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OurReader::pushError(const Value& value, const std::string& message, const Value& extra) {
|
|
||||||
size_t length = end_ - begin_;
|
|
||||||
if(value.getOffsetStart() > length
|
|
||||||
|| value.getOffsetLimit() > length
|
|
||||||
|| extra.getOffsetLimit() > length)
|
|
||||||
return false;
|
|
||||||
Token token;
|
|
||||||
token.type_ = tokenError;
|
|
||||||
token.start_ = begin_ + value.getOffsetStart();
|
|
||||||
token.end_ = begin_ + value.getOffsetLimit();
|
|
||||||
ErrorInfo info;
|
|
||||||
info.token_ = token;
|
|
||||||
info.message_ = message;
|
|
||||||
info.extra_ = begin_ + extra.getOffsetStart();
|
|
||||||
errors_.push_back(info);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OurReader::good() const {
|
|
||||||
return !errors_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class OurCharReader : public CharReader {
|
class OurCharReader : public CharReader {
|
||||||
bool const collectComments_;
|
bool const collectComments_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user