This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/main by this push:
new 6e4a5682b AVRO-4100: [C++] Remove boost::noncopyable and boost::any
(#3267)
6e4a5682b is described below
commit 6e4a5682b3bc30d386b8d20fbcfc9d8c99621189
Author: Gang Wu <[email protected]>
AuthorDate: Thu Dec 19 15:53:19 2024 +0800
AVRO-4100: [C++] Remove boost::noncopyable and boost::any (#3267)
* AVRO-4100: [C++] Remove boost::noncopyable and boost::any
* use stddef.h
---
lang/c++/examples/imaginary.hh | 1 -
lang/c++/impl/Resolver.cc | 6 +++++-
lang/c++/impl/json/JsonIO.hh | 5 ++++-
lang/c++/impl/parsing/ValidatingCodec.cc | 1 -
lang/c++/include/avro/DataFile.hh | 20 ++++++++++++++++----
lang/c++/include/avro/Generic.hh | 10 ++++++++--
lang/c++/include/avro/Layout.hh | 8 ++++++--
lang/c++/include/avro/Node.hh | 6 ++++--
lang/c++/include/avro/Parser.hh | 5 ++++-
lang/c++/include/avro/Reader.hh | 6 ++++--
lang/c++/include/avro/Resolver.hh | 7 +++++--
lang/c++/include/avro/ResolverSchema.hh | 1 -
lang/c++/include/avro/ResolvingReader.hh | 5 +++--
lang/c++/include/avro/Serializer.hh | 6 ++++--
lang/c++/include/avro/Stream.hh | 10 ++++++++--
lang/c++/include/avro/Validator.hh | 11 ++++++++---
lang/c++/include/avro/Writer.hh | 6 ++++--
lang/c++/include/avro/buffer/BufferReader.hh | 5 ++++-
lang/c++/include/avro/buffer/detail/BufferDetail.hh | 2 +-
19 files changed, 88 insertions(+), 33 deletions(-)
diff --git a/lang/c++/examples/imaginary.hh b/lang/c++/examples/imaginary.hh
index a268ea1c8..e483c0beb 100644
--- a/lang/c++/examples/imaginary.hh
+++ b/lang/c++/examples/imaginary.hh
@@ -22,7 +22,6 @@
#include "avro/Decoder.hh"
#include "avro/Encoder.hh"
#include "avro/Specific.hh"
-#include "boost/any.hpp"
namespace i {
struct cpx {
diff --git a/lang/c++/impl/Resolver.cc b/lang/c++/impl/Resolver.cc
index 5fdd551a3..b7a57197b 100644
--- a/lang/c++/impl/Resolver.cc
+++ b/lang/c++/impl/Resolver.cc
@@ -445,7 +445,7 @@ protected:
size_t offset_;
};
-class ResolverFactory : private boost::noncopyable {
+class ResolverFactory {
template<typename T>
unique_ptr<Resolver>
@@ -512,6 +512,10 @@ class ResolverFactory : private boost::noncopyable {
}
public:
+ ResolverFactory() = default;
+ ResolverFactory(const ResolverFactory &) = delete;
+ ResolverFactory &operator=(const ResolverFactory &) = delete;
+
unique_ptr<Resolver>
construct(const NodePtr &writer, const NodePtr &reader, const Layout
&offset) {
diff --git a/lang/c++/impl/json/JsonIO.hh b/lang/c++/impl/json/JsonIO.hh
index 203bf895f..499255c57 100644
--- a/lang/c++/impl/json/JsonIO.hh
+++ b/lang/c++/impl/json/JsonIO.hh
@@ -37,7 +37,7 @@ inline char toHex(unsigned int n) {
return static_cast<char>((n < 10) ? (n + '0') : (n + 'a' - 10));
}
-class AVRO_DECL JsonParser : boost::noncopyable {
+class AVRO_DECL JsonParser {
public:
enum class Token {
Null,
@@ -89,6 +89,9 @@ public:
JsonParser() : curState(stValue), hasNext(false), nextChar(0),
peeked(false),
curToken(Token::Null), bv(false), lv(0), dv(0), line_(1) {}
+ JsonParser(const JsonParser &) = delete;
+ JsonParser &operator=(const JsonParser &) = delete;
+
void init(InputStream &is) {
// Clear by swapping with an empty stack
std::stack<State>().swap(stateStack);
diff --git a/lang/c++/impl/parsing/ValidatingCodec.cc
b/lang/c++/impl/parsing/ValidatingCodec.cc
index 7a1f8d91b..9ec1f0406 100644
--- a/lang/c++/impl/parsing/ValidatingCodec.cc
+++ b/lang/c++/impl/parsing/ValidatingCodec.cc
@@ -19,7 +19,6 @@
#include "ValidatingCodec.hh"
#include <algorithm>
-#include <boost/any.hpp>
#include <map>
#include <memory>
#include <utility>
diff --git a/lang/c++/include/avro/DataFile.hh
b/lang/c++/include/avro/DataFile.hh
index 94a1dab8e..09592b7ee 100644
--- a/lang/c++/include/avro/DataFile.hh
+++ b/lang/c++/include/avro/DataFile.hh
@@ -58,7 +58,7 @@ typedef std::array<uint8_t, SyncSize> DataFileSync;
* At any given point in time, at most one file can be written using
* this object.
*/
-class AVRO_DECL DataFileWriterBase : boost::noncopyable {
+class AVRO_DECL DataFileWriterBase {
const std::string filename_;
const ValidSchema schema_;
const EncoderPtr encoderPtr_;
@@ -122,6 +122,9 @@ public:
DataFileWriterBase(std::unique_ptr<OutputStream> outputStream,
const ValidSchema &schema, size_t syncInterval, Codec
codec);
+ DataFileWriterBase(const DataFileWriterBase &) = delete;
+ DataFileWriterBase &operator=(const DataFileWriterBase &) = delete;
+
~DataFileWriterBase();
/**
* Closes the current file. Once closed this datafile object cannot be
@@ -144,7 +147,7 @@ public:
* An Avro datafile that can store objects of type T.
*/
template<typename T>
-class DataFileWriter : boost::noncopyable {
+class DataFileWriter {
std::unique_ptr<DataFileWriterBase> base_;
public:
@@ -157,6 +160,9 @@ public:
DataFileWriter(std::unique_ptr<OutputStream> outputStream, const
ValidSchema &schema,
size_t syncInterval = 16 * 1024, Codec codec = NULL_CODEC)
: base_(new DataFileWriterBase(std::move(outputStream), schema, syncInterval,
codec)) {}
+ DataFileWriter(const DataFileWriter &) = delete;
+ DataFileWriter &operator=(const DataFileWriter &) = delete;
+
/**
* Writes the given piece of data into the file.
*/
@@ -191,7 +197,7 @@ public:
/**
* The type independent portion of reader.
*/
-class AVRO_DECL DataFileReaderBase : boost::noncopyable {
+class AVRO_DECL DataFileReaderBase {
const std::string filename_;
const std::unique_ptr<InputStream> stream_;
const DecoderPtr decoder_;
@@ -245,6 +251,9 @@ public:
explicit DataFileReaderBase(std::unique_ptr<InputStream> inputStream);
+ DataFileReaderBase(const DataFileReaderBase &) = delete;
+ DataFileReaderBase &operator=(const DataFileReaderBase &) = delete;
+
/**
* Initializes the reader so that the reader and writer schemas
* are the same.
@@ -303,7 +312,7 @@ public:
* Reads the contents of data file one after another.
*/
template<typename T>
-class DataFileReader : boost::noncopyable {
+class DataFileReader {
std::unique_ptr<DataFileReaderBase> base_;
public:
@@ -358,6 +367,9 @@ public:
base_->init(readerSchema);
}
+ DataFileReader(const DataFileReader &) = delete;
+ DataFileReader &operator=(const DataFileReader &) = delete;
+
/**
* Reads the next entry from the data file.
* \return true if an object has been successfully read into \p datum and
diff --git a/lang/c++/include/avro/Generic.hh b/lang/c++/include/avro/Generic.hh
index f35e8cf68..ad8a73c7e 100644
--- a/lang/c++/include/avro/Generic.hh
+++ b/lang/c++/include/avro/Generic.hh
@@ -31,7 +31,7 @@ namespace avro {
/**
* A utility class to read generic datum from decoders.
*/
-class AVRO_DECL GenericReader : boost::noncopyable {
+class AVRO_DECL GenericReader {
const ValidSchema schema_;
const bool isResolving_;
const DecoderPtr decoder_;
@@ -52,6 +52,9 @@ public:
GenericReader(const ValidSchema &writerSchema,
const ValidSchema &readerSchema, const DecoderPtr &decoder);
+ GenericReader(const GenericReader &) = delete;
+ GenericReader &operator=(const GenericReader &) = delete;
+
/**
* Reads a value off the decoder.
*/
@@ -79,7 +82,7 @@ public:
/**
* A utility class to write generic datum to encoders.
*/
-class AVRO_DECL GenericWriter : boost::noncopyable {
+class AVRO_DECL GenericWriter {
const ValidSchema schema_;
const EncoderPtr encoder_;
@@ -91,6 +94,9 @@ public:
*/
GenericWriter(ValidSchema s, EncoderPtr encoder);
+ GenericWriter(const GenericWriter &) = delete;
+ GenericWriter &operator=(const GenericWriter &) = delete;
+
/**
* Writes a value onto the encoder.
*/
diff --git a/lang/c++/include/avro/Layout.hh b/lang/c++/include/avro/Layout.hh
index 56d2c1d9c..cbc05df4a 100644
--- a/lang/c++/include/avro/Layout.hh
+++ b/lang/c++/include/avro/Layout.hh
@@ -20,17 +20,21 @@
#define avro_Layout_hh__
#include "Config.hh"
-#include <boost/noncopyable.hpp>
+
+#include <stddef.h>
/// \file Layout.hh
///
namespace avro {
-class AVRO_DECL Layout : private boost::noncopyable {
+class AVRO_DECL Layout {
protected:
explicit Layout(size_t offset = 0) : offset_(offset) {}
+ Layout(const Layout &) = delete;
+ Layout &operator=(const Layout &) = delete;
+
public:
size_t offset() const {
return offset_;
diff --git a/lang/c++/include/avro/Node.hh b/lang/c++/include/avro/Node.hh
index e1a8e660f..8664a9ab6 100644
--- a/lang/c++/include/avro/Node.hh
+++ b/lang/c++/include/avro/Node.hh
@@ -21,7 +21,6 @@
#include "Config.hh"
-#include <boost/noncopyable.hpp>
#include <cassert>
#include <memory>
#include <utility>
@@ -97,12 +96,15 @@ inline std::ostream &operator<<(std::ostream &os, const
Name &n) {
/// different node types.
///
-class AVRO_DECL Node : private boost::noncopyable {
+class AVRO_DECL Node {
public:
explicit Node(Type type) : type_(type),
logicalType_(LogicalType::NONE),
locked_(false) {}
+ Node(const Node &) = delete;
+ Node &operator=(const Node &) = delete;
+
virtual ~Node();
Type type() const {
diff --git a/lang/c++/include/avro/Parser.hh b/lang/c++/include/avro/Parser.hh
index f6bc74874..3a6c3f137 100644
--- a/lang/c++/include/avro/Parser.hh
+++ b/lang/c++/include/avro/Parser.hh
@@ -32,7 +32,7 @@ namespace avro {
///
template<class Reader>
-class Parser : private boost::noncopyable {
+class Parser {
public:
// Constructor only works with Writer
@@ -41,6 +41,9 @@ public:
/// Constructor only works with ValidatingWriter
Parser(const ValidSchema &schema, const InputBuffer &in) : reader_(schema,
in) {}
+ Parser(const Parser &) = delete;
+ Parser &operator=(const Parser &) = delete;
+
void readNull() {
Null null;
reader_.readValue(null);
diff --git a/lang/c++/include/avro/Reader.hh b/lang/c++/include/avro/Reader.hh
index 62d81c236..604527c01 100644
--- a/lang/c++/include/avro/Reader.hh
+++ b/lang/c++/include/avro/Reader.hh
@@ -20,7 +20,6 @@
#define avro_Reader_hh__
#include <array>
-#include <boost/noncopyable.hpp>
#include <cstdint>
#include <vector>
@@ -38,7 +37,7 @@ namespace avro {
///
template<class ValidatorType>
-class ReaderImpl : private boost::noncopyable {
+class ReaderImpl {
public:
explicit ReaderImpl(const InputBuffer &buffer) : reader_(buffer) {}
@@ -46,6 +45,9 @@ public:
ReaderImpl(const ValidSchema &schema, const InputBuffer &buffer) :
validator_(schema),
reader_(buffer) {}
+ ReaderImpl(const ReaderImpl &) = delete;
+ ReaderImpl &operator=(const ReaderImpl &) = delete;
+
void readValue(Null &) {
validator_.checkTypeExpected(AVRO_NULL);
}
diff --git a/lang/c++/include/avro/Resolver.hh
b/lang/c++/include/avro/Resolver.hh
index 06c33e76c..e1fc00d29 100644
--- a/lang/c++/include/avro/Resolver.hh
+++ b/lang/c++/include/avro/Resolver.hh
@@ -19,7 +19,6 @@
#ifndef avro_Resolver_hh__
#define avro_Resolver_hh__
-#include <boost/noncopyable.hpp>
#include <cstdint>
#include <memory>
@@ -34,8 +33,12 @@ namespace avro {
class ValidSchema;
class Layout;
-class AVRO_DECL Resolver : private boost::noncopyable {
+class AVRO_DECL Resolver {
public:
+ Resolver() = default;
+ Resolver(const Resolver &) = delete;
+ Resolver &operator=(const Resolver &) = delete;
+
virtual void parse(Reader &reader, uint8_t *address) const = 0;
virtual ~Resolver() = default;
};
diff --git a/lang/c++/include/avro/ResolverSchema.hh
b/lang/c++/include/avro/ResolverSchema.hh
index d641d08f8..25c113fbe 100644
--- a/lang/c++/include/avro/ResolverSchema.hh
+++ b/lang/c++/include/avro/ResolverSchema.hh
@@ -19,7 +19,6 @@
#ifndef avro_ResolverSchema_hh__
#define avro_ResolverSchema_hh__
-#include <boost/noncopyable.hpp>
#include <cstdint>
#include <memory>
diff --git a/lang/c++/include/avro/ResolvingReader.hh
b/lang/c++/include/avro/ResolvingReader.hh
index c7aed3974..5ced210db 100644
--- a/lang/c++/include/avro/ResolvingReader.hh
+++ b/lang/c++/include/avro/ResolvingReader.hh
@@ -19,7 +19,6 @@
#ifndef avro_ResolvingReader_hh__
#define avro_ResolvingReader_hh__
-#include <boost/noncopyable.hpp>
#include <stdint.h>
#include "Config.hh"
@@ -28,11 +27,13 @@
namespace avro {
-class AVRO_DECL ResolvingReader : private boost::noncopyable {
+class AVRO_DECL ResolvingReader {
public:
ResolvingReader(const ResolverSchema &schema, const InputBuffer &in) :
reader_(in),
schema_(schema) {}
+ ResolvingReader(const ResolvingReader &) = delete;
+ ResolvingReader &operator=(const ResolvingReader &) = delete;
template<typename T>
void parse(T &object) {
diff --git a/lang/c++/include/avro/Serializer.hh
b/lang/c++/include/avro/Serializer.hh
index 1a2c8e029..484a477ca 100644
--- a/lang/c++/include/avro/Serializer.hh
+++ b/lang/c++/include/avro/Serializer.hh
@@ -20,7 +20,6 @@
#define avro_Serializer_hh__
#include <array>
-#include <boost/noncopyable.hpp>
#include "Config.hh"
#include "Writer.hh"
@@ -31,7 +30,7 @@ namespace avro {
/// explicit write* names instead of writeValue
template<class Writer>
-class Serializer : private boost::noncopyable {
+class Serializer {
public:
/// Constructor only works with Writer
@@ -40,6 +39,9 @@ public:
/// Constructor only works with ValidatingWriter
explicit Serializer(const ValidSchema &schema) : writer_(schema) {}
+ Serializer(const Serializer &) = delete;
+ Serializer &operator=(const Serializer &) = delete;
+
void writeNull() {
writer_.writeValue(Null());
}
diff --git a/lang/c++/include/avro/Stream.hh b/lang/c++/include/avro/Stream.hh
index 81448d26d..783e4513c 100644
--- a/lang/c++/include/avro/Stream.hh
+++ b/lang/c++/include/avro/Stream.hh
@@ -34,13 +34,16 @@ namespace avro {
/**
* A no-copy input stream.
*/
-class AVRO_DECL InputStream : boost::noncopyable {
+class AVRO_DECL InputStream {
protected:
/**
* An empty constructor.
*/
InputStream() = default;
+ InputStream(const InputStream &) = delete;
+ InputStream &operator=(const InputStream &) = delete;
+
public:
/**
* Destructor.
@@ -106,13 +109,16 @@ typedef std::unique_ptr<SeekableInputStream>
SeekableInputStreamPtr;
/**
* A no-copy output stream.
*/
-class AVRO_DECL OutputStream : boost::noncopyable {
+class AVRO_DECL OutputStream {
protected:
/**
* An empty constructor.
*/
OutputStream() = default;
+ OutputStream(const OutputStream &) = delete;
+ OutputStream &operator=(const OutputStream &) = delete;
+
public:
/**
* Destructor.
diff --git a/lang/c++/include/avro/Validator.hh
b/lang/c++/include/avro/Validator.hh
index 6437a549f..76b74764d 100644
--- a/lang/c++/include/avro/Validator.hh
+++ b/lang/c++/include/avro/Validator.hh
@@ -19,7 +19,6 @@
#ifndef avro_Validating_hh__
#define avro_Validating_hh__
-#include <boost/noncopyable.hpp>
#include <cstdint>
#include <utility>
#include <vector>
@@ -30,11 +29,14 @@
namespace avro {
-class AVRO_DECL NullValidator : private boost::noncopyable {
+class AVRO_DECL NullValidator {
public:
explicit NullValidator(const ValidSchema &) {}
NullValidator() = default;
+ NullValidator(const NullValidator &) = delete;
+ NullValidator &operator=(const NullValidator &) = delete;
+
void setCount(size_t) {}
static bool typeIsExpected(Type) {
@@ -67,10 +69,13 @@ public:
/// through all leaf nodes but a union only skips to one), and reports which
/// type is next.
-class AVRO_DECL Validator : private boost::noncopyable {
+class AVRO_DECL Validator {
public:
explicit Validator(ValidSchema schema);
+ Validator(const Validator &) = delete;
+ Validator &operator=(const Validator &) = delete;
+
void setCount(size_t val);
bool typeIsExpected(Type type) const {
diff --git a/lang/c++/include/avro/Writer.hh b/lang/c++/include/avro/Writer.hh
index 930ea398c..426f8ba0e 100644
--- a/lang/c++/include/avro/Writer.hh
+++ b/lang/c++/include/avro/Writer.hh
@@ -20,7 +20,6 @@
#define avro_Writer_hh__
#include <array>
-#include <boost/noncopyable.hpp>
#include "Config.hh"
#include "Types.hh"
@@ -33,13 +32,16 @@ namespace avro {
/// Class for writing avro data to a stream.
template<class ValidatorType>
-class WriterImpl : private boost::noncopyable {
+class WriterImpl {
public:
WriterImpl() = default;
explicit WriterImpl(const ValidSchema &schema) : validator_(schema) {}
+ WriterImpl(const WriterImpl &) = delete;
+ WriterImpl &operator=(const WriterImpl &) = delete;
+
void writeValue(const Null &) {
validator_.checkTypeExpected(AVRO_NULL);
}
diff --git a/lang/c++/include/avro/buffer/BufferReader.hh
b/lang/c++/include/avro/buffer/BufferReader.hh
index 7f49518e6..39b23fa70 100644
--- a/lang/c++/include/avro/buffer/BufferReader.hh
+++ b/lang/c++/include/avro/buffer/BufferReader.hh
@@ -40,7 +40,7 @@ namespace avro {
* chunk boundaries. May read from an InputBuffer or OutputBuffer.
*
**/
-class AVRO_DECL BufferReader : private boost::noncopyable {
+class AVRO_DECL BufferReader {
public:
typedef detail::data_type data_type;
@@ -83,6 +83,9 @@ public:
bytesRemaining_(bytes_),
chunkPos_(0) {}
+ BufferReader(const BufferReader &) = delete;
+ BufferReader &operator=(const BufferReader &) = delete;
+
/**
* How many bytes are still not read from this buffer.
**/
diff --git a/lang/c++/include/avro/buffer/detail/BufferDetail.hh
b/lang/c++/include/avro/buffer/detail/BufferDetail.hh
index 652e98d51..697c8f41c 100644
--- a/lang/c++/include/avro/buffer/detail/BufferDetail.hh
+++ b/lang/c++/include/avro/buffer/detail/BufferDetail.hh
@@ -191,7 +191,7 @@ inline bool operator!=(const Chunk &lhs, const Chunk &rhs) {
*
*/
-class BufferImpl : boost::noncopyable {
+class BufferImpl {
/// Add a new chunk to the list of chunks for this buffer, growing the
/// buffer by the default block size.