added collection, collection proxy and collection resolver implementations

This commit is contained in:
2026-01-18 22:11:51 +01:00
parent 4c899ae2f2
commit 623a64b610
15 changed files with 214 additions and 44 deletions
+35 -4
View File
@@ -1,7 +1,7 @@
#ifndef COLLECTION_HPP
#define COLLECTION_HPP
#include <vector>
#include "matador/object/collection_proxy.hpp"
namespace matador::object {
@@ -9,12 +9,43 @@ template < class Type >
class collection {
public:
using value_type = Type;
using iterator = typename std::vector<value_type>::iterator;
using const_iterator = typename std::vector<value_type>::const_iterator;
void push_back(const Type& value) { data_.push_back(value); }
void push_back(const value_type& value) {
proxy_->items().push_back(value);
}
iterator begin() {
return proxy_->items().begin();
}
iterator end() {
return proxy_->items().end();
}
const_iterator begin() const {
return proxy_->items().begin();
}
const_iterator end() const {
return proxy_->items().end();
}
[[nodiscard]] size_t size() const {
return proxy_->items().size();
}
[[nodiscard]] bool empty() const {
return proxy_->items_.empty();
}
void reset(std::shared_ptr<collection_proxy<typename Type::value_type>> proxy) {
proxy_ = std::move(proxy);
}
[[nodiscard]] size_t size() const { return data_.size(); }
private:
std::vector<Type> data_;
std::shared_ptr<collection_proxy<typename Type::value_type>> proxy_;
};
}