Skip to content

Commit 7b1e53c

Browse files
committed
change uses of JSONCPP_FOO to Json::Foo
1 parent 53e8a37 commit 7b1e53c

File tree

14 files changed

+387
-419
lines changed

14 files changed

+387
-419
lines changed

Diff for: include/json/assertions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#define JSON_FAIL_MESSAGE(message) \
3131
{ \
32-
JSONCPP_OSTRINGSTREAM oss; \
32+
OStringStream oss; \
3333
oss << message; \
3434
Json::throwLogicError(oss.str()); \
3535
abort(); \
@@ -43,7 +43,7 @@
4343
// release builds we abort, for a core-dump or debugger.
4444
#define JSON_FAIL_MESSAGE(message) \
4545
{ \
46-
JSONCPP_OSTRINGSTREAM oss; \
46+
OStringStream oss; \
4747
oss << message; \
4848
assert(false && oss.str().c_str()); \
4949
abort(); \

Diff for: include/json/config.h

+2
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ using IStream = std::istream;
189189
using OStream = std::ostream;
190190
} // namespace Json
191191

192+
#if 0 // easily test without these names in place
192193
// Legacy names (formerly macros).
193194
using JSONCPP_STRING = Json::String;
194195
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
195196
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
196197
using JSONCPP_ISTREAM = Json::IStream;
197198
using JSONCPP_OSTREAM = Json::OStream;
199+
#endif
198200

199201
#endif // JSON_CONFIG_H_INCLUDED

Diff for: include/json/reader.h

+19-23
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class JSON_API Reader {
4646
struct StructuredError {
4747
ptrdiff_t offset_start;
4848
ptrdiff_t offset_limit;
49-
JSONCPP_STRING message;
49+
String message;
5050
};
5151

5252
/** \brief Constructs a Reader allowing all features
@@ -103,7 +103,7 @@ class JSON_API Reader {
103103

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

108108
/** \brief Returns a user friendly string that list errors in the parsed
109109
* document.
@@ -115,7 +115,7 @@ class JSON_API Reader {
115115
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
116116
*/
117117
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
118-
JSONCPP_STRING getFormatedErrorMessages() const;
118+
String getFormatedErrorMessages() const;
119119

120120
/** \brief Returns a user friendly string that list errors in the parsed
121121
* document.
@@ -125,7 +125,7 @@ class JSON_API Reader {
125125
* occurred
126126
* during parsing.
127127
*/
128-
JSONCPP_STRING getFormattedErrorMessages() const;
128+
String getFormattedErrorMessages() const;
129129

130130
/** \brief Returns a vector of structured erros encounted while parsing.
131131
* \return A (possibly empty) vector of StructuredError objects. Currently
@@ -142,7 +142,7 @@ class JSON_API Reader {
142142
* \return \c true if the error was successfully added, \c false if the
143143
* Value offset exceeds the document size.
144144
*/
145-
bool pushError(const Value& value, const JSONCPP_STRING& message);
145+
bool pushError(const Value& value, const String& message);
146146

147147
/** \brief Add a semantic error message with extra context.
148148
* \param value JSON Value location associated with the error
@@ -151,9 +151,7 @@ class JSON_API Reader {
151151
* \return \c true if the error was successfully added, \c false if either
152152
* Value offset exceeds the document size.
153153
*/
154-
bool pushError(const Value& value,
155-
const JSONCPP_STRING& message,
156-
const Value& extra);
154+
bool pushError(const Value& value, const String& message, const Value& extra);
157155

158156
/** \brief Return whether there are any errors.
159157
* \return \c true if there are no errors to report \c false if
@@ -189,7 +187,7 @@ class JSON_API Reader {
189187
class ErrorInfo {
190188
public:
191189
Token token_;
192-
JSONCPP_STRING message_;
190+
String message_;
193191
Location extra_;
194192
};
195193

@@ -209,7 +207,7 @@ class JSON_API Reader {
209207
bool decodeNumber(Token& token);
210208
bool decodeNumber(Token& token, Value& decoded);
211209
bool decodeString(Token& token);
212-
bool decodeString(Token& token, JSONCPP_STRING& decoded);
210+
bool decodeString(Token& token, String& decoded);
213211
bool decodeDouble(Token& token);
214212
bool decodeDouble(Token& token, Value& decoded);
215213
bool decodeUnicodeCodePoint(Token& token,
@@ -220,35 +218,33 @@ class JSON_API Reader {
220218
Location& current,
221219
Location end,
222220
unsigned int& unicode);
223-
bool addError(const JSONCPP_STRING& message,
224-
Token& token,
225-
Location extra = nullptr);
221+
bool addError(const String& message, Token& token, Location extra = nullptr);
226222
bool recoverFromError(TokenType skipUntilToken);
227-
bool addErrorAndRecover(const JSONCPP_STRING& message,
223+
bool addErrorAndRecover(const String& message,
228224
Token& token,
229225
TokenType skipUntilToken);
230226
void skipUntilSpace();
231227
Value& currentValue();
232228
Char getNextChar();
233229
void
234230
getLocationLineAndColumn(Location location, int& line, int& column) const;
235-
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
231+
String getLocationLineAndColumn(Location location) const;
236232
void addComment(Location begin, Location end, CommentPlacement placement);
237233
void skipCommentTokens(Token& token);
238234

239235
static bool containsNewLine(Location begin, Location end);
240-
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
236+
static String normalizeEOL(Location begin, Location end);
241237

242238
typedef std::stack<Value*> Nodes;
243239
Nodes nodes_;
244240
Errors errors_;
245-
JSONCPP_STRING document_;
241+
String document_;
246242
Location begin_{};
247243
Location end_{};
248244
Location current_{};
249245
Location lastValueEnd_{};
250246
Value* lastValue_{};
251-
JSONCPP_STRING commentsBefore_;
247+
String commentsBefore_;
252248
Features features_;
253249
bool collectComments_{};
254250
}; // Reader
@@ -279,7 +275,7 @@ class JSON_API CharReader {
279275
virtual bool parse(char const* beginDoc,
280276
char const* endDoc,
281277
Value* root,
282-
JSONCPP_STRING* errs) = 0;
278+
String* errs) = 0;
283279

284280
class JSON_API Factory {
285281
public:
@@ -299,7 +295,7 @@ class JSON_API CharReader {
299295
CharReaderBuilder builder;
300296
builder["collectComments"] = false;
301297
Value value;
302-
JSONCPP_STRING errs;
298+
String errs;
303299
bool ok = parseFromStream(builder, std::cin, &value, &errs);
304300
\endcode
305301
*/
@@ -359,7 +355,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
359355

360356
/** A simple way to update a specific setting.
361357
*/
362-
Value& operator[](const JSONCPP_STRING& key);
358+
Value& operator[](const String& key);
363359

364360
/** Called by ctor, but you can use this to reset settings_.
365361
* \pre 'settings' != NULL (but Json::null is fine)
@@ -380,7 +376,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
380376
* is convenient.
381377
*/
382378
bool JSON_API parseFromStream(CharReader::Factory const&,
383-
JSONCPP_ISTREAM&,
379+
IStream&,
384380
Value* root,
385381
std::string* errs);
386382

@@ -408,7 +404,7 @@ bool JSON_API parseFromStream(CharReader::Factory const&,
408404
\throw std::exception on parse error.
409405
\see Json::operator<<()
410406
*/
411-
JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
407+
JSON_API IStream& operator>>(IStream&, Value&);
412408

413409
} // namespace Json
414410

Diff for: include/json/value.h

+29-29
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ namespace Json {
5454
*/
5555
class JSON_API Exception : public std::exception {
5656
public:
57-
Exception(JSONCPP_STRING msg);
57+
Exception(String msg);
5858
~Exception() JSONCPP_NOEXCEPT override;
5959
char const* what() const JSONCPP_NOEXCEPT override;
6060

6161
protected:
62-
JSONCPP_STRING msg_;
62+
String msg_;
6363
};
6464

6565
/** Exceptions which the user cannot easily avoid.
@@ -70,7 +70,7 @@ class JSON_API Exception : public std::exception {
7070
*/
7171
class JSON_API RuntimeError : public Exception {
7272
public:
73-
RuntimeError(JSONCPP_STRING const& msg);
73+
RuntimeError(String const& msg);
7474
};
7575

7676
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
@@ -81,13 +81,13 @@ class JSON_API RuntimeError : public Exception {
8181
*/
8282
class JSON_API LogicError : public Exception {
8383
public:
84-
LogicError(JSONCPP_STRING const& msg);
84+
LogicError(String const& msg);
8585
};
8686

8787
/// used internally
88-
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
88+
JSONCPP_NORETURN void throwRuntimeError(String const& msg);
8989
/// used internally
90-
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
90+
JSONCPP_NORETURN void throwLogicError(String const& msg);
9191

9292
/** \brief Type of the value held by a Value object.
9393
*/
@@ -186,7 +186,7 @@ class JSON_API Value {
186186
friend class ValueIteratorBase;
187187

188188
public:
189-
typedef std::vector<JSONCPP_STRING> Members;
189+
typedef std::vector<String> Members;
190190
typedef ValueIterator iterator;
191191
typedef ValueConstIterator const_iterator;
192192
typedef Json::UInt UInt;
@@ -332,8 +332,8 @@ Json::Value obj_value(Json::objectValue); // {}
332332
* \endcode
333333
*/
334334
Value(const StaticString& value);
335-
Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded
336-
///< zeroes too.
335+
Value(const String& value); ///< Copy data() til size(). Embedded
336+
///< zeroes too.
337337
#ifdef JSON_USE_CPPTL
338338
Value(const CppTL::ConstString& value);
339339
#endif
@@ -377,7 +377,7 @@ Json::Value obj_value(Json::objectValue); // {}
377377
unsigned getCStringLength() const; // Allows you to understand the length of
378378
// the CString
379379
#endif
380-
JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
380+
String asString() const; ///< Embedded zeroes are possible.
381381
/** Get raw char* of string-value.
382382
* \return false if !string. (Seg-fault if str or end are NULL.)
383383
*/
@@ -484,11 +484,11 @@ Json::Value obj_value(Json::objectValue); // {}
484484
const Value& operator[](const char* key) const;
485485
/// Access an object value by name, create a null member if it does not exist.
486486
/// \param key may contain embedded nulls.
487-
Value& operator[](const JSONCPP_STRING& key);
487+
Value& operator[](const String& key);
488488
/// Access an object value by name, returns null if there is no member with
489489
/// that name.
490490
/// \param key may contain embedded nulls.
491-
const Value& operator[](const JSONCPP_STRING& key) const;
491+
const Value& operator[](const String& key) const;
492492
/** \brief Access an object value by name, create a null member if it does not
493493
exist.
494494
@@ -521,7 +521,7 @@ Json::Value obj_value(Json::objectValue); // {}
521521
/// Return the member named key if it exist, defaultValue otherwise.
522522
/// \note deep copy
523523
/// \param key may contain embedded nulls.
524-
Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
524+
Value get(const String& key, const Value& defaultValue) const;
525525
#ifdef JSON_USE_CPPTL
526526
/// Return the member named key if it exist, defaultValue otherwise.
527527
/// \note deep copy
@@ -543,7 +543,7 @@ Json::Value obj_value(Json::objectValue); // {}
543543
void removeMember(const char* key);
544544
/// Same as removeMember(const char*)
545545
/// \param key may contain embedded nulls.
546-
void removeMember(const JSONCPP_STRING& key);
546+
void removeMember(const String& key);
547547
/// Same as removeMember(const char* begin, const char* end, Value* removed),
548548
/// but 'key' is null-terminated.
549549
bool removeMember(const char* key, Value* removed);
@@ -553,8 +553,8 @@ Json::Value obj_value(Json::objectValue); // {}
553553
\param key may contain embedded nulls.
554554
\return true iff removed (no exceptions)
555555
*/
556-
bool removeMember(JSONCPP_STRING const& key, Value* removed);
557-
/// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
556+
bool removeMember(String const& key, Value* removed);
557+
/// Same as removeMember(String const& key, Value* removed)
558558
bool removeMember(const char* begin, const char* end, Value* removed);
559559
/** \brief Remove the indexed array element.
560560
@@ -569,8 +569,8 @@ Json::Value obj_value(Json::objectValue); // {}
569569
bool isMember(const char* key) const;
570570
/// Return true if the object has a member named key.
571571
/// \param key may contain embedded nulls.
572-
bool isMember(const JSONCPP_STRING& key) const;
573-
/// Same as isMember(JSONCPP_STRING const& key)const
572+
bool isMember(const String& key) const;
573+
/// Same as isMember(String const& key)const
574574
bool isMember(const char* begin, const char* end) const;
575575
#ifdef JSON_USE_CPPTL
576576
/// Return true if the object has a member named key.
@@ -590,17 +590,17 @@ Json::Value obj_value(Json::objectValue); // {}
590590
//# endif
591591

592592
/// \deprecated Always pass len.
593-
JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
593+
JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
594594
void setComment(const char* comment, CommentPlacement placement);
595595
/// Comments must be //... or /* ... */
596596
void setComment(const char* comment, size_t len, CommentPlacement placement);
597597
/// Comments must be //... or /* ... */
598-
void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
598+
void setComment(const String& comment, CommentPlacement placement);
599599
bool hasComment(CommentPlacement placement) const;
600600
/// Include delimiters and embedded newlines.
601-
JSONCPP_STRING getComment(CommentPlacement placement) const;
601+
String getComment(CommentPlacement placement) const;
602602

603-
JSONCPP_STRING toStyledString() const;
603+
String toStyledString() const;
604604

605605
const_iterator begin() const;
606606
const_iterator end() const;
@@ -673,11 +673,11 @@ class JSON_API PathArgument {
673673
PathArgument();
674674
PathArgument(ArrayIndex index);
675675
PathArgument(const char* key);
676-
PathArgument(const JSONCPP_STRING& key);
676+
PathArgument(const String& key);
677677

678678
private:
679679
enum Kind { kindNone = 0, kindIndex, kindKey };
680-
JSONCPP_STRING key_;
680+
String key_;
681681
ArrayIndex index_{};
682682
Kind kind_{ kindNone };
683683
};
@@ -695,7 +695,7 @@ class JSON_API PathArgument {
695695
*/
696696
class JSON_API Path {
697697
public:
698-
Path(const JSONCPP_STRING& path,
698+
Path(const String& path,
699699
const PathArgument& a1 = PathArgument(),
700700
const PathArgument& a2 = PathArgument(),
701701
const PathArgument& a3 = PathArgument(),
@@ -712,12 +712,12 @@ class JSON_API Path {
712712
typedef std::vector<const PathArgument*> InArgs;
713713
typedef std::vector<PathArgument> Args;
714714

715-
void makePath(const JSONCPP_STRING& path, const InArgs& in);
716-
void addPathInArg(const JSONCPP_STRING& path,
715+
void makePath(const String& path, const InArgs& in);
716+
void addPathInArg(const String& path,
717717
const InArgs& in,
718718
InArgs::const_iterator& itInArg,
719719
PathArgument::Kind kind);
720-
static void invalidPath(const JSONCPP_STRING& path, int location);
720+
static void invalidPath(const String& path, int location);
721721

722722
Args args_;
723723
};
@@ -751,7 +751,7 @@ class JSON_API ValueIteratorBase {
751751
/// Return the member name of the referenced Value, or "" if it is not an
752752
/// objectValue.
753753
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
754-
JSONCPP_STRING name() const;
754+
String name() const;
755755

756756
/// Return the member name of the referenced Value. "" if it is not an
757757
/// objectValue.

0 commit comments

Comments
 (0)