Skip to content

Just run clang format #1025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions include/json/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ namespace Json {
*
* \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:
typedef char Char;
typedef const Char* Location;
Expand Down Expand Up @@ -74,8 +75,8 @@ class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_AP
* \return \c true if the document was successfully parsed, \c false if an
* error occurred.
*/
bool
parse(const std::string& document, Value& root, bool collectComments = true);
bool parse(const std::string& document, Value& root,
bool collectComments = true);

/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
* document.
Expand All @@ -93,14 +94,12 @@ class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_AP
* \return \c true if the document was successfully parsed, \c false if an
* error occurred.
*/
bool parse(const char* beginDoc,
const char* endDoc,
Value& root,
bool parse(const char* beginDoc, const char* endDoc, Value& root,
bool collectComments = true);

/// \brief Parse from input stream.
/// \see Json::operator>>(std::istream&, Json::Value&).
bool parse(IStream& is, Value& root, bool collectComments = true);
bool parse(IStream & is, Value & root, bool collectComments = true);

/** \brief Returns a user friendly string that list errors in the parsed
* document.
Expand All @@ -110,8 +109,8 @@ class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_AP
* occurred during parsing.
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
*/
[[deprecated("Use getFormattedErrorMessages() instead.")]]
String getFormatedErrorMessages() const;
[[deprecated("Use getFormattedErrorMessages() instead.")]] String
getFormatedErrorMessages() const;

/** \brief Returns a user friendly string that list errors in the parsed
* document.
Expand Down Expand Up @@ -191,7 +190,7 @@ class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_AP

typedef std::deque<ErrorInfo> Errors;

bool readToken(Token& token);
bool readToken(Token & token);
void skipSpaces();
bool match(const Char* pattern, int patternLength);
bool readComment();
Expand All @@ -200,35 +199,30 @@ class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_AP
bool readString();
void readNumber();
bool readValue();
bool readObject(Token& token);
bool readArray(Token& token);
bool decodeNumber(Token& token);
bool decodeNumber(Token& token, Value& decoded);
bool decodeString(Token& token);
bool decodeString(Token& token, String& decoded);
bool decodeDouble(Token& token);
bool decodeDouble(Token& token, Value& decoded);
bool decodeUnicodeCodePoint(Token& token,
Location& current,
Location end,
bool readObject(Token & token);
bool readArray(Token & token);
bool decodeNumber(Token & token);
bool decodeNumber(Token & token, Value & decoded);
bool decodeString(Token & token);
bool decodeString(Token & token, String & decoded);
bool decodeDouble(Token & token);
bool decodeDouble(Token & token, Value & decoded);
bool decodeUnicodeCodePoint(Token & token, Location & current, Location end,
unsigned int& unicode);
bool decodeUnicodeEscapeSequence(Token& token,
Location& current,
Location end,
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 recoverFromError(TokenType skipUntilToken);
bool addErrorAndRecover(const String& message,
Token& token,
bool addErrorAndRecover(const String& message, Token& token,
TokenType skipUntilToken);
void skipUntilSpace();
Value& currentValue();
Char getNextChar();
void
getLocationLineAndColumn(Location location, int& line, int& column) const;
void getLocationLineAndColumn(Location location, int& line, int& column)
const;
String getLocationLineAndColumn(Location location) const;
void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token& token);
void skipCommentTokens(Token & token);

static bool containsNewLine(Location begin, Location end);
static String normalizeEOL(Location begin, Location end);
Expand Down
10 changes: 5 additions & 5 deletions include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ class JSON_API Value {
static Value const& nullSingleton();

/// 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.
static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
/// Maximum unsigned integer value that can be stored in a Json::Value.
Expand Down Expand Up @@ -566,8 +567,8 @@ class JSON_API Value {
//# endif

/// \deprecated Always pass len.
[[deprecated("Use setComment(String const&) instead.")]]
void setComment(const char* comment, CommentPlacement placement) {
[[deprecated("Use setComment(String const&) instead.")]] void
setComment(const char* comment, CommentPlacement placement) {
setComment(String(comment, strlen(comment)), placement);
}
/// Comments must be //... or /* ... */
Expand Down Expand Up @@ -752,8 +753,7 @@ class JSON_API ValueIteratorBase {
/// objectValue.
/// \deprecated This cannot be used for UTF-8 strings, since there can be
/// embedded nulls.
[[deprecated("Use `key = name();` instead.")]]
char const* memberName() const;
[[deprecated("Use `key = name();` instead.")]] char const* memberName() const;
/// Return the member name of the referenced Value, or NULL if it is not an
/// objectValue.
/// \note Better version than memberName(). Allows embedded nulls.
Expand Down
46 changes: 23 additions & 23 deletions include/json/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ namespace Json {
class Value;

/**
*
* Usage:
* \code
* using namespace Json;
* void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
* std::unique_ptr<StreamWriter> const writer(
* factory.newStreamWriter());
* writer->write(value, &std::cout);
* std::cout << std::endl; // add lf and flush
* }
* \endcode
*/
*
* Usage:
* \code
* using namespace Json;
* void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
* { std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
* writer->write(value, &std::cout);
* std::cout << std::endl; // add lf and flush
* }
* \endcode
*/
class JSON_API StreamWriter {
protected:
OStream* sout_; // not owned; will not delete
public:
StreamWriter();
virtual ~StreamWriter();
/** Write Value into document as configured in sub-class.
* Do not take ownership of sout, but maintain a reference during function.
* \pre sout != NULL
* \return zero on success (For now, we always return zero, so check the
* stream instead.) \throw std::exception possibly, depending on configuration
*/
/** Write Value into document as configured in sub-class.
* Do not take ownership of sout, but maintain a reference during function.
* \pre sout != NULL
* \return zero on success (For now, we always return zero, so check the
* stream instead.) \throw std::exception possibly, depending on
* configuration
*/
virtual int write(Value const& root, OStream* sout) = 0;

/** \brief A simple abstract factory.
Expand Down Expand Up @@ -225,8 +225,8 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
#pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
StyledWriter : public Writer {
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API StyledWriter
: public Writer {
public:
StyledWriter();
~StyledWriter() override = default;
Expand Down Expand Up @@ -294,8 +294,8 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
#pragma warning(push)
#pragma warning(disable : 4996) // Deriving from deprecated class
#endif
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
StyledStreamWriter {
class [[deprecated(
"Use StreamWriterBuilder instead")]] JSON_API StyledStreamWriter {
public:
/**
* \param indentation Each level will be indented by this amount extra.
Expand All @@ -310,7 +310,7 @@ class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
* \note There is no point in deriving from Writer, since write() should not
* return a value.
*/
void write(OStream& out, const Value& root);
void write(OStream & out, const Value& root);

private:
void writeValue(const Value& value);
Expand Down
1 change: 0 additions & 1 deletion src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ Value const& Value::null = Value::nullSingleton();
Value const& Value::nullRef = Value::nullSingleton();
#endif


#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
template <typename T, typename U>
static inline bool InRange(double d, T min, U max) {
Expand Down
4 changes: 2 additions & 2 deletions src/test_lib_json/jsontest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ void Runner::preventDialogOnCrash() {
_CrtSetReportHook(&msvcrtSilentReportHook);
#endif // if defined(_MSC_VER)

// @todo investigate this handler (for buffer overflow)
// _set_security_error_handler
// @todo investigate this handler (for buffer overflow)
// _set_security_error_handler

#if defined(_WIN32)
// Prevents the system from popping a dialog for debugging if the
Expand Down
17 changes: 10 additions & 7 deletions src/test_lib_json/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,8 @@ JSONTEST_FIXTURE(StreamWriterTest, indentation) {
JSONTEST_ASSERT(Json::writeString(b, root) == "{\"hello\":\"world\"}");

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) {
Expand Down Expand Up @@ -2198,9 +2199,10 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
Json::String errs;
bool ok = reader->parse(doc, doc + std::strlen(doc), &root, &errs);
JSONTEST_ASSERT(!ok);
JSONTEST_ASSERT_STRING_EQUAL("* Line 1, Column 1\n"
" A valid JSON document must be either an array or an object value.\n",
errs);
JSONTEST_ASSERT_STRING_EQUAL(
"* Line 1, Column 1\n"
" A valid JSON document must be either an array or an object value.\n",
errs);
JSONTEST_ASSERT_EQUAL("property", root);
delete reader;
}
Expand Down Expand Up @@ -2451,7 +2453,8 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
Json::String errs;
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);
JSONTEST_ASSERT(ok);
JSONTEST_ASSERT_STRING_EQUAL("", errs);
Expand Down Expand Up @@ -2487,7 +2490,7 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
{__LINE__, false, "{\"a\":.Infinity}"}, //
{__LINE__, false, "{\"a\":_Infinity}"}, //
{__LINE__, false, "{\"a\":_nfinity}"}, //
{__LINE__, true, "{\"a\":-Infinity}"}, //
{__LINE__, true, "{\"a\":-Infinity}"}, //
{__LINE__, true, "{\"a\":+Infinity}"} //
};
for (const auto& td : test_data) {
Expand Down Expand Up @@ -2594,7 +2597,7 @@ JSONTEST_FIXTURE(IteratorTest, const) {
Json::Value const v;
JSONTEST_ASSERT_THROWS(
Json::Value::iterator it(v.begin()) // Compile, but throw.
);
);

Json::Value value;

Expand Down