Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-4100: [C++] Remove boost::noncopyable and boost::any #3267

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lang/c++/examples/imaginary.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "avro/Decoder.hh"
#include "avro/Encoder.hh"
#include "avro/Specific.hh"
#include "boost/any.hpp"

namespace i {
struct cpx {
Expand Down
6 changes: 5 additions & 1 deletion lang/c++/impl/Resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class FixedParser : public Resolver {
size_t offset_;
};

class ResolverFactory : private boost::noncopyable {
class ResolverFactory {

template<typename T>
unique_ptr<Resolver>
Expand Down Expand Up @@ -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) {

Expand Down
5 changes: 4 additions & 1 deletion lang/c++/impl/json/JsonIO.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion lang/c++/impl/parsing/ValidatingCodec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "ValidatingCodec.hh"

#include <algorithm>
#include <boost/any.hpp>
#include <map>
#include <memory>
#include <utility>
Expand Down
20 changes: 16 additions & 4 deletions lang/c++/include/avro/DataFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions lang/c++/include/avro/Generic.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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_;

Expand All @@ -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.
*/
Expand Down
8 changes: 6 additions & 2 deletions lang/c++/include/avro/Layout.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@
#define avro_Layout_hh__

#include "Config.hh"
#include <boost/noncopyable.hpp>

#include <cstddef>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be <stddef.h> because Layout.hh uses size_t rather than std::size_t?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


/// \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_;
Expand Down
6 changes: 4 additions & 2 deletions lang/c++/include/avro/Node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "Config.hh"

#include <boost/noncopyable.hpp>
#include <cassert>
#include <memory>
#include <utility>
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion lang/c++/include/avro/Parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace avro {
///

template<class Reader>
class Parser : private boost::noncopyable {
class Parser {

public:
// Constructor only works with Writer
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions lang/c++/include/avro/Reader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define avro_Reader_hh__

#include <array>
#include <boost/noncopyable.hpp>
#include <cstdint>
#include <vector>

Expand All @@ -38,14 +37,17 @@ namespace avro {
///

template<class ValidatorType>
class ReaderImpl : private boost::noncopyable {
class ReaderImpl {

public:
explicit ReaderImpl(const InputBuffer &buffer) : reader_(buffer) {}

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);
}
Expand Down
7 changes: 5 additions & 2 deletions lang/c++/include/avro/Resolver.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef avro_Resolver_hh__
#define avro_Resolver_hh__

#include <boost/noncopyable.hpp>
#include <cstdint>
#include <memory>

Expand All @@ -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;
};
Expand Down
1 change: 0 additions & 1 deletion lang/c++/include/avro/ResolverSchema.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef avro_ResolverSchema_hh__
#define avro_ResolverSchema_hh__

#include <boost/noncopyable.hpp>
#include <cstdint>
#include <memory>

Expand Down
5 changes: 3 additions & 2 deletions lang/c++/include/avro/ResolvingReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef avro_ResolvingReader_hh__
#define avro_ResolvingReader_hh__

#include <boost/noncopyable.hpp>
#include <stdint.h>

#include "Config.hh"
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions lang/c++/include/avro/Serializer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define avro_Serializer_hh__

#include <array>
#include <boost/noncopyable.hpp>

#include "Config.hh"
#include "Writer.hh"
Expand All @@ -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
Expand All @@ -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());
}
Expand Down
10 changes: 8 additions & 2 deletions lang/c++/include/avro/Stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading
Loading