Fix different names for parameters in declaration and definition

This commit is contained in:
Marian Klymov 2018-06-02 20:15:26 +03:00
parent 091e03979d
commit fc20134c92
5 changed files with 57 additions and 57 deletions

View File

@ -427,12 +427,12 @@ Json::Value obj_value(Json::objectValue); // {}
/// \post type() is unchanged /// \post type() is unchanged
void clear(); void clear();
/// Resize the array to size elements. /// Resize the array to newSize elements.
/// New elements are initialized to null. /// New elements are initialized to null.
/// May only be called on nullValue or arrayValue. /// May only be called on nullValue or arrayValue.
/// \pre type() is arrayValue or nullValue /// \pre type() is arrayValue or nullValue
/// \post type() is arrayValue /// \post type() is arrayValue
void resize(ArrayIndex size); void resize(ArrayIndex newSize);
/// Access an array element (zero based index ). /// Access an array element (zero based index ).
/// If the array contains less than index element, then null value are /// If the array contains less than index element, then null value are
@ -562,10 +562,10 @@ Json::Value obj_value(Json::objectValue); // {}
/** \brief Remove the indexed array element. /** \brief Remove the indexed array element.
O(n) expensive operations. O(n) expensive operations.
Update 'removed' iff removed. Update 'removed' if removed.
\return true iff removed (no exceptions) \return true if removed (no exceptions)
*/ */
bool removeIndex(ArrayIndex i, Value* removed); bool removeIndex(ArrayIndex index, Value* removed);
/// Return true if the object has a member named key. /// Return true if the object has a member named key.
/// \note 'key' must be null-terminated. /// \note 'key' must be null-terminated.

View File

