Skip to content

Commit 75570d7

Browse files
dawesccdunn2001
authored andcommitted
Fixing up for #define instead of typedef in secure allocators
1 parent 5da29e2 commit 75570d7

File tree

10 files changed

+327
-299
lines changed

10 files changed

+327
-299
lines changed

Diff for: include/json/reader.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class JSON_API Reader {
4444
struct StructuredError {
4545
ptrdiff_t offset_start;
4646
ptrdiff_t offset_limit;
47-
std::string message;
47+
JSONCPP_STRING message;
4848
};
4949

5050
/** \brief Constructs a Reader allowing all features
@@ -111,7 +111,7 @@ class JSON_API Reader {
111111
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
112112
*/
113113
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
114-
std::string getFormatedErrorMessages() const;
114+
JSONCPP_STRING getFormatedErrorMessages() const;
115115

116116
/** \brief Returns a user friendly string that list errors in the parsed
117117
* document.
@@ -121,7 +121,7 @@ class JSON_API Reader {
121121
* occurred
122122
* during parsing.
123123
*/
124-
std::string getFormattedErrorMessages() const;
124+
JSONCPP_STRING getFormattedErrorMessages() const;
125125

126126
/** \brief Returns a vector of structured erros encounted while parsing.
127127
* \return A (possibly empty) vector of StructuredError objects. Currently
@@ -138,7 +138,7 @@ class JSON_API Reader {
138138
* \return \c true if the error was successfully added, \c false if the
139139
* Value offset exceeds the document size.
140140
*/
141-
bool pushError(const Value& value, const std::string& message);
141+
bool pushError(const Value& value, const JSONCPP_STRING& message);
142142

143143
/** \brief Add a semantic error message with extra context.
144144
* \param value JSON Value location associated with the error
@@ -147,7 +147,7 @@ class JSON_API Reader {
147147
* \return \c true if the error was successfully added, \c false if either
148148
* Value offset exceeds the document size.
149149
*/
150-
bool pushError(const Value& value, const std::string& message, const Value& extra);
150+
bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
151151

152152
/** \brief Return whether there are any errors.
153153
* \return \c true if there are no errors to report \c false if
@@ -183,7 +183,7 @@ class JSON_API Reader {
183183
class ErrorInfo {
184184
public:
185185
Token token_;
186-
std::string message_;
186+
JSONCPP_STRING message_;
187187
Location extra_;
188188
};
189189

@@ -203,7 +203,7 @@ class JSON_API Reader {
203203
bool decodeNumber(Token& token);
204204
bool decodeNumber(Token& token, Value& decoded);
205205
bool decodeString(Token& token);
206-
bool decodeString(Token& token, std::string& decoded);
206+
bool decodeString(Token& token, JSONCPP_STRING& decoded);
207207
bool decodeDouble(Token& token);
208208
bool decodeDouble(Token& token, Value& decoded);
209209
bool decodeUnicodeCodePoint(Token& token,
@@ -214,30 +214,30 @@ class JSON_API Reader {
214214
Location& current,
215215
Location end,
216216
unsigned int& unicode);
217-
bool addError(const std::string& message, Token& token, Location extra = 0);
217+
bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
218218
bool recoverFromError(TokenType skipUntilToken);
219-
bool addErrorAndRecover(const std::string& message,
219+
bool addErrorAndRecover(const JSONCPP_STRING& message,
220220
Token& token,
221221
TokenType skipUntilToken);
222222
void skipUntilSpace();
223223
Value& currentValue();
224224
Char getNextChar();
225225
void
226226
getLocationLineAndColumn(Location location, int& line, int& column) const;
227-
std::string getLocationLineAndColumn(Location location) const;
227+
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
228228
void addComment(Location begin, Location end, CommentPlacement placement);
229229
void skipCommentTokens(Token& token);
230230

231231
typedef std::stack<Value*> Nodes;
232232
Nodes nodes_;
233233
Errors errors_;
234-
std::string document_;
234+
JSONCPP_STRING document_;
235235
Location begin_;
236236
Location end_;
237237
Location current_;
238238
Location lastValueEnd_;
239239
Value* lastValue_;
240-
std::string commentsBefore_;
240+
JSONCPP_STRING commentsBefore_;
241241
Features features_;
242242
bool collectComments_;
243243
}; // Reader
@@ -266,7 +266,7 @@ class JSON_API CharReader {
266266
*/
267267
virtual bool parse(
268268
char const* beginDoc, char const* endDoc,
269-
Value* root, std::string* errs) = 0;
269+
Value* root, JSONCPP_STRING* errs) = 0;
270270

