Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions include/rfl/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,19 @@ class Object {
auto max_size() const { return data_.max_size(); }

/// Inserts a new element at the end.
void insert(const value_type& _value) {
data_.push_back(_value);
template <class... Args>
void insert(const Args&... _values) {
(data_.push_back(_values), ...);
i_ = 0;
}

/// Inserts a new element at the end.
void insert(value_type&& _value) {
data_.emplace_back(std::move(_value));
template <class... Args>
void insert(Args&&... _values) {
(data_.emplace_back(std::move(_values)), ...);
i_ = 0;
}

/// Inserts several new elements at the end.
template <class InputIt>
void insert(InputIt _first, InputIt _last) {
for (auto it = _first; it != _last; ++it) {
insert(*it);
}
}

/// Inserts a new element at the end.
void insert(const std::string& _k, const T& _v) {
insert(std::make_pair(_k, _v));
Expand Down Expand Up @@ -152,6 +146,22 @@ class Object {
insert(_args...);
}

/// Inserts several new elements at the end.
template <class InputIt>
void insert_range(InputIt _first, InputIt _last) {
for (auto it = _first; it != _last; ++it) {
insert(*it);
}
}

/// Inserts several new elements at the end.
template <class RangeType>
void insert_range(RangeType _range) {
for (const auto& val : _range) {
insert(val);
}
}

/// Returns the element signified by the key or creates a new one.
T& operator[](const std::string& _key) {
const auto i = find(_key);
Expand Down
Loading