@ -112,8 +112,8 @@ bool Reader::parse(const std::string& document,
return parse(begin, end, root, collectComments); return parse(begin, end, root, collectComments);
} }
bool Reader::parse(std::istream& sin, Value& root, bool collectComments) { bool Reader::parse(std::istream& is, Value& root, bool collectComments) {
// std::istream_iterator<char> begin(sin); // std::istream_iterator<char> begin(is);
// std::istream_iterator<char> end; // std::istream_iterator<char> end;
// Those would allow streamed input from a file, if parse() were a // Those would allow streamed input from a file, if parse() were a
// template function. // template function.
@ -121,7 +121,7 @@ bool Reader::parse(std::istream& sin, Value& root, bool collectComments) {
// Since JSONCPP_STRING is reference-counted, this at least does not // Since JSONCPP_STRING is reference-counted, this at least does not
// create an extra copy. // create an extra copy.
JSONCPP_STRING doc; JSONCPP_STRING doc;
std::getline(sin, doc, (char)EOF); std::getline(is, doc, (char)EOF);
return parse(doc.data(), doc.data() + doc.size(), root, collectComments); return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
} }
@ -460,12 +460,12 @@ bool Reader::readString() {
return c == '"'; return c == '"';
} }
bool Reader::readObject(Token& tokenStart) { bool Reader::readObject(Token& token) {
Token tokenName; Token tokenName;
JSONCPP_STRING name; JSONCPP_STRING name;
Value init(objectValue); Value init(objectValue);
currentValue().swapPayload(init); currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
while (readToken(tokenName)) { while (readToken(tokenName)) {
bool initialTokenOk = true; bool initialTokenOk = true;
while (tokenName.type_ == tokenComment && initialTokenOk) while (tokenName.type_ == tokenComment && initialTokenOk)
@ -516,10 +516,10 @@ bool Reader::readObject(Token& tokenStart) {
tokenObjectEnd); tokenObjectEnd);
} }
bool Reader::readArray(Token& tokenStart) { bool Reader::readArray(Token& token) {
Value init(arrayValue); Value init(arrayValue);
currentValue().swapPayload(init); currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
skipSpaces(); skipSpaces();
if (current_ != end_ && *current_ == ']') // empty array if (current_ != end_ && *current_ == ']') // empty array
{ {
@ -536,19 +536,19 @@ bool Reader::readArray(Token& tokenStart) {
if (!ok) // error already set if (!ok) // error already set
return recoverFromError(tokenArrayEnd); return recoverFromError(tokenArrayEnd);
Token token; Token currentToken;
// Accept Comment after last item in the array. // Accept Comment after last item in the array.
ok = readToken(token); ok = readToken(currentToken);
while (token.type_ == tokenComment && ok) { while (currentToken.type_ == tokenComment && ok) {
ok = readToken(token); ok = readToken(currentToken);
} }
bool badTokenType = bool badTokenType =
(token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); (currentToken.type_ != tokenArraySeparator && currentToken.type_ != tokenArrayEnd);
if (!ok || badTokenType) { if (!ok || badTokenType) {
return addErrorAndRecover("Missing ',' or ']' in array declaration", return addErrorAndRecover("Missing ',' or ']' in array declaration",
token, tokenArrayEnd); currentToken, tokenArrayEnd);
} }
if (token.type_ == tokenArrayEnd) if (currentToken.type_ == tokenArrayEnd)
break; break;
} }
return true; return true;
@ -1450,12 +1450,12 @@ bool OurReader::readStringSingleQuote() {
return c == '\''; return c == '\'';
} }
bool OurReader::readObject(Token& tokenStart) { bool OurReader::readObject(Token& token) {
Token tokenName; Token tokenName;
JSONCPP_STRING name; JSONCPP_STRING name;
Value init(objectValue); Value init(objectValue);
currentValue().swapPayload(init); currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
while (readToken(tokenName)) { while (readToken(tokenName)) {
bool initialTokenOk = true; bool initialTokenOk = true;
while (tokenName.type_ == tokenComment && initialTokenOk) while (tokenName.type_ == tokenComment && initialTokenOk)
@ -1512,10 +1512,10 @@ bool OurReader::readObject(Token& tokenStart) {
tokenObjectEnd); tokenObjectEnd);
} }
bool OurReader::readArray(Token& tokenStart) { bool OurReader::readArray(Token& token) {
Value init(arrayValue); Value init(arrayValue);
currentValue().swapPayload(init); currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(token.start_ - begin_);
skipSpaces(); skipSpaces();
if (current_ != end_ && *current_ == ']') // empty array if (current_ != end_ && *current_ == ']') // empty array
{ {
@ -1532,19 +1532,19 @@ bool OurReader::readArray(Token& tokenStart) {
if (!ok) // error already set if (!ok) // error already set
return recoverFromError(tokenArrayEnd); return recoverFromError(tokenArrayEnd);
Token token; Token currentToken;
// Accept Comment after last item in the array. // Accept Comment after last item in the array.
ok = readToken(token); ok = readToken(currentToken);
while (token.type_ == tokenComment && ok) { while (currentToken.type_ == tokenComment && ok) {
ok = readToken(token); ok = readToken(currentToken);
} }
bool badTokenType = bool badTokenType =
(token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); (currentToken.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
if (!ok || badTokenType) { if (!ok || badTokenType) {
return addErrorAndRecover("Missing ',' or ']' in array declaration", return addErrorAndRecover("Missing ',' or ']' in array declaration",
token, tokenArrayEnd); currentToken, tokenArrayEnd);
} }
if (token.type_ == tokenArrayEnd) if (currentToken.type_ == tokenArrayEnd)
break; break;
} }
return true; return true;

View File

@ -241,15 +241,15 @@ void Value::CommentInfo::setComment(const char* text, size_t len) {
// Notes: policy_ indicates if the string was allocated when // Notes: policy_ indicates if the string was allocated when
// a string is stored. // a string is stored.
Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {} Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {}
Value::CZString::CZString(char const* str, Value::CZString::CZString(char const* str,
unsigned ulength, unsigned length,
DuplicationPolicy allocate) DuplicationPolicy allocate)
: cstr_(str) { : cstr_(str) {
// allocate != duplicate // allocate != duplicate
storage_.policy_ = allocate & 0x3; storage_.policy_ = allocate & 0x3;
storage_.length_ = ulength & 0x3FFFFFFF; storage_.length_ = length & 0x3FFFFFFF;
} }
Value::CZString::CZString(const CZString& other) { Value::CZString::CZString(const CZString& other) {
@ -357,10 +357,10 @@ bool Value::CZString::isStaticString() const {
* memset( this, 0, sizeof(Value) ) * memset( this, 0, sizeof(Value) )
* This optimization is used in ValueInternalMap fast allocator. * This optimization is used in ValueInternalMap fast allocator.
*/ */
Value::Value(ValueType vtype) { Value::Value(ValueType type) {
static char const emptyString[] = ""; static char const emptyString[] = "";
initBasic(vtype); initBasic(type);
switch (vtype) { switch (type) {
case nullValue: case nullValue:
break; break;
case intValue: case intValue:
@ -418,10 +418,10 @@ Value::Value(const char* value) {
value, static_cast<unsigned>(strlen(value))); value, static_cast<unsigned>(strlen(value)));
} }
Value::Value(const char* beginValue, const char* endValue) { Value::Value(const char* begin, const char* end) {
initBasic(stringValue, true); initBasic(stringValue, true);
value_.string_ = duplicateAndPrefixStringValue( value_.string_ = duplicateAndPrefixStringValue(
beginValue, static_cast<unsigned>(endValue - beginValue)); begin, static_cast<unsigned>(end - begin));
} }
Value::Value(const JSONCPP_STRING& value) { Value::Value(const JSONCPP_STRING& value) {
@ -645,14 +645,14 @@ unsigned Value::getCStringLength() const {
} }
#endif #endif
bool Value::getString(char const** str, char const** cend) const { bool Value::getString(char const** begin, char const** end) const {
if (type_ != stringValue) if (type_ != stringValue)
return false; return false;
if (value_.string_ == 0) if (value_.string_ == 0)
return false; return false;
unsigned length; unsigned length;
decodePrefixedString(this->allocated_, this->value_.string_, &length, str); decodePrefixedString(this->allocated_, this->value_.string_, &length, begin);
*cend = *str + length; *end = *begin + length;
return true; return true;
} }
@ -1003,8 +1003,8 @@ const Value& Value::operator[](int index) const {
return (*this)[ArrayIndex(index)]; return (*this)[ArrayIndex(index)];
} }
void Value::initBasic(ValueType vtype, bool allocated) { void Value::initBasic(ValueType type, bool allocated) {
type_ = vtype; type_ = type;
allocated_ = allocated; allocated_ = allocated;
comments_ = 0; comments_ = 0;
start_ = 0; start_ = 0;
@ -1101,13 +1101,13 @@ Value& Value::resolveReference(const char* key) {
} }
// @param key is not null-terminated. // @param key is not null-terminated.
Value& Value::resolveReference(char const* key, char const* cend) { Value& Value::resolveReference(char const* key, char const* end) {
JSON_ASSERT_MESSAGE( JSON_ASSERT_MESSAGE(
type_ == nullValue || type_ == objectValue, type_ == nullValue || type_ == objectValue,
"in Json::Value::resolveReference(key, end): requires objectValue"); "in Json::Value::resolveReference(key, end): requires objectValue");
if (type_ == nullValue) if (type_ == nullValue)
*this = Value(objectValue); *this = Value(objectValue);
CZString actualKey(key, static_cast<unsigned>(cend - key), CZString actualKey(key, static_cast<unsigned>(end - key),
CZString::duplicateOnCopy); CZString::duplicateOnCopy);
ObjectValues::iterator it = value_.map_->lower_bound(actualKey); ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
if (it != value_.map_->end() && (*it).first == actualKey) if (it != value_.map_->end() && (*it).first == actualKey)
@ -1126,13 +1126,13 @@ Value Value::get(ArrayIndex index, const Value& defaultValue) const {
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); } bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
Value const* Value::find(char const* key, char const* cend) const { Value const* Value::find(char const* begin, char const* end) const {
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue, JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
"in Json::Value::find(key, end, found): requires " "in Json::Value::find(key, end, found): requires "
"objectValue or nullValue"); "objectValue or nullValue");
if (type_ == nullValue) if (type_ == nullValue)
return NULL; return NULL;
CZString actualKey(key, static_cast<unsigned>(cend - key), CZString actualKey(begin, static_cast<unsigned>(end - begin),
CZString::noDuplication); CZString::noDuplication);
ObjectValues::const_iterator it = value_.map_->find(actualKey); ObjectValues::const_iterator it = value_.map_->find(actualKey);
if (it == value_.map_->end()) if (it == value_.map_->end())
@ -1184,10 +1184,10 @@ Value& Value::append(Value&& value) {
} }
#endif #endif
Value Value::get(char const* key, Value Value::get(char const* begin,
char const* cend, char const* end,
Value const& defaultValue) const { Value const& defaultValue) const {
Value const* found = find(key, cend); Value const* found = find(begin, end);
return !found ? defaultValue : *found; return !found ? defaultValue : *found;
} }
Value Value::get(char const* key, Value const& defaultValue) const { Value Value::get(char const* key, Value const& defaultValue) const {
@ -1197,11 +1197,11 @@ Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const {
return get(key.data(), key.data() + key.length(), defaultValue); return get(key.data(), key.data() + key.length(), defaultValue);
} }
bool Value::removeMember(const char* key, const char* cend, Value* removed) { bool Value::removeMember(const char* begin, const char* end, Value* removed) {
if (type_ != objectValue) { if (type_ != objectValue) {
return false; return false;
} }
CZString actualKey(key, static_cast<unsigned>(cend - key), CZString actualKey(begin, static_cast<unsigned>(end - begin),
CZString::noDuplication); CZString::noDuplication);
ObjectValues::iterator it = value_.map_->find(actualKey); ObjectValues::iterator it = value_.map_->find(actualKey);
if (it == value_.map_->end()) if (it == value_.map_->end())
@ -1264,8 +1264,8 @@ Value Value::get(const CppTL::ConstString& key,
} }
#endif #endif
bool Value::isMember(char const* key, char const* cend) const { bool Value::isMember(char const* begin, char const* end) const {
Value const* value = find(key, cend); Value const* value = find(begin, end);
return NULL != value; return NULL != value;
} }
bool Value::isMember(char const* key) const { bool Value::isMember(char const* key) const {

View File

@ -1245,10 +1245,10 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings) {
//! [StreamWriterBuilderDefaults] //! [StreamWriterBuilderDefaults]
} }
JSONCPP_STRING writeString(StreamWriter::Factory const& builder, JSONCPP_STRING writeString(StreamWriter::Factory const& factory,
Value const& root) { Value const& root) {
JSONCPP_OSTRINGSTREAM sout; JSONCPP_OSTRINGSTREAM sout;
StreamWriterPtr const writer(builder.newStreamWriter()); StreamWriterPtr const writer(factory.newStreamWriter());
writer->write(root, &sout); writer->write(root, &sout);
return sout.str(); return sout.str();
} }

View File

@ -167,7 +167,7 @@ private: // prevents copy construction and assignment
private: private:
void listTests() const; void listTests() const;
bool testIndex(const JSONCPP_STRING& testName, unsigned int& index) const; bool testIndex(const JSONCPP_STRING& testName, unsigned int& indexOut) const;
static void preventDialogOnCrash(); static void preventDialogOnCrash();
private: private: