mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-05-30 06:42:39 +02:00
STYLE: Pefer = default to explicitly trivial implementations
This check replaces default bodies of special member functions with = default;. The explicitly defaulted function declarations enable more opportunities in optimization, because the compiler might treat explicitly defaulted functions as trivial. Additionally, the C++11 use of = default more clearly expreses the intent for the special member functions. SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/ run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-default -header-filter=.* -fix
This commit is contained in:
parent
e817e4fc25
commit
e3e05c7085
@ -256,7 +256,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
class JSON_API CharReader {
|
class JSON_API CharReader {
|
||||||
public:
|
public:
|
||||||
virtual ~CharReader() {}
|
virtual ~CharReader() = default;
|
||||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||||
document.
|
document.
|
||||||
* The document must be a UTF-8 encoded string containing the document to
|
* The document must be a UTF-8 encoded string containing the document to
|
||||||
@ -282,7 +282,7 @@ public:
|
|||||||
|
|
||||||
class JSON_API Factory {
|
class JSON_API Factory {
|
||||||
public:
|
public:
|
||||||
virtual ~Factory() {}
|
virtual ~Factory() = default;
|
||||||
/** \brief Allocate a CharReader via operator new().
|
/** \brief Allocate a CharReader via operator new().
|
||||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||||
*/
|
*/
|
||||||
|
@ -169,7 +169,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
|
|||||||
: public Writer {
|
: public Writer {
|
||||||
public:
|
public:
|
||||||
FastWriter();
|
FastWriter();
|
||||||
~FastWriter() override {}
|
~FastWriter() override = default;
|
||||||
|
|
||||||
void enableYAMLCompatibility();
|
void enableYAMLCompatibility();
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
|
|||||||
StyledWriter : public Writer {
|
StyledWriter : public Writer {
|
||||||
public:
|
public:
|
||||||
StyledWriter();
|
StyledWriter();
|
||||||
~StyledWriter() override {}
|
~StyledWriter() override = default;
|
||||||
|
|
||||||
public: // overridden from Writer
|
public: // overridden from Writer
|
||||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||||
|
@ -60,7 +60,7 @@ typedef std::auto_ptr<CharReader> CharReaderPtr;
|
|||||||
// ////////////////////////////////
|
// ////////////////////////////////
|
||||||
|
|
||||||
Features::Features()
|
Features::Features()
|
||||||
{}
|
= default;
|
||||||
|
|
||||||
Features Features::all() { return {}; }
|
Features Features::all() { return {}; }
|
||||||
|
|
||||||
@ -1907,7 +1907,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CharReaderBuilder::CharReaderBuilder() { setDefaults(&settings_); }
|
CharReaderBuilder::CharReaderBuilder() { setDefaults(&settings_); }
|
||||||
CharReaderBuilder::~CharReaderBuilder() {}
|
CharReaderBuilder::~CharReaderBuilder() = default;
|
||||||
CharReader* CharReaderBuilder::newCharReader() const {
|
CharReader* CharReaderBuilder::newCharReader() const {
|
||||||
bool collectComments = settings_["collectComments"].asBool();
|
bool collectComments = settings_["collectComments"].asBool();
|
||||||
OurFeatures features = OurFeatures::all();
|
OurFeatures features = OurFeatures::all();
|
||||||
|
@ -233,7 +233,7 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg) {
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Value::CommentInfo::CommentInfo() {}
|
Value::CommentInfo::CommentInfo() = default;
|
||||||
|
|
||||||
Value::CommentInfo::~CommentInfo() {
|
Value::CommentInfo::~CommentInfo() {
|
||||||
if (comment_)
|
if (comment_)
|
||||||
|
@ -123,7 +123,7 @@ char const* ValueIteratorBase::memberName(char const** end) const {
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ValueConstIterator::ValueConstIterator() {}
|
ValueConstIterator::ValueConstIterator() = default;
|
||||||
|
|
||||||
ValueConstIterator::ValueConstIterator(
|
ValueConstIterator::ValueConstIterator(
|
||||||
const Value::ObjectValues::iterator& current)
|
const Value::ObjectValues::iterator& current)
|
||||||
@ -146,7 +146,7 @@ operator=(const ValueIteratorBase& other) {
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ValueIterator::ValueIterator() {}
|
ValueIterator::ValueIterator() = default;
|
||||||
|
|
||||||
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
||||||
: ValueIteratorBase(current) {}
|
: ValueIteratorBase(current) {}
|
||||||
@ -157,7 +157,7 @@ ValueIterator::ValueIterator(const ValueConstIterator& other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ValueIterator::ValueIterator(const ValueIterator& other)
|
ValueIterator::ValueIterator(const ValueIterator& other)
|
||||||
: ValueIteratorBase(other) {}
|
= default;
|
||||||
|
|
||||||
ValueIterator& ValueIterator::operator=(const SelfType& other) {
|
ValueIterator& ValueIterator::operator=(const SelfType& other) {
|
||||||
copy(other);
|
copy(other);
|
||||||
|
@ -346,14 +346,14 @@ JSONCPP_STRING valueToQuotedString(const char* value) {
|
|||||||
|
|
||||||
// Class Writer
|
// Class Writer
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
Writer::~Writer() {}
|
Writer::~Writer() = default;
|
||||||
|
|
||||||
// Class FastWriter
|
// Class FastWriter
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FastWriter::FastWriter()
|
FastWriter::FastWriter()
|
||||||
|
|
||||||
{}
|
= default;
|
||||||
|
|
||||||
void FastWriter::enableYAMLCompatibility() { yamlCompatibilityEnabled_ = true; }
|
void FastWriter::enableYAMLCompatibility() { yamlCompatibilityEnabled_ = true; }
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
StyledWriter::StyledWriter()
|
StyledWriter::StyledWriter()
|
||||||
{}
|
= default;
|
||||||
|
|
||||||
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
||||||
document_.clear();
|
document_.clear();
|
||||||
@ -1156,10 +1156,10 @@ bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
|
|||||||
// StreamWriter
|
// StreamWriter
|
||||||
|
|
||||||
StreamWriter::StreamWriter() : sout_(nullptr) {}
|
StreamWriter::StreamWriter() : sout_(nullptr) {}
|
||||||
StreamWriter::~StreamWriter() {}
|
StreamWriter::~StreamWriter() = default;
|
||||||
StreamWriter::Factory::~Factory() {}
|
StreamWriter::Factory::~Factory() = default;
|
||||||
StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
|
StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
|
||||||
StreamWriterBuilder::~StreamWriterBuilder() {}
|
StreamWriterBuilder::~StreamWriterBuilder() = default;
|
||||||
StreamWriter* StreamWriterBuilder::newStreamWriter() const {
|
StreamWriter* StreamWriterBuilder::newStreamWriter() const {
|
||||||
JSONCPP_STRING indentation = settings_["indentation"].asString();
|
JSONCPP_STRING indentation = settings_["indentation"].asString();
|
||||||
JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
|
JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
|
||||||
|
@ -205,9 +205,9 @@ TestResult& TestResult::operator<<(bool value) {
|
|||||||
// class TestCase
|
// class TestCase
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TestCase::TestCase() {}
|
TestCase::TestCase() = default;
|
||||||
|
|
||||||
TestCase::~TestCase() {}
|
TestCase::~TestCase() = default;
|
||||||
|
|
||||||
void TestCase::run(TestResult& result) {
|
void TestCase::run(TestResult& result) {
|
||||||
result_ = &result;
|
result_ = &result;
|
||||||
@ -217,7 +217,7 @@ void TestCase::run(TestResult& result) {
|
|||||||
// class Runner
|
// class Runner
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Runner::Runner() {}
|
Runner::Runner() = default;
|
||||||
|
|
||||||
Runner& Runner::add(TestCaseFactory factory) {
|
Runner& Runner::add(TestCaseFactory factory) {
|
||||||
tests_.push_back(factory);
|
tests_.push_back(factory);
|
||||||
|
@ -1332,7 +1332,7 @@ void ValueTest::checkMemberCount(Json::Value& value,
|
|||||||
|
|
||||||
ValueTest::IsCheck::IsCheck()
|
ValueTest::IsCheck::IsCheck()
|
||||||
|
|
||||||
{}
|
= default;
|
||||||
|
|
||||||
void ValueTest::checkIs(const Json::Value& value, const IsCheck& check) {
|
void ValueTest::checkIs(const Json::Value& value, const IsCheck& check) {
|
||||||
JSONTEST_ASSERT_EQUAL(check.isObject_, value.isObject());
|
JSONTEST_ASSERT_EQUAL(check.isObject_, value.isObject());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user