271271
class JSON_API Factory {
272272
public:
@@ -286,7 +286,7 @@ class JSON_API CharReader {
286286
CharReaderBuilder builder;
287287
builder["collectComments"] = false;
288288
Value value;
289-
std::string errs;
289+
JSONCPP_STRING errs;
290290
bool ok = parseFromStream(builder, std::cin, &value, &errs);
291291
\endcode
292292
*/
@@ -344,7 +344,7 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
344344

345345
/** A simple way to update a specific setting.
346346
*/
347-
Value& operator[](std::string key);
347+
Value& operator[](JSONCPP_STRING key);
348348

349349
/** Called by ctor, but you can use this to reset settings_.
350350
* \pre 'settings' != NULL (but Json::null is fine)

Diff for: include/json/writer.h

+26-26
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class JSON_API StreamWriter {
6666
/** \brief Write into stringstream, then return string, for convenience.
6767
* A StreamWriter will be created from the factory, used, and then deleted.
6868
*/
69-
std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
69+
JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
7070

7171

7272
/** \brief Build a StreamWriter implementation.
@@ -125,7 +125,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
125125
bool validate(Json::Value* invalid) const;
126126
/** A simple way to update a specific setting.
127127
*/
128-
Value& operator[](std::string key);
128+
Value& operator[](JSONCPP_STRING key);
129129

130130
/** Called by ctor, but you can use this to reset settings_.
131131
* \pre 'settings' != NULL (but Json::null is fine)
@@ -142,7 +142,7 @@ class JSON_API Writer {
142142
public:
143143
virtual ~Writer();
144144

145-
virtual std::string write(const Value& root) = 0;
145+
virtual JSONCPP_STRING write(const Value& root) = 0;
146146
};
147147

148148
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
@@ -172,12 +172,12 @@ class JSON_API FastWriter : public Writer {
172172
void omitEndingLineFeed();
173173

174174
public: // overridden from Writer
175-
std::string write(const Value& root) override;
175+
JSONCPP_STRING write(const Value& root) override;
176176

177177
private:
178178
void writeValue(const Value& value);
179179

180-
std::string document_;
180+
JSONCPP_STRING document_;
181181
bool yamlCompatiblityEnabled_;
182182
bool dropNullPlaceholders_;
183183
bool omitEndingLineFeed_;
@@ -217,27 +217,27 @@ class JSON_API StyledWriter : public Writer {
217217
* \param root Value to serialize.
218218
* \return String containing the JSON document that represents the root value.
219219
*/
220-
std::string write(const Value& root) override;
220+
JSONCPP_STRING write(const Value& root) override;
221221

222222
private:
223223
void writeValue(const Value& value);
224224
void writeArrayValue(const Value& value);
225225
bool isMultineArray(const Value& value);
226-
void pushValue(const std::string& value);
226+
void pushValue(const JSONCPP_STRING& value);
227227
void writeIndent();
228-
void writeWithIndent(const std::string& value);
228+
void writeWithIndent(const JSONCPP_STRING& value);
229229
void indent();
230230
void unindent();
231231
void writeCommentBeforeValue(const Value& root);
232232
void writeCommentAfterValueOnSameLine(const Value& root);
233233
bool hasCommentForValue(const Value& value);
234-
static std::string normalizeEOL(const std::string& text);
234+
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
235235

236-
typedef std::vector<std::string> ChildValues;
236+
typedef std::vector<JSONCPP_STRING> ChildValues;
237237

238238
ChildValues childValues_;
239-
std::string document_;
240-
std::string indentString_;
239+
JSONCPP_STRING document_;
240+
JSONCPP_STRING indentString_;
241241
unsigned int rightMargin_;
242242
unsigned int indentSize_;
243243
bool addChildValues_;
@@ -271,7 +271,7 @@ class JSON_API StyledWriter : public Writer {
271271
*/
272272
class JSON_API StyledStreamWriter {
273273
public:
274-
StyledStreamWriter(std::string indentation = "\t");
274+
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
275275
~StyledStreamWriter() {}
276276

277277
public:
@@ -287,36 +287,36 @@ class JSON_API StyledStreamWriter {
287287
void writeValue(const Value& value);
288288
void writeArrayValue(const Value& value);
289289
bool isMultineArray(const Value& value);
290-
void pushValue(const std::string& value);
290+
void pushValue(const JSONCPP_STRING& value);
291291
void writeIndent();
292-
void writeWithIndent(const std::string& value);
292+
void writeWithIndent(const JSONCPP_STRING& value);
293293
void indent();
294294
void unindent();
295295
void writeCommentBeforeValue(const Value& root);
296296
void writeCommentAfterValueOnSameLine(const Value& root);
297297
bool hasCommentForValue(const Value& value);
298-
static std::string normalizeEOL(const std::string& text);
298+
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
299299

300-
typedef std::vector<std::string> ChildValues;
300+
typedef std::vector<JSONCPP_STRING> ChildValues;
301301

302302
ChildValues childValues_;
303303
JSONCPP_OSTREAM* document_;
304-
std::string indentString_;
304+
JSONCPP_STRING indentString_;
305305
unsigned int rightMargin_;
306-
std::string indentation_;
306+
JSONCPP_STRING indentation_;
307307
bool addChildValues_ : 1;
308308
bool indented_ : 1;
309309
};
310310

311311
#if defined(JSON_HAS_INT64)
312-
std::string JSON_API valueToString(Int value);
313-
std::string JSON_API valueToString(UInt value);
312+
JSONCPP_STRING JSON_API valueToString(Int value);
313+
JSONCPP_STRING JSON_API valueToString(UInt value);
314314
#endif // if defined(JSON_HAS_INT64)
315-
std::string JSON_API valueToString(LargestInt value);
316-
std::string JSON_API valueToString(LargestUInt value);
317-
std::string JSON_API valueToString(double value);
318-
std::string JSON_API valueToString(bool value);
319-
std::string JSON_API valueToQuotedString(const char* value);
315+
JSONCPP_STRING JSON_API valueToString(LargestInt value);
316+
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
317+
JSONCPP_STRING JSON_API valueToString(double value);
318+
JSONCPP_STRING JSON_API valueToString(bool value);
319+
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
320320

321321
/// \brief Output using the StyledStreamWriter.
322322
/// \see Json::operator>>()

0 commit comments

Comments
 (0)