mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
Just run clang format (#1025)
This commit is contained in:
parent
18f790fbe7
commit
81ae1d55f7
@ -36,7 +36,8 @@ namespace Json {
|
|||||||
*
|
*
|
||||||
* \deprecated Use CharReader and CharReaderBuilder.
|
* \deprecated Use CharReader and CharReaderBuilder.
|
||||||
*/
|
*/
|
||||||
class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader {
|
class [[deprecated(
|
||||||
|
"deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader {
|
||||||
public:
|
public:
|
||||||
typedef char Char;
|
typedef char Char;
|
||||||
typedef const Char* Location;
|
typedef const Char* Location;
|
||||||
@ -74,8 +75,8 @@ public:
|
|||||||
* \return \c true if the document was successfully parsed, \c false if an
|
* \return \c true if the document was successfully parsed, \c false if an
|
||||||
* error occurred.
|
* error occurred.
|
||||||
*/
|
*/
|
||||||
bool
|
bool parse(const std::string& document, Value& root,
|
||||||
parse(const std::string& document, Value& root, bool collectComments = true);
|
bool collectComments = true);
|
||||||
|
|
||||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||||
* document.
|
* document.
|
||||||
@ -93,9 +94,7 @@ public:
|
|||||||
* \return \c true if the document was successfully parsed, \c false if an
|
* \return \c true if the document was successfully parsed, \c false if an
|
||||||
* error occurred.
|
* error occurred.
|
||||||
*/
|
*/
|
||||||
bool parse(const char* beginDoc,
|
bool parse(const char* beginDoc, const char* endDoc, Value& root,
|
||||||
const char* endDoc,
|
|
||||||
Value& root,
|
|
||||||
bool collectComments = true);
|
bool collectComments = true);
|
||||||
|
|
||||||
/// \brief Parse from input stream.
|
/// \brief Parse from input stream.
|
||||||
@ -110,8 +109,8 @@ public:
|
|||||||
* occurred during parsing.
|
* occurred during parsing.
|
||||||
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||||
*/
|
*/
|
||||||
[[deprecated("Use getFormattedErrorMessages() instead.")]]
|
[[deprecated("Use getFormattedErrorMessages() instead.")]] String
|
||||||
String getFormatedErrorMessages() const;
|
getFormatedErrorMessages() const;
|
||||||
|
|
||||||
/** \brief Returns a user friendly string that list errors in the parsed
|
/** \brief Returns a user friendly string that list errors in the parsed
|
||||||
* document.
|
* document.
|
||||||
@ -208,24 +207,19 @@ private:
|
|||||||
bool decodeString(Token & token, String & decoded);
|
bool decodeString(Token & token, String & decoded);
|
||||||
bool decodeDouble(Token & token);
|
bool decodeDouble(Token & token);
|
||||||
bool decodeDouble(Token & token, Value & decoded);
|
bool decodeDouble(Token & token, Value & decoded);
|
||||||
bool decodeUnicodeCodePoint(Token& token,
|
bool decodeUnicodeCodePoint(Token & token, Location & current, Location end,
|
||||||
Location& current,
|
|
||||||
Location end,
|
|
||||||
unsigned int& unicode);
|
|
||||||
bool decodeUnicodeEscapeSequence(Token& token,
|
|
||||||
Location& current,
|
|
||||||
Location end,
|
|
||||||
unsigned int& unicode);
|
unsigned int& unicode);
|
||||||
|
bool decodeUnicodeEscapeSequence(Token & token, Location & current,
|
||||||
|
Location end, unsigned int& unicode);
|
||||||
bool addError(const String& message, Token& token, Location extra = nullptr);
|
bool addError(const String& message, Token& token, Location extra = nullptr);
|
||||||
bool recoverFromError(TokenType skipUntilToken);
|
bool recoverFromError(TokenType skipUntilToken);
|
||||||
bool addErrorAndRecover(const String& message,
|
bool addErrorAndRecover(const String& message, Token& token,
|
||||||
Token& token,
|
|
||||||
TokenType skipUntilToken);
|
TokenType skipUntilToken);
|
||||||
void skipUntilSpace();
|
void skipUntilSpace();
|
||||||
Value& currentValue();
|
Value& currentValue();
|
||||||
Char getNextChar();
|
Char getNextChar();
|
||||||
void
|
void getLocationLineAndColumn(Location location, int& line, int& column)
|
||||||
getLocationLineAndColumn(Location location, int& line, int& column) const;
|
const;
|
||||||
String getLocationLineAndColumn(Location location) const;
|
String getLocationLineAndColumn(Location location) const;
|
||||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||||
void skipCommentTokens(Token & token);
|
void skipCommentTokens(Token & token);
|
||||||
|
@ -203,7 +203,8 @@ public:
|
|||||||
static Value const& nullSingleton();
|
static Value const& nullSingleton();
|
||||||
|
|
||||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||||
static constexpr LargestInt minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
|
static constexpr LargestInt minLargestInt =
|
||||||
|
LargestInt(~(LargestUInt(-1) / 2));
|
||||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||||
static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
|
static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
|
||||||
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
||||||
@ -566,8 +567,8 @@ public:
|
|||||||
//# endif
|
//# endif
|
||||||
|
|
||||||
/// \deprecated Always pass len.
|
/// \deprecated Always pass len.
|
||||||
[[deprecated("Use setComment(String const&) instead.")]]
|
[[deprecated("Use setComment(String const&) instead.")]] void
|
||||||
void setComment(const char* comment, CommentPlacement placement) {
|
setComment(const char* comment, CommentPlacement placement) {
|
||||||
setComment(String(comment, strlen(comment)), placement);
|
setComment(String(comment, strlen(comment)), placement);
|
||||||
}
|
}
|
||||||
/// Comments must be //... or /* ... */
|
/// Comments must be //... or /* ... */
|
||||||
@ -752,8 +753,7 @@ public:
|
|||||||
/// objectValue.
|
/// objectValue.
|
||||||
/// \deprecated This cannot be used for UTF-8 strings, since there can be
|
/// \deprecated This cannot be used for UTF-8 strings, since there can be
|
||||||
/// embedded nulls.
|
/// embedded nulls.
|
||||||
[[deprecated("Use `key = name();` instead.")]]
|
[[deprecated("Use `key = name();` instead.")]] char const* memberName() const;
|
||||||
char const* memberName() const;
|
|
||||||
/// Return the member name of the referenced Value, or NULL if it is not an
|
/// Return the member name of the referenced Value, or NULL if it is not an
|
||||||
/// objectValue.
|
/// objectValue.
|
||||||
/// \note Better version than memberName(). Allows embedded nulls.
|
/// \note Better version than memberName(). Allows embedded nulls.
|
||||||
|
@ -31,9 +31,8 @@ class Value;
|
|||||||
* Usage:
|
* Usage:
|
||||||
* \code
|
* \code
|
||||||
* using namespace Json;
|
* using namespace Json;
|
||||||
* void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
|
* void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
|
||||||
* std::unique_ptr<StreamWriter> const writer(
|
* { std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
|
||||||
* factory.newStreamWriter());
|
|
||||||
* writer->write(value, &std::cout);
|
* writer->write(value, &std::cout);
|
||||||
* std::cout << std::endl; // add lf and flush
|
* std::cout << std::endl; // add lf and flush
|
||||||
* }
|
* }
|
||||||
@ -49,7 +48,8 @@ public:
|
|||||||
* Do not take ownership of sout, but maintain a reference during function.
|
* Do not take ownership of sout, but maintain a reference during function.
|
||||||
* \pre sout != NULL
|
* \pre sout != NULL
|
||||||
* \return zero on success (For now, we always return zero, so check the
|
* \return zero on success (For now, we always return zero, so check the
|
||||||
* stream instead.) \throw std::exception possibly, depending on configuration
|
* stream instead.) \throw std::exception possibly, depending on
|
||||||
|
* configuration
|
||||||
*/
|
*/
|
||||||
virtual int write(Value const& root, OStream* sout) = 0;
|
virtual int write(Value const& root, OStream* sout) = 0;
|
||||||
|
|
||||||
@ -225,8 +225,8 @@ private:
|
|||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||||
#endif
|
#endif
|
||||||
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
|
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter
|
||||||
StyledWriter : public Writer {
|
: public Writer {
|
||||||
public:
|
public:
|
||||||
StyledWriter();
|
StyledWriter();
|
||||||
~StyledWriter() override = default;
|
~StyledWriter() override = default;
|
||||||
@ -294,8 +294,8 @@ private:
|
|||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||||
#endif
|
#endif
|
||||||
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
|
class [[deprecated(
|
||||||
StyledStreamWriter {
|
"Use StreamWriterBuilder instead")]] JSON_API StyledStreamWriter {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \param indentation Each level will be indented by this amount extra.
|
* \param indentation Each level will be indented by this amount extra.
|
||||||
|
@ -88,7 +88,6 @@ Value const& Value::null = Value::nullSingleton();
|
|||||||
Value const& Value::nullRef = Value::nullSingleton();
|
Value const& Value::nullRef = Value::nullSingleton();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
static inline bool InRange(double d, T min, U max) {
|
static inline bool InRange(double d, T min, U max) {
|
||||||
|
@ -1920,7 +1920,8 @@ JSONTEST_FIXTURE(StreamWriterTest, indentation) {
|
|||||||
JSONTEST_ASSERT(Json::writeString(b, root) == "{\"hello\":\"world\"}");
|
JSONTEST_ASSERT(Json::writeString(b, root) == "{\"hello\":\"world\"}");
|
||||||
|
|
||||||
b.settings_["indentation"] = "\t";
|
b.settings_["indentation"] = "\t";
|
||||||
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"hello\" : \"world\"\n}");
|
JSONTEST_ASSERT(Json::writeString(b, root) ==
|
||||||
|
"{\n\t\"hello\" : \"world\"\n}");
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) {
|
JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) {
|
||||||
@ -2198,7 +2199,8 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
|||||||
Json::String errs;
|
Json::String errs;
|
||||||
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
|
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
|
||||||
JSONTEST_ASSERT(!ok);
|
JSONTEST_ASSERT(!ok);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("* Line 1, Column 1\n"
|
JSONTEST_ASSERT_STRING_EQUAL(
|
||||||
|
"* Line 1, Column 1\n"
|
||||||
" A valid JSON document must be either an array or an object value.\n",
|
" A valid JSON document must be either an array or an object value.\n",
|
||||||
errs);
|
errs);
|
||||||
JSONTEST_ASSERT_EQUAL("property", root);
|
JSONTEST_ASSERT_EQUAL("property", root);
|
||||||
@ -2451,7 +2453,8 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
|
|||||||
Json::String errs;
|
Json::String errs;
|
||||||
Json::CharReader* reader(b.newCharReader());
|
Json::CharReader* reader(b.newCharReader());
|
||||||
{
|
{
|
||||||
char const doc[] = "{\"a\":NaN,\"b\":Infinity,\"c\":-Infinity,\"d\":+Infinity}";
|
char const doc[] =
|
||||||
|
"{\"a\":NaN,\"b\":Infinity,\"c\":-Infinity,\"d\":+Infinity}";
|
||||||
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
|
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
|
||||||
JSONTEST_ASSERT(ok);
|
JSONTEST_ASSERT(ok);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user