mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-26 18:51:04 +08:00
clang-tidy cleanups 2 (#1048)
* [clang-tidy] Add explicit to single argument constructor Found with hicpp-explicit-conversions Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Fix mismatching declaration Found with readability-inconsistent-declaration-parameter-name Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Replace {} with = default Found with modernize-use-equals-default Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Remove redundant .c_Str Found with readability-redundant-string-cstr Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Simplify boolean expressions Found with readability-simplify-boolean-expr Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Use std::move Found with modernize-pass-by-value Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Uppercase literal suffixes Found with hicpp-uppercase-literal-suffix Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
7329223f58
commit
bcad4e4de2
@ -657,7 +657,7 @@ private:
|
|||||||
Comments& operator=(Comments&& that);
|
Comments& operator=(Comments&& that);
|
||||||
bool has(CommentPlacement slot) const;
|
bool has(CommentPlacement slot) const;
|
||||||
String get(CommentPlacement slot) const;
|
String get(CommentPlacement slot) const;
|
||||||
void set(CommentPlacement slot, String s);
|
void set(CommentPlacement slot, String comment);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Array = std::array<String, numberOfCommentPlacement>;
|
using Array = std::array<String, numberOfCommentPlacement>;
|
||||||
@ -681,7 +681,7 @@ public:
|
|||||||
PathArgument();
|
PathArgument();
|
||||||
PathArgument(ArrayIndex index);
|
PathArgument(ArrayIndex index);
|
||||||
PathArgument(const char* key);
|
PathArgument(const char* key);
|
||||||
PathArgument(const String& key);
|
PathArgument(String key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Kind { kindNone = 0, kindIndex, kindKey };
|
enum Kind { kindNone = 0, kindIndex, kindKey };
|
||||||
|
@ -889,7 +889,7 @@ public:
|
|||||||
String message;
|
String message;
|
||||||
};
|
};
|
||||||
|
|
||||||
OurReader(OurFeatures const& features);
|
explicit OurReader(OurFeatures const& features);
|
||||||
bool parse(const char* beginDoc, const char* endDoc, Value& root,
|
bool parse(const char* beginDoc, const char* endDoc, Value& root,
|
||||||
bool collectComments = true);
|
bool collectComments = true);
|
||||||
String getFormattedErrorMessages() const;
|
String getFormattedErrorMessages() const;
|
||||||
|
@ -203,7 +203,7 @@ namespace Json {
|
|||||||
|
|
||||||
#if JSON_USE_EXCEPTION
|
#if JSON_USE_EXCEPTION
|
||||||
Exception::Exception(String msg) : msg_(std::move(msg)) {}
|
Exception::Exception(String msg) : msg_(std::move(msg)) {}
|
||||||
Exception::~Exception() JSONCPP_NOEXCEPT {}
|
Exception::~Exception() JSONCPP_NOEXCEPT = default;
|
||||||
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
|
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
|
||||||
RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
|
RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
|
||||||
LogicError::LogicError(String const& msg) : Exception(msg) {}
|
LogicError::LogicError(String const& msg) : Exception(msg) {}
|
||||||
@ -263,7 +263,7 @@ Value::CZString::CZString(CZString&& other)
|
|||||||
Value::CZString::~CZString() {
|
Value::CZString::~CZString() {
|
||||||
if (cstr_ && storage_.policy_ == duplicate) {
|
if (cstr_ && storage_.policy_ == duplicate) {
|
||||||
releaseStringValue(const_cast<char*>(cstr_),
|
releaseStringValue(const_cast<char*>(cstr_),
|
||||||
storage_.length_ + 1u); // +1 for null terminating
|
storage_.length_ + 1U); // +1 for null terminating
|
||||||
// character for sake of
|
// character for sake of
|
||||||
// completeness but not actually
|
// completeness but not actually
|
||||||
// necessary
|
// necessary
|
||||||
@ -494,7 +494,7 @@ int Value::compare(const Value& other) const {
|
|||||||
bool Value::operator<(const Value& other) const {
|
bool Value::operator<(const Value& other) const {
|
||||||
int typeDelta = type() - other.type();
|
int typeDelta = type() - other.type();
|
||||||
if (typeDelta)
|
if (typeDelta)
|
||||||
return typeDelta < 0 ? true : false;
|
return typeDelta < 0;
|
||||||
switch (type()) {
|
switch (type()) {
|
||||||
case nullValue:
|
case nullValue:
|
||||||
return false;
|
return false;
|
||||||
@ -508,10 +508,7 @@ bool Value::operator<(const Value& other) const {
|
|||||||
return value_.bool_ < other.value_.bool_;
|
return value_.bool_ < other.value_.bool_;
|
||||||
case stringValue: {
|
case stringValue: {
|
||||||
if ((value_.string_ == nullptr) || (other.value_.string_ == nullptr)) {
|
if ((value_.string_ == nullptr) || (other.value_.string_ == nullptr)) {
|
||||||
if (other.value_.string_)
|
return other.value_.string_ != nullptr;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
unsigned this_len;
|
unsigned this_len;
|
||||||
unsigned other_len;
|
unsigned other_len;
|
||||||
@ -809,7 +806,7 @@ float Value::asFloat() const {
|
|||||||
case nullValue:
|
case nullValue:
|
||||||
return 0.0;
|
return 0.0;
|
||||||
case booleanValue:
|
case booleanValue:
|
||||||
return value_.bool_ ? 1.0f : 0.0f;
|
return value_.bool_ ? 1.0F : 0.0F;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -823,9 +820,9 @@ bool Value::asBool() const {
|
|||||||
case nullValue:
|
case nullValue:
|
||||||
return false;
|
return false;
|
||||||
case intValue:
|
case intValue:
|
||||||
return value_.int_ ? true : false;
|
return value_.int_ != 0;
|
||||||
case uintValue:
|
case uintValue:
|
||||||
return value_.uint_ ? true : false;
|
return value_.uint_ != 0;
|
||||||
case realValue: {
|
case realValue: {
|
||||||
// According to JavaScript language zero or NaN is regarded as false
|
// According to JavaScript language zero or NaN is regarded as false
|
||||||
const auto value_classification = std::fpclassify(value_.real_);
|
const auto value_classification = std::fpclassify(value_.real_);
|
||||||
@ -841,7 +838,7 @@ bool Value::isConvertibleTo(ValueType other) const {
|
|||||||
switch (other) {
|
switch (other) {
|
||||||
case nullValue:
|
case nullValue:
|
||||||
return (isNumeric() && asDouble() == 0.0) ||
|
return (isNumeric() && asDouble() == 0.0) ||
|
||||||
(type() == booleanValue && value_.bool_ == false) ||
|
(type() == booleanValue && !value_.bool_) ||
|
||||||
(type() == stringValue && asString().empty()) ||
|
(type() == stringValue && asString().empty()) ||
|
||||||
(type() == arrayValue && value_.map_->empty()) ||
|
(type() == arrayValue && value_.map_->empty()) ||
|
||||||
(type() == objectValue && value_.map_->empty()) ||
|
(type() == objectValue && value_.map_->empty()) ||
|
||||||
@ -896,7 +893,7 @@ ArrayIndex Value::size() const {
|
|||||||
|
|
||||||
bool Value::empty() const {
|
bool Value::empty() const {
|
||||||
if (isNull() || isArray() || isObject())
|
if (isNull() || isArray() || isObject())
|
||||||
return size() == 0u;
|
return size() == 0U;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1545,15 +1542,14 @@ Value::iterator Value::end() {
|
|||||||
// class PathArgument
|
// class PathArgument
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PathArgument::PathArgument() {}
|
PathArgument::PathArgument() = default;
|
||||||
|
|
||||||
PathArgument::PathArgument(ArrayIndex index)
|
PathArgument::PathArgument(ArrayIndex index)
|
||||||
: index_(index), kind_(kindIndex) {}
|
: index_(index), kind_(kindIndex) {}
|
||||||
|
|
||||||
PathArgument::PathArgument(const char* key) : key_(key), kind_(kindKey) {}
|
PathArgument::PathArgument(const char* key) : key_(key), kind_(kindKey) {}
|
||||||
|
|
||||||
PathArgument::PathArgument(const String& key)
|
PathArgument::PathArgument(String key) : key_(std::move(key)), kind_(kindKey) {}
|
||||||
: key_(key.c_str()), kind_(kindKey) {}
|
|
||||||
|
|
||||||
// class Path
|
// class Path
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user