diff --git a/include/awkward/Slice.h b/include/awkward/Slice.h index 50cd3f8a5d..db8ee59772 100644 --- a/include/awkward/Slice.h +++ b/include/awkward/Slice.h @@ -139,7 +139,7 @@ namespace awkward { } virtual const std::string tostring() const; virtual bool preserves_type(const std::shared_ptr& type, const Index64& advanced) const { - return type.get() != nullptr && type.get()->numfields() != -1 && util::subset(keys_, type.get()->keys()); + return type != nullptr && type.get()->numfields() != -1 && util::subset(keys_, type.get()->keys()); } private: const std::vector keys_; diff --git a/include/awkward/array/EmptyArray.h b/include/awkward/array/EmptyArray.h index fa15aa309b..f475b57f7b 100644 --- a/include/awkward/array/EmptyArray.h +++ b/include/awkward/array/EmptyArray.h @@ -18,40 +18,40 @@ namespace awkward { EmptyArray(const std::shared_ptr id, const std::shared_ptr type) : Content(id, type) { } - virtual const std::string classname() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + const std::string classname() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const; + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const override; }; } diff --git a/include/awkward/array/ListArray.h b/include/awkward/array/ListArray.h index 148d0437bf..fd0c2ae4a0 100644 --- a/include/awkward/array/ListArray.h +++ b/include/awkward/array/ListArray.h @@ -24,38 +24,38 @@ namespace awkward { const IndexOf stops() const { return stops_; } const std::shared_ptr content() const { return content_; } - virtual const std::string classname() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + const std::string classname() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const; + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override; private: const IndexOf starts_; diff --git a/include/awkward/array/ListOffsetArray.h b/include/awkward/array/ListOffsetArray.h index 6bfdcc0c9f..214e7b99a2 100644 --- a/include/awkward/array/ListOffsetArray.h +++ b/include/awkward/array/ListOffsetArray.h @@ -22,38 +22,38 @@ namespace awkward { const IndexOf offsets() const { return offsets_; } const std::shared_ptr content() const { return content_; } - virtual const std::string classname() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + const std::string classname() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const; + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override; private: const IndexOf offsets_; diff --git a/include/awkward/array/NumpyArray.h b/include/awkward/array/NumpyArray.h index 02b5ed6454..f53701c72a 100644 --- a/include/awkward/array/NumpyArray.h +++ b/include/awkward/array/NumpyArray.h @@ -40,56 +40,56 @@ namespace awkward { ssize_t bytelength() const; uint8_t getbyte(ssize_t at) const; - virtual bool isscalar() const; - virtual const std::string classname() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual const std::shared_ptr type() const; - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr getitem(const Slice& where) const; - virtual const std::shared_ptr getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + bool isscalar() const override; + const std::string classname() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + const std::shared_ptr type() const override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr getitem(const Slice& where) const override; + const std::shared_ptr getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; bool iscontiguous() const; void become_contiguous(); const NumpyArray contiguous() const; protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override { throw std::runtime_error("NumpyArray has its own getitem_next system"); } - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override { throw std::runtime_error("NumpyArray has its own getitem_next system"); } - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override { throw std::runtime_error("NumpyArray has its own getitem_next system"); } - virtual const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const override { throw std::runtime_error("NumpyArray has its own getitem_next system"); } - virtual const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const override { throw std::runtime_error("NumpyArray has its own getitem_next system"); } diff --git a/include/awkward/array/RawArray.h b/include/awkward/array/RawArray.h index e0b68b346d..9a8c21d6bb 100644 --- a/include/awkward/array/RawArray.h +++ b/include/awkward/array/RawArray.h @@ -79,9 +79,9 @@ namespace awkward { T* borrow(int64_t at) const { return reinterpret_cast(reinterpret_cast(ptr_.get()) + (ssize_t)itemsize_*(ssize_t)(offset_ + at)); } - virtual const std::string classname() const { return std::string("RawArrayOf<") + std::string(typeid(T).name()) + std::string(">"); } + const std::string classname() const override { return std::string("RawArrayOf<") + std::string(typeid(T).name()) + std::string(">"); } - virtual void setid() { + void setid() override { if (length() <= kMaxInt32) { Identity32* rawid = new Identity32(Identity::newref(), Identity::FieldLoc(), 1, length()); std::shared_ptr newid(rawid); @@ -95,15 +95,15 @@ namespace awkward { setid(newid); } } - virtual void setid(const std::shared_ptr id) { - if (id.get() != nullptr && length() != id.get()->length()) { + void setid(const std::shared_ptr id) override { + if (id != nullptr && length() != id.get()->length()) { throw std::invalid_argument("content and its id must have the same length"); } id_ = id; } const std::string tostring() { return tostring_part("", "", ""); } - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const { + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override { std::stringstream out; out << indent << pre << "::value) { tojson_real(builder, reinterpret_cast(byteptr()), length()); } @@ -182,7 +182,7 @@ namespace awkward { } } - virtual const std::shared_ptr innertype(bool bare) const { + const std::shared_ptr innertype(bool bare) const override { if (std::is_same::value) { return std::shared_ptr(new PrimitiveType(Type::Parameters(), PrimitiveType::float64)); } @@ -221,7 +221,7 @@ namespace awkward { } } - virtual void settype_part(const std::shared_ptr type) { + void settype_part(const std::shared_ptr type) override { if (accepts(type)) { type_ = type; } @@ -230,7 +230,7 @@ namespace awkward { } } - virtual bool accepts(const std::shared_ptr type) { + bool accepts(const std::shared_ptr type) override { std::shared_ptr check = type.get()->level(); if (std::is_same::value) { return check.get()->equal(std::shared_ptr(new PrimitiveType(Type::Parameters(), PrimitiveType::float64)), false); @@ -270,21 +270,21 @@ namespace awkward { } } - virtual int64_t length() const { return length_; } + int64_t length() const override { return length_; } - virtual const std::shared_ptr shallow_copy() const { return std::shared_ptr(new RawArrayOf(id_, type_, ptr_, offset_, length_, itemsize_)); } + const std::shared_ptr shallow_copy() const override { return std::shared_ptr(new RawArrayOf(id_, type_, ptr_, offset_, length_, itemsize_)); } - virtual void check_for_iteration() const { + void check_for_iteration() const override { if (id_.get() != nullptr && id_.get()->length() < length_) { util::handle_error(failure("len(id) < len(array)", kSliceNone, kSliceNone), id_.get()->classname(), nullptr); } } - virtual const std::shared_ptr getitem_nothing() const { + const std::shared_ptr getitem_nothing() const override { return getitem_range_nowrap(0, 0); } - virtual const std::shared_ptr getitem_at(int64_t at) const { + const std::shared_ptr getitem_at(int64_t at) const override { int64_t regular_at = at; if (regular_at < 0) { regular_at += length_; @@ -295,11 +295,11 @@ namespace awkward { return getitem_at_nowrap(regular_at); } - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const { + const std::shared_ptr getitem_at_nowrap(int64_t at) const override { return getitem_range_nowrap(at, at + 1); } - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const { + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override { int64_t regular_start = start; int64_t regular_stop = stop; awkward_regularize_rangeslice(®ular_start, ®ular_stop, true, start != Slice::none(), stop != Slice::none(), length_); @@ -309,7 +309,7 @@ namespace awkward { return getitem_range_nowrap(regular_start, regular_stop); } - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const { + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override { std::shared_ptr id(nullptr); if (id_.get() != nullptr) { id = id_.get()->getitem_range_nowrap(start, stop); @@ -317,29 +317,29 @@ namespace awkward { return std::shared_ptr(new RawArrayOf(id, type_, ptr_, offset_ + start, stop - start, itemsize_)); } - virtual const std::shared_ptr getitem_field(const std::string& key) const { + const std::shared_ptr getitem_field(const std::string& key) const override { throw std::invalid_argument(std::string("cannot slice ") + classname() + std::string(" by field name")); } - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const { + const std::shared_ptr getitem_fields(const std::vector& keys) const override { throw std::invalid_argument(std::string("cannot slice ") + classname() + std::string(" by field name")); } - virtual const std::shared_ptr getitem(const Slice& where) const { + const std::shared_ptr getitem(const Slice& where) const override { std::shared_ptr nexthead = where.head(); Slice nexttail = where.tail(); Index64 nextadvanced(0); return getitem_next(nexthead, nexttail, nextadvanced); } - virtual const std::shared_ptr getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const override { if (tail.length() != 0) { throw std::invalid_argument("too many indexes for array"); } return Content::getitem_next(head, tail, advanced); } - virtual const std::shared_ptr carry(const Index64& carry) const { + const std::shared_ptr carry(const Index64& carry) const override { std::shared_ptr ptr(new T[(size_t)carry.length()], awkward::util::array_deleter()); struct Error err = awkward_numpyarray_getitem_next_null_64( reinterpret_cast(ptr.get()), @@ -358,42 +358,42 @@ namespace awkward { return std::shared_ptr(new RawArrayOf(id, type_, ptr, 0, carry.length(), itemsize_)); } - virtual const std::pair minmax_depth() const { + const std::pair minmax_depth() const override { return std::pair(1, 1); } - virtual int64_t numfields() const { return -1; } + int64_t numfields() const override { return -1; } - virtual int64_t fieldindex(const std::string& key) const { + int64_t fieldindex(const std::string& key) const override { throw std::invalid_argument("array contains no Records"); } - virtual const std::string key(int64_t fieldindex) const { + const std::string key(int64_t fieldindex) const override { throw std::invalid_argument("array contains no Records"); } - virtual bool haskey(const std::string& key) const { + bool haskey(const std::string& key) const override { throw std::invalid_argument("array contains no Records"); } - virtual const std::vector keyaliases(int64_t fieldindex) const { + const std::vector keyaliases(int64_t fieldindex) const override { throw std::invalid_argument("array contains no Records"); } - virtual const std::vector keyaliases(const std::string& key) const { + const std::vector keyaliases(const std::string& key) const override { throw std::invalid_argument("array contains no Records"); } - virtual const std::vector keys() const { + const std::vector keys() const override { throw std::invalid_argument("array contains no Records"); } protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override { return getitem_at(at.at()); } - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override { if (range.step() == Slice::none() || range.step() == 1) { return getitem_range(range.start(), range.stop()); } @@ -409,8 +409,8 @@ namespace awkward { } awkward_regularize_rangeslice(&start, &stop, step > 0, range.hasstart(), range.hasstop(), length_); - int64_t numer = abs(start - stop); - int64_t denom = abs(step); + int64_t numer = std::abs(start - stop); + int64_t denom = std::abs(step); int64_t d = numer / denom; int64_t m = numer % denom; int64_t lenhead = d + (m != 0 ? 1 : 0); @@ -425,7 +425,7 @@ namespace awkward { } } - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override { assert(advanced.length() == 0); if (array.shape().size() != 1) { throw std::runtime_error("array.ndim != 1"); @@ -439,11 +439,11 @@ namespace awkward { return carry(flathead); } - virtual const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const override { throw std::invalid_argument(field.tostring() + std::string(" is not a valid slice type for ") + classname()); } - virtual const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const { + const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const override { throw std::invalid_argument(fields.tostring() + std::string(" is not a valid slice type for ") + classname()); } diff --git a/include/awkward/array/Record.h b/include/awkward/array/Record.h index 94b6cdc778..7da0cf4f94 100644 --- a/include/awkward/array/Record.h +++ b/include/awkward/array/Record.h @@ -24,39 +24,39 @@ namespace awkward { } const std::shared_ptr lookup() const { return array_.lookup(); } const std::shared_ptr reverselookup() const { return array_.reverselookup(); } - bool istuple() const { return lookup().get() == nullptr; } + bool istuple() const { return lookup() == nullptr; } - virtual bool isscalar() const; - virtual const std::string classname() const; - virtual const std::shared_ptr id() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual const std::shared_ptr type() const; - virtual void settype(const std::shared_ptr type); - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + bool isscalar() const override; + const std::string classname() const override; + const std::shared_ptr id() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + const std::shared_ptr type() const override; + void settype(const std::shared_ptr type) override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr field(int64_t fieldindex) const; const std::shared_ptr field(const std::string& key) const; @@ -65,11 +65,11 @@ namespace awkward { const Record astuple() const; protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const; + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const override; private: RecordArray array_; diff --git a/include/awkward/array/RecordArray.h b/include/awkward/array/RecordArray.h index f9e16a2812..00185c22ac 100644 --- a/include/awkward/array/RecordArray.h +++ b/include/awkward/array/RecordArray.h @@ -23,7 +23,7 @@ namespace awkward { , lookup_(lookup) , reverselookup_(reverselookup) , length_(0) { - assert(contents.size() != 0); + assert(!contents.empty()); } RecordArray(const std::shared_ptr id, const std::shared_ptr type, const std::vector>& contents) : Content(id, type) @@ -31,7 +31,7 @@ namespace awkward { , lookup_(nullptr) , reverselookup_(nullptr) , length_(0) { - assert(contents.size() != 0); + assert(!contents.empty()); } RecordArray(const std::shared_ptr id, const std::shared_ptr type, int64_t length, bool istuple) : Content(id, type) @@ -43,36 +43,36 @@ namespace awkward { const std::vector> contents() const { return contents_; } const std::shared_ptr lookup() const { return lookup_; } const std::shared_ptr reverselookup() const { return reverselookup_; } - bool istuple() const { return lookup_.get() == nullptr; } + bool istuple() const { return lookup_ == nullptr; } - virtual const std::string classname() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + const std::string classname() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr field(int64_t fieldindex) const; const std::shared_ptr field(const std::string& key) const; @@ -85,11 +85,11 @@ namespace awkward { void setkey(int64_t fieldindex, const std::string& key); protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const; + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceField& field, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceFields& fields, const Slice& tail, const Index64& advanced) const override; private: std::vector> contents_; diff --git a/include/awkward/array/RegularArray.h b/include/awkward/array/RegularArray.h index d88a7e33e5..4acae3e370 100644 --- a/include/awkward/array/RegularArray.h +++ b/include/awkward/array/RegularArray.h @@ -23,38 +23,38 @@ namespace awkward { const std::shared_ptr content() const { return content_; } int64_t size() const { return size_; } - virtual const std::string classname() const; - virtual void setid(); - virtual void setid(const std::shared_ptr id); - virtual const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const; - virtual void tojson_part(ToJson& builder) const; - virtual const std::shared_ptr innertype(bool bare) const; - virtual void settype_part(const std::shared_ptr type); - virtual bool accepts(const std::shared_ptr type); - virtual int64_t length() const; - virtual const std::shared_ptr shallow_copy() const; - virtual void check_for_iteration() const; - virtual const std::shared_ptr getitem_nothing() const; - virtual const std::shared_ptr getitem_at(int64_t at) const; - virtual const std::shared_ptr getitem_at_nowrap(int64_t at) const; - virtual const std::shared_ptr getitem_range(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const; - virtual const std::shared_ptr getitem_field(const std::string& key) const; - virtual const std::shared_ptr getitem_fields(const std::vector& keys) const; - virtual const std::shared_ptr carry(const Index64& carry) const; - virtual const std::pair minmax_depth() const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + const std::string classname() const override; + void setid() override; + void setid(const std::shared_ptr id) override; + const std::string tostring_part(const std::string indent, const std::string pre, const std::string post) const override; + void tojson_part(ToJson& builder) const override; + const std::shared_ptr innertype(bool bare) const override; + void settype_part(const std::shared_ptr type) override; + bool accepts(const std::shared_ptr type) override; + int64_t length() const override; + const std::shared_ptr shallow_copy() const override; + void check_for_iteration() const override; + const std::shared_ptr getitem_nothing() const override; + const std::shared_ptr getitem_at(int64_t at) const override; + const std::shared_ptr getitem_at_nowrap(int64_t at) const override; + const std::shared_ptr getitem_range(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_range_nowrap(int64_t start, int64_t stop) const override; + const std::shared_ptr getitem_field(const std::string& key) const override; + const std::shared_ptr getitem_fields(const std::vector& keys) const override; + const std::shared_ptr carry(const Index64& carry) const override; + const std::pair minmax_depth() const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; protected: - virtual const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const; - virtual const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const; + const std::shared_ptr getitem_next(const SliceAt& at, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceRange& range, const Slice& tail, const Index64& advanced) const override; + const std::shared_ptr getitem_next(const SliceArray64& array, const Slice& tail, const Index64& advanced) const override; private: const std::shared_ptr content_; diff --git a/include/awkward/fillable/BoolFillable.h b/include/awkward/fillable/BoolFillable.h index cb0a1fe856..abcc116e76 100644 --- a/include/awkward/fillable/BoolFillable.h +++ b/include/awkward/fillable/BoolFillable.h @@ -15,26 +15,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); - virtual const std::string classname() const { return "BoolFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "BoolFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; private: const FillableOptions options_; diff --git a/include/awkward/fillable/Float64Fillable.h b/include/awkward/fillable/Float64Fillable.h index a25a3056df..501be21446 100644 --- a/include/awkward/fillable/Float64Fillable.h +++ b/include/awkward/fillable/Float64Fillable.h @@ -16,26 +16,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); static const std::shared_ptr fromint64(const FillableOptions& options, GrowableBuffer old); - virtual const std::string classname() const { return "Float64Fillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "Float64Fillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; private: const FillableOptions options_; diff --git a/include/awkward/fillable/Int64Fillable.h b/include/awkward/fillable/Int64Fillable.h index 41967a8bc7..1ffa2ac3ce 100644 --- a/include/awkward/fillable/Int64Fillable.h +++ b/include/awkward/fillable/Int64Fillable.h @@ -15,26 +15,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); - virtual const std::string classname() const { return "Int64Fillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "Int64Fillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; const GrowableBuffer buffer() const { return buffer_; } diff --git a/include/awkward/fillable/ListFillable.h b/include/awkward/fillable/ListFillable.h index 60fded2729..1b8cd10828 100644 --- a/include/awkward/fillable/ListFillable.h +++ b/include/awkward/fillable/ListFillable.h @@ -18,26 +18,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); - virtual const std::string classname() const { return "ListFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "ListFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; private: const FillableOptions options_; diff --git a/include/awkward/fillable/OptionFillable.h b/include/awkward/fillable/OptionFillable.h index c3ce89e1df..9d55045cee 100644 --- a/include/awkward/fillable/OptionFillable.h +++ b/include/awkward/fillable/OptionFillable.h @@ -18,26 +18,26 @@ namespace awkward { static const std::shared_ptr fromnulls(const FillableOptions& options, int64_t nullcount, std::shared_ptr content); static const std::shared_ptr fromvalids(const FillableOptions& options, std::shared_ptr content); - virtual const std::string classname() const { return "OptionFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "OptionFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; private: const FillableOptions options_; diff --git a/include/awkward/fillable/RecordFillable.h b/include/awkward/fillable/RecordFillable.h index 2558cabde0..248d9c641d 100644 --- a/include/awkward/fillable/RecordFillable.h +++ b/include/awkward/fillable/RecordFillable.h @@ -28,26 +28,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); - virtual const std::string classname() const { return "RecordFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; + const std::string classname() const override { return "RecordFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; const std::string name() const { return name_; } const char* nameptr() const { return nameptr_; } diff --git a/include/awkward/fillable/StringFillable.h b/include/awkward/fillable/StringFillable.h index 7962be0552..c245d974f4 100644 --- a/include/awkward/fillable/StringFillable.h +++ b/include/awkward/fillable/StringFillable.h @@ -15,26 +15,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options, const char* encoding); - virtual const std::string classname() const { return "StringFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "StringFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; const char* encoding() const { return encoding_; } diff --git a/include/awkward/fillable/TupleFillable.h b/include/awkward/fillable/TupleFillable.h index 71dd012f2f..8121a7f790 100644 --- a/include/awkward/fillable/TupleFillable.h +++ b/include/awkward/fillable/TupleFillable.h @@ -23,26 +23,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); - virtual const std::string classname() const { return "TupleFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "TupleFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; int64_t numfields() const { return (int64_t)contents_.size(); } diff --git a/include/awkward/fillable/UnionFillable.h b/include/awkward/fillable/UnionFillable.h index 4a83935000..d232a26e71 100644 --- a/include/awkward/fillable/UnionFillable.h +++ b/include/awkward/fillable/UnionFillable.h @@ -20,26 +20,26 @@ namespace awkward { static const std::shared_ptr fromsingle(const FillableOptions& options, const std::shared_ptr firstcontent); - virtual const std::string classname() const { return "UnionFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "UnionFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; private: const FillableOptions options_; diff --git a/include/awkward/fillable/UnknownFillable.h b/include/awkward/fillable/UnknownFillable.h index f050bc26ee..22fc20ef2e 100644 --- a/include/awkward/fillable/UnknownFillable.h +++ b/include/awkward/fillable/UnknownFillable.h @@ -16,26 +16,26 @@ namespace awkward { static const std::shared_ptr fromempty(const FillableOptions& options); - virtual const std::string classname() const { return "UnknownFillable"; }; - virtual int64_t length() const; - virtual void clear(); - virtual const std::shared_ptr type() const; - virtual const std::shared_ptr snapshot() const; - - virtual bool active() const; - virtual const std::shared_ptr null(); - virtual const std::shared_ptr boolean(bool x); - virtual const std::shared_ptr integer(int64_t x); - virtual const std::shared_ptr real(double x); - virtual const std::shared_ptr string(const char* x, int64_t length, const char* encoding); - virtual const std::shared_ptr beginlist(); - virtual const std::shared_ptr endlist(); - virtual const std::shared_ptr begintuple(int64_t numfields); - virtual const std::shared_ptr index(int64_t index); - virtual const std::shared_ptr endtuple(); - virtual const std::shared_ptr beginrecord(const char* name, bool check); - virtual const std::shared_ptr field(const char* key, bool check); - virtual const std::shared_ptr endrecord(); + const std::string classname() const override { return "UnknownFillable"; }; + int64_t length() const override; + void clear() override; + const std::shared_ptr type() const override; + const std::shared_ptr snapshot() const override; + + bool active() const override; + const std::shared_ptr null() override; + const std::shared_ptr boolean(bool x) override; + const std::shared_ptr integer(int64_t x) override; + const std::shared_ptr real(double x) override; + const std::shared_ptr string(const char* x, int64_t length, const char* encoding) override; + const std::shared_ptr beginlist() override; + const std::shared_ptr endlist() override; + const std::shared_ptr begintuple(int64_t numfields) override; + const std::shared_ptr index(int64_t index) override; + const std::shared_ptr endtuple() override; + const std::shared_ptr beginrecord(const char* name, bool check) override; + const std::shared_ptr field(const char* key, bool check) override; + const std::shared_ptr endrecord() override; private: const FillableOptions options_; diff --git a/include/awkward/io/json.h b/include/awkward/io/json.h index 7f28f914e0..68a0b1cb4c 100644 --- a/include/awkward/io/json.h +++ b/include/awkward/io/json.h @@ -48,16 +48,16 @@ namespace awkward { } } - virtual void null() { writer_.Null(); } - virtual void boolean(bool x) { writer_.Bool(x); } - virtual void integer(int64_t x) { writer_.Int64(x); } - virtual void real(double x) { writer_.Double(x); } - virtual void string(const char* x, int64_t length) { writer_.String(x, (rj::SizeType)length); } - virtual void beginlist() { writer_.StartArray(); } - virtual void endlist() { writer_.EndArray(); } - virtual void beginrecord() { writer_.StartObject(); } - virtual void field(const char* x) { writer_.Key(x); } - virtual void endrecord() { writer_.EndObject(); } + void null() override { writer_.Null(); } + void boolean(bool x) override { writer_.Bool(x); } + void integer(int64_t x) override { writer_.Int64(x); } + void real(double x) override { writer_.Double(x); } + void string(const char* x, int64_t length) override { writer_.String(x, (rj::SizeType)length); } + void beginlist() override { writer_.StartArray(); } + void endlist() override { writer_.EndArray(); } + void beginrecord() override { writer_.StartObject(); } + void field(const char* x) override { writer_.Key(x); } + void endrecord() override { writer_.EndObject(); } std::string tostring() { return std::string(buffer_.GetString()); @@ -76,16 +76,16 @@ namespace awkward { } } - virtual void null() { writer_.Null(); } - virtual void boolean(bool x) { writer_.Bool(x); } - virtual void integer(int64_t x) { writer_.Int64(x); } - virtual void real(double x) { writer_.Double(x); } - virtual void string(const char* x, int64_t length) { writer_.String(x, (rj::SizeType)length); } - virtual void beginlist() { writer_.StartArray(); } - virtual void endlist() { writer_.EndArray(); } - virtual void beginrecord() { writer_.StartObject(); } - virtual void field(const char* x) { writer_.Key(x); } - virtual void endrecord() { writer_.EndObject(); } + void null() override { writer_.Null(); } + void boolean(bool x) override { writer_.Bool(x); } + void integer(int64_t x) override { writer_.Int64(x); } + void real(double x) override { writer_.Double(x); } + void string(const char* x, int64_t length) override { writer_.String(x, (rj::SizeType)length); } + void beginlist() override { writer_.StartArray(); } + void endlist() override { writer_.EndArray(); } + void beginrecord() override { writer_.StartObject(); } + void field(const char* x) override { writer_.Key(x); } + void endrecord() override { writer_.EndObject(); } std::string tostring() { return std::string(buffer_.GetString()); @@ -104,16 +104,16 @@ namespace awkward { } } - virtual void null() { writer_.Null(); } - virtual void boolean(bool x) { writer_.Bool(x); } - virtual void integer(int64_t x) { writer_.Int64(x); } - virtual void real(double x) { writer_.Double(x); } - virtual void string(const char* x, int64_t length) { writer_.String(x, (rj::SizeType)length); } - virtual void beginlist() { writer_.StartArray(); } - virtual void endlist() { writer_.EndArray(); } - virtual void beginrecord() { writer_.StartObject(); } - virtual void field(const char* x) { writer_.Key(x); } - virtual void endrecord() { writer_.EndObject(); } + void null() override { writer_.Null(); } + void boolean(bool x) override { writer_.Bool(x); } + void integer(int64_t x) override { writer_.Int64(x); } + void real(double x) override { writer_.Double(x); } + void string(const char* x, int64_t length) override { writer_.String(x, (rj::SizeType)length); } + void beginlist() override { writer_.StartArray(); } + void endlist() override { writer_.EndArray(); } + void beginrecord() override { writer_.StartObject(); } + void field(const char* x) override { writer_.Key(x); } + void endrecord() override { writer_.EndObject(); } private: std::shared_ptr buffer_; @@ -129,16 +129,16 @@ namespace awkward { } } - virtual void null() { writer_.Null(); } - virtual void boolean(bool x) { writer_.Bool(x); } - virtual void integer(int64_t x) { writer_.Int64(x); } - virtual void real(double x) { writer_.Double(x); } - virtual void string(const char* x, int64_t length) { writer_.String(x, (rj::SizeType)length); } - virtual void beginlist() { writer_.StartArray(); } - virtual void endlist() { writer_.EndArray(); } - virtual void beginrecord() { writer_.StartObject(); } - virtual void field(const char* x) { writer_.Key(x); } - virtual void endrecord() { writer_.EndObject(); } + void null() override { writer_.Null(); } + void boolean(bool x) override { writer_.Bool(x); } + void integer(int64_t x) override { writer_.Int64(x); } + void real(double x) override { writer_.Double(x); } + void string(const char* x, int64_t length) override { writer_.String(x, (rj::SizeType)length); } + void beginlist() override { writer_.StartArray(); } + void endlist() override { writer_.EndArray(); } + void beginrecord() override { writer_.StartObject(); } + void field(const char* x) override { writer_.Key(x); } + void endrecord() override { writer_.EndObject(); } private: std::shared_ptr buffer_; diff --git a/include/awkward/type/ArrayType.h b/include/awkward/type/ArrayType.h index e0dd32aa2b..421fcc8e6b 100644 --- a/include/awkward/type/ArrayType.h +++ b/include/awkward/type/ArrayType.h @@ -13,20 +13,20 @@ namespace awkward { , type_(type) , length_(length) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr nolength() const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr nolength() const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr type() const; int64_t length() const; diff --git a/include/awkward/type/ListType.h b/include/awkward/type/ListType.h index fb568914fd..a10831e3f0 100644 --- a/include/awkward/type/ListType.h +++ b/include/awkward/type/ListType.h @@ -12,19 +12,19 @@ namespace awkward { : Type(parameters) , type_(type) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr type() const; diff --git a/include/awkward/type/OptionType.h b/include/awkward/type/OptionType.h index adfd2a2c1a..607f77a41e 100644 --- a/include/awkward/type/OptionType.h +++ b/include/awkward/type/OptionType.h @@ -12,19 +12,19 @@ namespace awkward { : Type(parameters) , type_(type) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr type() const; diff --git a/include/awkward/type/PrimitiveType.h b/include/awkward/type/PrimitiveType.h index ff165648ee..d3519dd367 100644 --- a/include/awkward/type/PrimitiveType.h +++ b/include/awkward/type/PrimitiveType.h @@ -27,19 +27,19 @@ namespace awkward { : Type(parameters) , dtype_(dtype) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const DType dtype() const; diff --git a/include/awkward/type/RecordType.h b/include/awkward/type/RecordType.h index f19e45547d..e6087d242f 100644 --- a/include/awkward/type/RecordType.h +++ b/include/awkward/type/RecordType.h @@ -30,19 +30,19 @@ namespace awkward { const std::shared_ptr lookup() const { return lookup_; } const std::shared_ptr reverselookup() const { return reverselookup_; } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr field(int64_t fieldindex) const; const std::shared_ptr field(const std::string& key) const; diff --git a/include/awkward/type/RegularType.h b/include/awkward/type/RegularType.h index 9f8af20713..2c23a21c63 100644 --- a/include/awkward/type/RegularType.h +++ b/include/awkward/type/RegularType.h @@ -15,19 +15,19 @@ namespace awkward { , type_(type) , size_(size) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; const std::shared_ptr type() const; int64_t size() const; diff --git a/include/awkward/type/UnionType.h b/include/awkward/type/UnionType.h index 0b63a0b274..b7a93bb79e 100644 --- a/include/awkward/type/UnionType.h +++ b/include/awkward/type/UnionType.h @@ -12,19 +12,19 @@ namespace awkward { public: UnionType(const Parameters& parameters, const std::vector>& types): Type(parameters), types_(types) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; int64_t numtypes() const; const std::vector> types() const; diff --git a/include/awkward/type/UnknownType.h b/include/awkward/type/UnknownType.h index 272657c653..0a54bf57b8 100644 --- a/include/awkward/type/UnknownType.h +++ b/include/awkward/type/UnknownType.h @@ -10,19 +10,19 @@ namespace awkward { public: UnknownType(const Parameters& parameters): Type(parameters) { } - virtual std::string tostring_part(std::string indent, std::string pre, std::string post) const; - virtual const std::shared_ptr shallow_copy() const; - virtual bool equal(const std::shared_ptr other, bool check_parameters) const; - virtual std::shared_ptr level() const; - virtual std::shared_ptr inner() const; - virtual std::shared_ptr inner(const std::string& key) const; - virtual int64_t numfields() const; - virtual int64_t fieldindex(const std::string& key) const; - virtual const std::string key(int64_t fieldindex) const; - virtual bool haskey(const std::string& key) const; - virtual const std::vector keyaliases(int64_t fieldindex) const; - virtual const std::vector keyaliases(const std::string& key) const; - virtual const std::vector keys() const; + std::string tostring_part(std::string indent, std::string pre, std::string post) const override; + const std::shared_ptr shallow_copy() const override; + bool equal(const std::shared_ptr other, bool check_parameters) const override; + std::shared_ptr level() const override; + std::shared_ptr inner() const override; + std::shared_ptr inner(const std::string& key) const override; + int64_t numfields() const override; + int64_t fieldindex(const std::string& key) const override; + const std::string key(int64_t fieldindex) const override; + bool haskey(const std::string& key) const override; + const std::vector keyaliases(int64_t fieldindex) const override; + const std::vector keyaliases(const std::string& key) const override; + const std::vector keys() const override; private: }; diff --git a/src/libawkward/Content.cpp b/src/libawkward/Content.cpp index bfca83ddd6..6c98fe8fca 100644 --- a/src/libawkward/Content.cpp +++ b/src/libawkward/Content.cpp @@ -17,7 +17,7 @@ namespace awkward { } const std::shared_ptr Content::type() const { - if (type_.get() == nullptr) { + if (type_ == nullptr) { if (isscalar()) { return innertype(false); } @@ -42,7 +42,7 @@ namespace awkward { } bool Content::isbare() const { - return type_.get() == nullptr; + return type_ == nullptr; } const std::shared_ptr Content::baretype() const { @@ -103,7 +103,7 @@ namespace awkward { } const std::shared_ptr Content::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { - if (head.get() == nullptr) { + if (head == nullptr) { return shallow_copy(); } else if (SliceAt* at = dynamic_cast(head.get())) { diff --git a/src/libawkward/Slice.cpp b/src/libawkward/Slice.cpp index 710e279e52..174ef23a77 100644 --- a/src/libawkward/Slice.cpp +++ b/src/libawkward/Slice.cpp @@ -163,7 +163,7 @@ namespace awkward { } const std::shared_ptr Slice::head() const { - if (items_.size() != 0) { + if (!items_.empty()) { return items_[0]; } else { @@ -173,7 +173,7 @@ namespace awkward { const Slice Slice::tail() const { std::vector> items; - if (items_.size() != 0) { + if (!items_.empty()) { items.insert(items.end(), items_.begin() + 1, items_.end()); } return Slice(items, true); @@ -224,7 +224,7 @@ namespace awkward { std::vector shape; for (size_t i = 0; i < items_.size(); i++) { if (SliceArray64* array = dynamic_cast(items_[i].get())) { - if (shape.size() == 0) { + if (shape.empty()) { shape = array->shape(); } else if (shape.size() != array->ndim()) { @@ -244,7 +244,7 @@ namespace awkward { } } - if (shape.size() != 0) { + if (!shape.empty()) { for (size_t i = 0; i < items_.size(); i++) { if (SliceAt* at = dynamic_cast(items_[i].get())) { Index64 index(1); diff --git a/src/libawkward/array/EmptyArray.cpp b/src/libawkward/array/EmptyArray.cpp index f4dbf4fcc3..6d097800a3 100644 --- a/src/libawkward/array/EmptyArray.cpp +++ b/src/libawkward/array/EmptyArray.cpp @@ -15,7 +15,7 @@ namespace awkward { } void EmptyArray::setid(const std::shared_ptr id) { - if (id.get() != nullptr && length() != id.get()->length()) { + if (id != nullptr && length() != id.get()->length()) { util::handle_error(failure("content and its id must have the same length", kSliceNone, kSliceNone), classname(), id_.get()); } id_ = id; @@ -26,14 +26,14 @@ namespace awkward { const std::string EmptyArray::tostring_part(const std::string indent, const std::string pre, const std::string post) const { std::stringstream out; out << indent << pre << "<" << classname(); - if (id_.get() == nullptr && type_.get() == nullptr) { + if (id_ == nullptr && type_ == nullptr) { out << "/>" << post; } else { - if (id_.get() != nullptr) { + if (id_ != nullptr) { out << ">\n" << id_.get()->tostring_part(indent + std::string(" "), "", "\n") << indent << "" << post; } - if (type_.get() != nullptr) { + if (type_ != nullptr) { out << indent << " " + type().get()->tostring() + "\n"; } } diff --git a/src/libawkward/array/ListArray.cpp b/src/libawkward/array/ListArray.cpp index 7100d24b2e..3691423cde 100644 --- a/src/libawkward/array/ListArray.cpp +++ b/src/libawkward/array/ListArray.cpp @@ -33,7 +33,7 @@ namespace awkward { template <> void ListArrayOf::setid(const std::shared_ptr id) { - if (id.get() == nullptr) { + if (id == nullptr) { content_.get()->setid(id); } else { @@ -87,7 +87,7 @@ namespace awkward { template void ListArrayOf::setid(const std::shared_ptr id) { - if (id.get() == nullptr) { + if (id == nullptr) { content_.get()->setid(id); } else { @@ -141,10 +141,10 @@ namespace awkward { const std::string ListArrayOf::tostring_part(const std::string indent, const std::string pre, const std::string post) const { std::stringstream out; out << indent << pre << "<" << classname() << ">\n"; - if (id_.get() != nullptr) { + if (id_ != nullptr) { out << id_.get()->tostring_part(indent + std::string(" "), "", "\n"); } - if (type_.get() != nullptr) { + if (type_ != nullptr) { out << indent << " " + type().get()->tostring() + "\n"; } out << starts_.tostring_part(indent + std::string(" "), "", "\n"); @@ -205,7 +205,7 @@ namespace awkward { if (stops_.length() < starts_.length()) { util::handle_error(failure("len(stops) < len(starts)", kSliceNone, kSliceNone), classname(), id_.get()); } - if (id_.get() != nullptr && id_.get()->length() < starts_.length()) { + if (id_ != nullptr && id_.get()->length() < starts_.length()) { util::handle_error(failure("len(id) < len(array)", kSliceNone, kSliceNone), id_.get()->classname(), nullptr); } } @@ -258,7 +258,7 @@ namespace awkward { if (regular_stop > stops_.length()) { util::handle_error(failure("len(stops) < len(starts)", kSliceNone, kSliceNone), classname(), id_.get()); } - if (id_.get() != nullptr && regular_stop > id_.get()->length()) { + if (id_ != nullptr && regular_stop > id_.get()->length()) { util::handle_error(failure("index out of range", kSliceNone, stop), id_.get()->classname(), nullptr); } return getitem_range_nowrap(regular_start, regular_stop); @@ -267,7 +267,7 @@ namespace awkward { template const std::shared_ptr ListArrayOf::getitem_range_nowrap(int64_t start, int64_t stop) const { std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_range_nowrap(start, stop); } return std::shared_ptr(new ListArrayOf(id, type_, starts_.getitem_range_nowrap(start, stop), stops_.getitem_range_nowrap(start, stop), content_)); @@ -307,7 +307,7 @@ namespace awkward { carry.length()); util::handle_error(err, classname(), id_.get()); std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } return std::shared_ptr(new ListArrayOf(id, type_, nextstarts, nextstops, content_)); diff --git a/src/libawkward/array/ListOffsetArray.cpp b/src/libawkward/array/ListOffsetArray.cpp index 4810e15570..c317b82919 100644 --- a/src/libawkward/array/ListOffsetArray.cpp +++ b/src/libawkward/array/ListOffsetArray.cpp @@ -43,7 +43,7 @@ namespace awkward { template <> void ListOffsetArrayOf::setid(const std::shared_ptr id) { - if (id.get() == nullptr) { + if (id == nullptr) { content_.get()->setid(id); } else { @@ -93,7 +93,7 @@ namespace awkward { template void ListOffsetArrayOf::setid(const std::shared_ptr id) { - if (id.get() == nullptr) { + if (id == nullptr) { content_.get()->setid(id); } else { @@ -145,10 +145,10 @@ namespace awkward { const std::string ListOffsetArrayOf::tostring_part(const std::string indent, const std::string pre, const std::string post) const { std::stringstream out; out << indent << pre << "<" << classname() << ">\n"; - if (id_.get() != nullptr) { + if (id_ != nullptr) { out << id_.get()->tostring_part(indent + std::string(" "), "", "\n"); } - if (type_.get() != nullptr) { + if (type_ != nullptr) { out << indent << " " + type().get()->tostring() + "\n"; } out << offsets_.tostring_part(indent + std::string(" "), "", "\n"); @@ -205,7 +205,7 @@ namespace awkward { template void ListOffsetArrayOf::check_for_iteration() const { - if (id_.get() != nullptr && id_.get()->length() < offsets_.length() - 1) { + if (id_ != nullptr && id_.get()->length() < offsets_.length() - 1) { util::handle_error(failure("len(id) < len(array)", kSliceNone, kSliceNone), id_.get()->classname(), nullptr); } } @@ -252,7 +252,7 @@ namespace awkward { int64_t regular_start = start; int64_t regular_stop = stop; awkward_regularize_rangeslice(®ular_start, ®ular_stop, true, start != Slice::none(), stop != Slice::none(), offsets_.length() - 1); - if (id_.get() != nullptr && regular_stop > id_.get()->length()) { + if (id_ != nullptr && regular_stop > id_.get()->length()) { util::handle_error(failure("index out of range", kSliceNone, stop), id_.get()->classname(), nullptr); } return getitem_range_nowrap(regular_start, regular_stop); @@ -261,7 +261,7 @@ namespace awkward { template const std::shared_ptr ListOffsetArrayOf::getitem_range_nowrap(int64_t start, int64_t stop) const { std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_range_nowrap(start, stop); } return std::shared_ptr(new ListOffsetArrayOf(id, type_, offsets_.getitem_range_nowrap(start, stop + 1), content_)); @@ -299,7 +299,7 @@ namespace awkward { carry.length()); util::handle_error(err, classname(), id_.get()); std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } return std::shared_ptr(new ListArrayOf(id, type_, nextstarts, nextstops, content_)); diff --git a/src/libawkward/array/NumpyArray.cpp b/src/libawkward/array/NumpyArray.cpp index 484ebfd1c8..930d71d9c1 100644 --- a/src/libawkward/array/NumpyArray.cpp +++ b/src/libawkward/array/NumpyArray.cpp @@ -57,7 +57,7 @@ namespace awkward { } void NumpyArray::setid(const std::shared_ptr id) { - if (id.get() != nullptr && length() != id.get()->length()) { + if (id != nullptr && length() != id.get()->length()) { util::handle_error(failure("content and its id must have the same length", kSliceNone, kSliceNone), classname(), id_.get()); } id_ = id; @@ -197,15 +197,15 @@ namespace awkward { } out << "\" at=\"0x"; out << std::hex << std::setw(12) << std::setfill('0') << reinterpret_cast(ptr_.get()); - if (id_.get() == nullptr && type_.get() == nullptr) { + if (id_ == nullptr && type_ == nullptr) { out << "\"/>" << post; } else { out << "\">\n"; - if (id_.get() != nullptr) { + if (id_ != nullptr) { out << id_.get()->tostring_part(indent + std::string(" "), "", "\n"); } - if (type_.get() != nullptr) { + if (type_ != nullptr) { out << indent << " " + type().get()->tostring() + "\n"; } out << indent << "" << post; @@ -214,7 +214,7 @@ namespace awkward { } void NumpyArray::tojson_part(ToJson& builder) const { - if (type_.get() != nullptr && type_.get()->parameter_equals("__class__", "\"char\"")) { + if (type_ != nullptr && type_.get()->parameter_equals("__class__", "\"char\"")) { tojson_string(builder); } else if (format_.compare("d") == 0) { @@ -337,7 +337,7 @@ namespace awkward { } const std::shared_ptr NumpyArray::type() const { - if (type_.get() == nullptr) { + if (type_ == nullptr) { if (isscalar()) { return innertype(false); } @@ -455,7 +455,7 @@ namespace awkward { } void NumpyArray::check_for_iteration() const { - if (id_.get() != nullptr && id_.get()->length() < shape_[0]) { + if (id_ != nullptr && id_.get()->length() < shape_[0]) { util::handle_error(failure("len(id) < len(array)", kSliceNone, kSliceNone), id_.get()->classname(), nullptr); } } @@ -464,7 +464,7 @@ namespace awkward { const std::vector shape({ 0 }); const std::vector strides({ itemsize_ }); std::shared_ptr id; - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_range_nowrap(0, 0); } return std::shared_ptr(new NumpyArray(id, type_, ptr_, shape, strides, byteoffset_, itemsize_, format_)); @@ -487,7 +487,7 @@ namespace awkward { const std::vector shape(shape_.begin() + 1, shape_.end()); const std::vector strides(strides_.begin() + 1, strides_.end()); std::shared_ptr id; - if (id_.get() != nullptr) { + if (id_ != nullptr) { if (at >= id_.get()->length()) { util::handle_error(failure("index out of range", kSliceNone, at), id_.get()->classname(), nullptr); } @@ -510,7 +510,7 @@ namespace awkward { shape.push_back((ssize_t)(stop - start)); shape.insert(shape.end(), shape_.begin() + 1, shape_.end()); std::shared_ptr id; - if (id_.get() != nullptr) { + if (id_ != nullptr) { if (stop > id_.get()->length()) { util::handle_error(failure("index out of range", kSliceNone, stop), id_.get()->classname(), nullptr); } @@ -530,7 +530,7 @@ namespace awkward { const std::shared_ptr NumpyArray::getitem(const Slice& where) const { assert(!isscalar()); - if (!where.isadvanced() && id_.get() == nullptr) { + if (!where.isadvanced() && id_ == nullptr) { std::vector nextshape = { 1 }; nextshape.insert(nextshape.end(), shape_.begin(), shape_.end()); std::vector nextstrides = { shape_[0]*strides_[0] }; @@ -590,7 +590,7 @@ namespace awkward { util::handle_error(err, classname(), id_.get()); std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } @@ -729,7 +729,7 @@ namespace awkward { } const NumpyArray NumpyArray::getitem_bystrides(const std::shared_ptr& head, const Slice& tail, int64_t length) const { - if (head.get() == nullptr) { + if (head == nullptr) { return NumpyArray(id_, type_, ptr_, shape_, strides_, byteoffset_, itemsize_, format_); } else if (SliceAt* at = dynamic_cast(head.get())) { @@ -791,8 +791,8 @@ namespace awkward { } awkward_regularize_rangeslice(&start, &stop, step > 0, range.hasstart(), range.hasstop(), (int64_t)shape_[1]); - int64_t numer = abs(start - stop); - int64_t denom = abs(step); + int64_t numer = std::abs(start - stop); + int64_t denom = std::abs(step); int64_t d = numer / denom; int64_t m = numer % denom; int64_t lenhead = d + (m != 0 ? 1 : 0); @@ -845,7 +845,7 @@ namespace awkward { } const NumpyArray NumpyArray::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& carry, const Index64& advanced, int64_t length, int64_t stride, bool first) const { - if (head.get() == nullptr) { + if (head == nullptr) { std::shared_ptr ptr(new uint8_t[(size_t)(carry.length()*stride)], awkward::util::array_deleter()); struct Error err = awkward_numpyarray_getitem_next_null_64( reinterpret_cast(ptr.get()), @@ -857,7 +857,7 @@ namespace awkward { util::handle_error(err, classname(), id_.get()); std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } @@ -943,8 +943,8 @@ namespace awkward { } awkward_regularize_rangeslice(&start, &stop, step > 0, range.hasstart(), range.hasstop(), (int64_t)shape_[1]); - int64_t numer = abs(start - stop); - int64_t denom = abs(step); + int64_t numer = std::abs(start - stop); + int64_t denom = std::abs(step); int64_t d = numer / denom; int64_t m = numer % denom; int64_t lenhead = d + (m != 0 ? 1 : 0); diff --git a/src/libawkward/array/Record.cpp b/src/libawkward/array/Record.cpp index 8ab68640eb..684cf84fcd 100644 --- a/src/libawkward/array/Record.cpp +++ b/src/libawkward/array/Record.cpp @@ -1,5 +1,6 @@ // BSD 3-Clause License; see https://github.com/jpivarski/awkward-1.0/blob/master/LICENSE +#include #include #include "awkward/cpu-kernels/identity.h" @@ -20,7 +21,7 @@ namespace awkward { const std::shared_ptr Record::id() const { std::shared_ptr recid = array_.id(); - if (recid.get() == nullptr) { + if (recid == nullptr) { return recid; } else { @@ -52,7 +53,7 @@ namespace awkward { size_t cols = (size_t)numfields(); std::shared_ptr keys = array_.reverselookup(); if (istuple()) { - keys = std::shared_ptr(new RecordArray::ReverseLookup); + keys = std::make_shared(); for (size_t j = 0; j < cols; j++) { keys.get()->push_back(std::to_string(j)); } @@ -94,7 +95,7 @@ namespace awkward { } void Record::check_for_iteration() const { - if (array_.id().get() != nullptr && array_.id().get()->length() != 1) { + if (array_.id() != nullptr && array_.id().get()->length() != 1) { util::handle_error(failure("len(id) != 1 for scalar Record", kSliceNone, kSliceNone), array_.id().get()->classname(), nullptr); } } @@ -125,7 +126,7 @@ namespace awkward { const std::shared_ptr Record::getitem_fields(const std::vector& keys) const { std::shared_ptr type = Type::none(); - if (type_.get() != nullptr && type_.get()->numfields() != -1 && util::subset(keys, type_.get()->keys())) { + if (type_ != nullptr && type_.get()->numfields() != -1 && util::subset(keys, type_.get()->keys())) { type = type_; } RecordArray out(array_.id(), type, length(), istuple()); diff --git a/src/libawkward/array/RecordArray.cpp b/src/libawkward/array/RecordArray.cpp index 72258cd8e0..f1c94c695a 100644 --- a/src/libawkward/array/RecordArray.cpp +++ b/src/libawkward/array/RecordArray.cpp @@ -1,5 +1,6 @@ // BSD 3-Clause License; see https://github.com/jpivarski/awkward-1.0/blob/master/LICENSE +#include #include #include "awkward/cpu-kernels/identity.h" @@ -34,7 +35,7 @@ namespace awkward { } void RecordArray::setid(const std::shared_ptr id) { - if (id.get() == nullptr) { + if (id == nullptr) { for (auto content : contents_) { content.get()->setid(id); } @@ -65,14 +66,14 @@ namespace awkward { const std::string RecordArray::tostring_part(const std::string indent, const std::string pre, const std::string post) const { std::stringstream out; out << indent << pre << "<" << classname(); - if (contents_.size() == 0) { + if (contents_.empty()) { out << " length=\"" << length_ << "\""; } out << ">\n"; - if (id_.get() != nullptr) { + if (id_ != nullptr) { out << id_.get()->tostring_part(indent + std::string(" "), "", "\n"); } - if (type_.get() != nullptr) { + if (type_ != nullptr) { out << indent << " " + type().get()->tostring() + "\n"; } for (size_t j = 0; j < contents_.size(); j++) { @@ -101,7 +102,7 @@ namespace awkward { size_t cols = contents_.size(); std::shared_ptr keys = reverselookup_; if (istuple()) { - keys = std::shared_ptr(new ReverseLookup); + keys = std::make_shared(); for (size_t j = 0; j < cols; j++) { keys.get()->push_back(std::to_string(j)); } @@ -130,7 +131,7 @@ namespace awkward { if (accepts(type)) { std::shared_ptr level = type.get()->level(); RecordType* raw = dynamic_cast(level.get()); - if (reverselookup_.get() == nullptr) { + if (reverselookup_ == nullptr) { for (int64_t i = 0; i < numfields(); i++) { field(i).get()->settype_part(raw->field(i)); } @@ -150,14 +151,14 @@ namespace awkward { bool RecordArray::accepts(const std::shared_ptr type) { std::shared_ptr check = type.get()->level(); if (RecordType* raw = dynamic_cast(check.get())) { - if (reverselookup_.get() == nullptr) { - if (raw->reverselookup().get() != nullptr) { + if (reverselookup_ == nullptr) { + if (raw->reverselookup() != nullptr) { return false; } return numfields() == raw->numfields(); } else { - if (raw->reverselookup().get() == nullptr) { + if (raw->reverselookup() == nullptr) { return false; } for (auto key : raw->keys()) { @@ -174,7 +175,7 @@ namespace awkward { } int64_t RecordArray::length() const { - if (contents_.size() == 0) { + if (contents_.empty()) { return length_; } else { @@ -190,7 +191,7 @@ namespace awkward { } const std::shared_ptr RecordArray::shallow_copy() const { - if (contents_.size() == 0) { + if (contents_.empty()) { return std::shared_ptr(new RecordArray(id_, type_, length(), istuple())); } else { @@ -199,7 +200,7 @@ namespace awkward { } void RecordArray::check_for_iteration() const { - if (id_.get() != nullptr && id_.get()->length() < length()) { + if (id_ != nullptr && id_.get()->length() < length()) { util::handle_error(failure("len(id) < len(array)", kSliceNone, kSliceNone), id_.get()->classname(), nullptr); } } @@ -225,7 +226,7 @@ namespace awkward { } const std::shared_ptr RecordArray::getitem_range(int64_t start, int64_t stop) const { - if (contents_.size() == 0) { + if (contents_.empty()) { int64_t regular_start = start; int64_t regular_stop = stop; awkward_regularize_rangeslice(®ular_start, ®ular_stop, true, start != Slice::none(), stop != Slice::none(), length()); @@ -241,7 +242,7 @@ namespace awkward { } const std::shared_ptr RecordArray::getitem_range_nowrap(int64_t start, int64_t stop) const { - if (contents_.size() == 0) { + if (contents_.empty()) { return std::shared_ptr(new RecordArray(id_, type_, stop - start, istuple())); } else { @@ -259,7 +260,7 @@ namespace awkward { const std::shared_ptr RecordArray::getitem_fields(const std::vector& keys) const { std::shared_ptr type = Type::none(); - if (type_.get() != nullptr && type_.get()->numfields() != -1 && util::subset(keys, type_.get()->keys())) { + if (type_ != nullptr && type_.get()->numfields() != -1 && util::subset(keys, type_.get()->keys())) { type = type_; } RecordArray out(id_, type, length(), istuple()); @@ -277,9 +278,9 @@ namespace awkward { } const std::shared_ptr RecordArray::carry(const Index64& carry) const { - if (contents_.size() == 0) { + if (contents_.empty()) { std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } return std::shared_ptr(new RecordArray(id, type_, carry.length(), istuple())); @@ -290,7 +291,7 @@ namespace awkward { contents.push_back(content.get()->carry(carry)); } std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } return std::shared_ptr(new RecordArray(id, type_, contents, lookup_, reverselookup_)); @@ -298,7 +299,7 @@ namespace awkward { } const std::pair RecordArray::minmax_depth() const { - if (contents_.size() == 0) { + if (contents_.empty()) { return std::pair(0, 0); } int64_t min = kMaxInt64; @@ -438,7 +439,7 @@ namespace awkward { const RecordArray RecordArray::astuple() const { RecordArray out(id_, Type::none(), contents_); - if (type_.get() != nullptr && type_.get()->numfields() != -1 && util::subset(out.keys(), type_.get()->keys())) { + if (type_ != nullptr && type_.get()->numfields() != -1 && util::subset(out.keys(), type_.get()->keys())) { out.type_ = type_; } return out; @@ -459,8 +460,8 @@ namespace awkward { void RecordArray::setkey(int64_t fieldindex, const std::string& fieldname) { if (istuple()) { - lookup_ = std::shared_ptr(new Lookup); - reverselookup_ = std::shared_ptr(new ReverseLookup); + lookup_ = std::make_shared(); + reverselookup_ = std::make_shared(); for (size_t j = 0; j < contents_.size(); j++) { reverselookup_.get()->push_back(std::to_string(j)); } @@ -475,7 +476,7 @@ namespace awkward { Slice emptytail; emptytail.become_sealed(); - if (head.get() == nullptr) { + if (head == nullptr) { return shallow_copy(); } else if (SliceField* field = dynamic_cast(head.get())) { @@ -486,7 +487,7 @@ namespace awkward { std::shared_ptr out = getitem_next(*fields, emptytail, advanced); return out.get()->getitem_next(nexthead, nexttail, advanced); } - else if (contents_.size() == 0) { + else if (contents_.empty()) { RecordArray out(Identity::none(), type_, length(), istuple()); return out.getitem_next(nexthead, nexttail, advanced); } diff --git a/src/libawkward/array/RegularArray.cpp b/src/libawkward/array/RegularArray.cpp index 09efd3b799..76be9c012d 100644 --- a/src/libawkward/array/RegularArray.cpp +++ b/src/libawkward/array/RegularArray.cpp @@ -18,7 +18,7 @@ namespace awkward { } void RegularArray::setid(const std::shared_ptr id) { - if (id.get() == nullptr) { + if (id == nullptr) { content_.get()->setid(id); } else { @@ -84,10 +84,10 @@ namespace awkward { const std::string RegularArray::tostring_part(const std::string indent, const std::string pre, const std::string post) const { std::stringstream out; out << indent << pre << "<" << classname() << " size=\"" << size_ << "\">\n"; - if (id_.get() != nullptr) { + if (id_ != nullptr) { out << id_.get()->tostring_part(indent + std::string(" "), "", "\n"); } - if (type_.get() != nullptr) { + if (type_ != nullptr) { out << indent << " " + type().get()->tostring() + "\n"; } out << content_.get()->tostring_part(indent + std::string(" "), "", "\n"); @@ -141,7 +141,7 @@ namespace awkward { } void RegularArray::check_for_iteration() const { - if (id_.get() != nullptr && id_.get()->length() < length()) { + if (id_ != nullptr && id_.get()->length() < length()) { util::handle_error(failure("len(id) < len(array)", kSliceNone, kSliceNone), id_.get()->classname(), nullptr); } } @@ -170,7 +170,7 @@ namespace awkward { int64_t regular_start = start; int64_t regular_stop = stop; awkward_regularize_rangeslice(®ular_start, ®ular_stop, true, start != Slice::none(), stop != Slice::none(), length()); - if (id_.get() != nullptr && regular_stop > id_.get()->length()) { + if (id_ != nullptr && regular_stop > id_.get()->length()) { util::handle_error(failure("index out of range", kSliceNone, stop), id_.get()->classname(), nullptr); } return getitem_range_nowrap(regular_start, regular_stop); @@ -178,7 +178,7 @@ namespace awkward { const std::shared_ptr RegularArray::getitem_range_nowrap(int64_t start, int64_t stop) const { std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_range_nowrap(start, stop); } return std::shared_ptr(new RegularArray(id_, type_, content_.get()->getitem_range_nowrap(start*size_, stop*size_), size_)); @@ -207,7 +207,7 @@ namespace awkward { util::handle_error(err, classname(), id_.get()); std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { + if (id_ != nullptr) { id = id_.get()->getitem_carry_64(carry); } return std::shared_ptr(new RegularArray(id, type_, content_.get()->carry(nextcarry), size_)); @@ -273,7 +273,7 @@ namespace awkward { assert(range.step() != 0); int64_t regular_start = range.start(); int64_t regular_stop = range.stop(); - int64_t regular_step = abs(range.step()); + int64_t regular_step = std::abs(range.step()); awkward_regularize_rangeslice(®ular_start, ®ular_stop, range.step() > 0, range.start() != Slice::none(), range.stop() != Slice::none(), size_); int64_t nextsize = 0; if (range.step() > 0 && regular_stop - regular_start > 0) { @@ -305,7 +305,7 @@ namespace awkward { std::shared_ptr nextcontent = content_.get()->carry(nextcarry); std::shared_ptr outtype = Type::none(); - if (type_.get() != nullptr) { + if (type_ != nullptr) { RegularType* raw = dynamic_cast(type_.get()); outtype = std::shared_ptr(new RegularType(Type::Parameters(), raw->type(), nextsize)); } diff --git a/src/libawkward/fillable/FillableArray.cpp b/src/libawkward/fillable/FillableArray.cpp index 014407b00a..5d4d085fa0 100644 --- a/src/libawkward/fillable/FillableArray.cpp +++ b/src/libawkward/fillable/FillableArray.cpp @@ -87,7 +87,7 @@ namespace awkward { void FillableArray::endlist() { std::shared_ptr tmp = fillable_.get()->endlist(); - if (tmp.get() == nullptr) { + if (tmp == nullptr) { throw std::invalid_argument("endlist doesn't match a corresponding beginlist"); } maybeupdate(tmp); diff --git a/src/libawkward/fillable/RecordFillable.cpp b/src/libawkward/fillable/RecordFillable.cpp index acc2dc42a4..193fc4af03 100644 --- a/src/libawkward/fillable/RecordFillable.cpp +++ b/src/libawkward/fillable/RecordFillable.cpp @@ -67,7 +67,7 @@ namespace awkward { if (length_ == -1) { return std::shared_ptr(new EmptyArray(Identity::none(), Type::none())); } - else if (contents_.size() == 0) { + else if (contents_.empty()) { std::shared_ptr out(new RecordArray(Identity::none(), Type::none(), length_, false)); if (nameptr_ != nullptr) { std::shared_ptr type = out.get()->type(); diff --git a/src/libawkward/fillable/TupleFillable.cpp b/src/libawkward/fillable/TupleFillable.cpp index ff8b09b76a..b344941bff 100644 --- a/src/libawkward/fillable/TupleFillable.cpp +++ b/src/libawkward/fillable/TupleFillable.cpp @@ -50,7 +50,7 @@ namespace awkward { if (length_ == -1) { return std::shared_ptr(new EmptyArray(Identity::none(), Type::none())); } - else if (contents_.size() == 0) { + else if (contents_.empty()) { return std::shared_ptr(new RecordArray(Identity::none(), Type::none(), length_, true)); } else { diff --git a/src/libawkward/fillable/UnionFillable.cpp b/src/libawkward/fillable/UnionFillable.cpp index e45c15e594..6f33d5a4f0 100644 --- a/src/libawkward/fillable/UnionFillable.cpp +++ b/src/libawkward/fillable/UnionFillable.cpp @@ -79,7 +79,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { tofill = BoolFillable::fromempty(options_); contents_.push_back(tofill); } @@ -105,7 +105,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { tofill = Int64Fillable::fromempty(options_); contents_.push_back(tofill); } @@ -131,7 +131,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { i = 0; for (auto content : contents_) { if (dynamic_cast(content.get()) != nullptr) { @@ -140,7 +140,7 @@ namespace awkward { } i++; } - if (tofill.get() != nullptr) { + if (tofill != nullptr) { tofill = Float64Fillable::fromint64(options_, dynamic_cast(tofill.get())->buffer()); contents_[(size_t)i] = tofill; } @@ -173,7 +173,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { tofill = StringFillable::fromempty(options_, encoding); contents_.push_back(tofill); } @@ -199,7 +199,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { tofill = ListFillable::fromempty(options_); contents_.push_back(tofill); } @@ -240,7 +240,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { tofill = TupleFillable::fromempty(options_); contents_.push_back(tofill); } @@ -292,7 +292,7 @@ namespace awkward { } i++; } - if (tofill.get() == nullptr) { + if (tofill == nullptr) { tofill = RecordFillable::fromempty(options_); contents_.push_back(tofill); } diff --git a/src/libawkward/type/ListType.cpp b/src/libawkward/type/ListType.cpp index 08f0e25a13..b81d91ce35 100644 --- a/src/libawkward/type/ListType.cpp +++ b/src/libawkward/type/ListType.cpp @@ -16,7 +16,7 @@ namespace awkward { } std::stringstream out; - if (parameters_.size() == 0) { + if (parameters_.empty()) { out << indent << pre << "var * " << type_.get()->tostring_part(indent, "", "") << post; } else { diff --git a/src/libawkward/type/OptionType.cpp b/src/libawkward/type/OptionType.cpp index 0831624b73..84e8fff3b3 100644 --- a/src/libawkward/type/OptionType.cpp +++ b/src/libawkward/type/OptionType.cpp @@ -17,7 +17,7 @@ namespace awkward { } std::stringstream out; - if (parameters_.size() == 0) { + if (parameters_.empty()) { if (dynamic_cast(type_.get()) != nullptr || dynamic_cast(type_.get()) != nullptr) { out << indent << pre << "option[" << type_.get()->tostring_part(indent, "", "") << "]" << post; diff --git a/src/libawkward/type/PrimitiveType.cpp b/src/libawkward/type/PrimitiveType.cpp index 5164a5c00d..56341902be 100644 --- a/src/libawkward/type/PrimitiveType.cpp +++ b/src/libawkward/type/PrimitiveType.cpp @@ -31,7 +31,7 @@ namespace awkward { case float64: s = "float64"; break; default: assert(dtype_ < numtypes); } - if (parameters_.size() == 0) { + if (parameters_.empty()) { out << indent << pre << s << post; } else { diff --git a/src/libawkward/type/RecordType.cpp b/src/libawkward/type/RecordType.cpp index 3c1d6e98d7..25902e6e02 100644 --- a/src/libawkward/type/RecordType.cpp +++ b/src/libawkward/type/RecordType.cpp @@ -17,8 +17,8 @@ namespace awkward { } std::stringstream out; - if (parameters_.size() == 0) { - if (reverselookup_.get() == nullptr) { + if (parameters_.empty()) { + if (reverselookup_ == nullptr) { out << "("; for (size_t j = 0; j < types_.size(); j++) { if (j != 0) { @@ -41,7 +41,7 @@ namespace awkward { } } else { - if (reverselookup_.get() == nullptr) { + if (reverselookup_ == nullptr) { out << "tuple[["; for (size_t j = 0; j < types_.size(); j++) { if (j != 0) { @@ -83,8 +83,8 @@ namespace awkward { if (numfields() != t->numfields()) { return false; } - if (reverselookup_.get() == nullptr) { - if (t->reverselookup().get() != nullptr) { + if (reverselookup_ == nullptr) { + if (t->reverselookup() != nullptr) { return false; } for (int64_t j = 0; j < numfields(); j++) { @@ -95,7 +95,7 @@ namespace awkward { return true; } else { - if (t->reverselookup().get() == nullptr) { + if (t->reverselookup() == nullptr) { return false; } if (lookup_.get()->size() != t->lookup().get()->size()) { @@ -139,7 +139,7 @@ namespace awkward { int64_t RecordType::fieldindex(const std::string& key) const { int64_t out = -1; - if (lookup_.get() != nullptr) { + if (lookup_ != nullptr) { try { out = (int64_t)lookup_.get()->at(key); } @@ -166,7 +166,7 @@ namespace awkward { if (fieldindex >= numfields()) { throw std::invalid_argument(std::string("fieldindex ") + std::to_string(fieldindex) + std::string(" for RecordType with only " + std::to_string(numfields()) + std::string(" fields"))); } - if (reverselookup_.get() != nullptr) { + if (reverselookup_ != nullptr) { return reverselookup_.get()->at((size_t)fieldindex); } else { @@ -188,7 +188,7 @@ namespace awkward { std::vector out; std::string _default = std::to_string(fieldindex); bool has_default = false; - if (lookup_.get() != nullptr) { + if (lookup_ != nullptr) { for (auto pair : *lookup_.get()) { if (pair.second == fieldindex) { out.push_back(pair.first); @@ -210,7 +210,7 @@ namespace awkward { const std::vector RecordType::keys() const { std::vector out; - if (reverselookup_.get() == nullptr) { + if (reverselookup_ == nullptr) { int64_t cols = numfields(); for (int64_t j = 0; j < cols; j++) { out.push_back(std::to_string(j)); @@ -239,7 +239,7 @@ namespace awkward { const std::vector>> RecordType::fielditems() const { std::vector>> out; - if (reverselookup_.get() == nullptr) { + if (reverselookup_ == nullptr) { size_t cols = types_.size(); for (size_t j = 0; j < cols; j++) { out.push_back(std::pair>(std::to_string(j), types_[j])); diff --git a/src/libawkward/type/RegularType.cpp b/src/libawkward/type/RegularType.cpp index 9683b285d7..f6a579024d 100644 --- a/src/libawkward/type/RegularType.cpp +++ b/src/libawkward/type/RegularType.cpp @@ -16,7 +16,7 @@ namespace awkward { } std::stringstream out; - if (parameters_.size() == 0) { + if (parameters_.empty()) { out << indent << pre << size_ << " * " << type_.get()->tostring_part(indent, "", "") << post; } else { diff --git a/src/libawkward/type/UnionType.cpp b/src/libawkward/type/UnionType.cpp index 560a99a82b..be45e312f5 100644 --- a/src/libawkward/type/UnionType.cpp +++ b/src/libawkward/type/UnionType.cpp @@ -23,7 +23,7 @@ namespace awkward { } out << type(i).get()->tostring_part(indent, "", ""); } - if (parameters_.size() != 0) { + if (!parameters_.empty()) { out << ", " << string_parameters(); } out << "]" << post; diff --git a/src/libawkward/type/UnknownType.cpp b/src/libawkward/type/UnknownType.cpp index dae16d03ab..128d4e61fc 100644 --- a/src/libawkward/type/UnknownType.cpp +++ b/src/libawkward/type/UnknownType.cpp @@ -13,7 +13,7 @@ namespace awkward { } std::stringstream out; - if (parameters_.size() == 0) { + if (parameters_.empty()) { out << indent << pre << "unknown" << post; } else {