#pragma once #include #include #include "storage/model/properties/flags.hpp" template using ArrayStore = std::vector; template class Array { public: const static Type type; using Arr = ArrayStore; Array(Arr &&value) : data(std::make_shared(std::move(value))) {} Arr &value() { return *data.get(); } Arr const &value() const { return *data.get(); } std::ostream &print(std::ostream &stream) const { stream << "["; for (auto e : value()) { stream << e << ","; } stream << "]"; return stream; } friend std::ostream &operator<<(std::ostream &stream, const Array &prop) { return prop.print(stream); } bool operator==(const Array &other) const { return *this == other.value(); } bool operator==(const Arr &other) const { auto arr = value(); if (arr.size() != other.size()) { return false; } auto n = arr.size(); for (size_t i = 0; i < n; i++) { if (arr[i] != other[i]) { return false; } } return true; } // NOTE: OTHER METHODS WILL AUTOMATICALLY USE THIS IN CERTAIN SITUATIONS TO // MOVE ARR OUT OF SHARED_PTR WHICH IS BAD // operator const Arr &() const { return value(); }; private: std::shared_ptr data; }; using ArrayString = Array; using ArrayBool = Array; using ArrayInt32 = Array; using ArrayInt64 = Array; using ArrayFloat = Array; using ArrayDouble = Array;