forked from bblanchon/ArduinoJson
Use delete
instead of hiding copy constructors and assignments (#1820)
This commit is contained in:
@ -11,6 +11,7 @@ class CustomReader {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CustomReader(const char* input) : _stream(input) {}
|
CustomReader(const char* input) : _stream(input) {}
|
||||||
|
CustomReader(const CustomReader&) = delete;
|
||||||
|
|
||||||
int read() {
|
int read() {
|
||||||
return _stream.get();
|
return _stream.get();
|
||||||
@ -20,7 +21,4 @@ class CustomReader {
|
|||||||
_stream.read(buffer, static_cast<std::streamsize>(length));
|
_stream.read(buffer, static_cast<std::streamsize>(length));
|
||||||
return static_cast<size_t>(_stream.gcount());
|
return static_cast<size_t>(_stream.gcount());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
CustomReader(const CustomReader&);
|
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@ class SpyingAllocator {
|
|||||||
public:
|
public:
|
||||||
SpyingAllocator(const SpyingAllocator& src) : _log(src._log) {}
|
SpyingAllocator(const SpyingAllocator& src) : _log(src._log) {}
|
||||||
SpyingAllocator(std::ostream& log) : _log(log) {}
|
SpyingAllocator(std::ostream& log) : _log(log) {}
|
||||||
|
SpyingAllocator& operator=(const SpyingAllocator& src) = delete;
|
||||||
|
|
||||||
void* allocate(size_t n) {
|
void* allocate(size_t n) {
|
||||||
_log << "A" << n;
|
_log << "A" << n;
|
||||||
@ -23,8 +24,6 @@ class SpyingAllocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SpyingAllocator& operator=(const SpyingAllocator& src);
|
|
||||||
|
|
||||||
std::ostream& _log;
|
std::ostream& _log;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
class CustomWriter {
|
class CustomWriter {
|
||||||
public:
|
public:
|
||||||
CustomWriter() {}
|
CustomWriter() {}
|
||||||
|
CustomWriter(const CustomWriter&) = delete;
|
||||||
|
CustomWriter& operator=(const CustomWriter&) = delete;
|
||||||
|
|
||||||
size_t write(uint8_t c) {
|
size_t write(uint8_t c) {
|
||||||
_str.append(1, static_cast<char>(c));
|
_str.append(1, static_cast<char>(c));
|
||||||
@ -24,9 +26,6 @@ class CustomWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CustomWriter(const CustomWriter&); // non-copiable
|
|
||||||
CustomWriter& operator=(const CustomWriter&);
|
|
||||||
|
|
||||||
std::string _str;
|
std::string _str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
|
|||||||
friend class detail::VariantAttorney;
|
friend class detail::VariantAttorney;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
JsonDocument(const JsonDocument&) = delete;
|
||||||
|
JsonDocument& operator=(const JsonDocument&) = delete;
|
||||||
|
|
||||||
// Casts the root to the specified type.
|
// Casts the root to the specified type.
|
||||||
// https://arduinojson.org/v6/api/jsondocument/as/
|
// https://arduinojson.org/v6/api/jsondocument/as/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -303,10 +306,6 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
|
|||||||
detail::MemoryPool _pool;
|
detail::MemoryPool _pool;
|
||||||
detail::VariantData _data;
|
detail::VariantData _data;
|
||||||
|
|
||||||
private:
|
|
||||||
JsonDocument(const JsonDocument&);
|
|
||||||
JsonDocument& operator=(const JsonDocument&);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
detail::MemoryPool* getPool() {
|
detail::MemoryPool* getPool() {
|
||||||
return &_pool;
|
return &_pool;
|
||||||
|
@ -22,6 +22,8 @@ class TextFormatter {
|
|||||||
public:
|
public:
|
||||||
explicit TextFormatter(TWriter writer) : _writer(writer) {}
|
explicit TextFormatter(TWriter writer) : _writer(writer) {}
|
||||||
|
|
||||||
|
TextFormatter& operator=(const TextFormatter&) = delete;
|
||||||
|
|
||||||
// Returns the number of bytes sent to the TWriter implementation.
|
// Returns the number of bytes sent to the TWriter implementation.
|
||||||
size_t bytesWritten() const {
|
size_t bytesWritten() const {
|
||||||
return _writer.count();
|
return _writer.count();
|
||||||
@ -166,9 +168,6 @@ class TextFormatter {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CountingDecorator<TWriter> _writer;
|
CountingDecorator<TWriter> _writer;
|
||||||
|
|
||||||
private:
|
|
||||||
TextFormatter& operator=(const TextFormatter&); // cannot be assigned
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
Reference in New Issue
Block a user