3#include <StormByte/database/value.hxx>
13namespace StormByte::Database {
18 class STORMBYTE_DATABASE_PUBLIC
Row {
26 using iterator_category = std::random_access_iterator_tag;
28 using difference_type = std::ptrdiff_t;
37 return (*m_row)[m_index];
45 return &(*m_row)[m_index];
92 m_index =
static_cast<std::size_t
>(
static_cast<difference_type
>(m_index) + n);
102 m_index =
static_cast<std::size_t
>(
static_cast<difference_type
>(m_index) - n);
134 return static_cast<difference_type
>(m_index) -
static_cast<difference_type
>(other.m_index);
143 return m_row == other.m_row && m_index == other.m_index;
152 return !(*
this == other);
164 m_row(row), m_index(index) {}
172 using iterator_category = std::random_access_iterator_tag;
174 using difference_type = std::ptrdiff_t;
183 return (*m_row)[m_index];
191 return &(*m_row)[m_index];
238 m_index =
static_cast<std::size_t
>(
static_cast<difference_type
>(m_index) + n);
248 m_index =
static_cast<std::size_t
>(
static_cast<difference_type
>(m_index) - n);
280 return static_cast<difference_type
>(m_index) -
static_cast<difference_type
>(other.m_index);
287 return (*m_row)[m_index +
static_cast<std::size_t
>(n)];
296 return m_row == other.m_row && m_index == other.m_index;
305 return !(*
this == other);
317 m_row(row), m_index(index) {}
323 using iterator = Iterator;
324 using const_iterator = ConstIterator;
325 using reverse_iterator = std::reverse_iterator<iterator>;
326 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
348 ~
Row() noexcept = default;
355 Row& operator=(const
Row& other) = default;
362 Row& operator=(
Row&& other) noexcept = default;
370 const
Value& operator[](std::
size_t index) const &;
378 Value& operator[](std::
size_t index) &;
386 Value operator[](std::
size_t index) &&;
394 const
Value& operator[](const std::
string& columnName) const &;
402 Value& operator[](const std::
string& columnName) &;
410 Value operator[](const std::
string& columnName) &&;
417 inline
void Add(std::
string&& columnName,
Value&& value) {
418 m_values.emplace_back(std::move(columnName), std::move(value));
434 return Iterator(
this, m_values.size());
473 inline reverse_iterator
rbegin() noexcept {
474 return reverse_iterator(end());
481 inline reverse_iterator
rend() noexcept {
482 return reverse_iterator(begin());
489 inline const_reverse_iterator
rbegin() const noexcept {
490 return const_reverse_iterator(end());
497 inline const_reverse_iterator
rend() const noexcept {
498 return const_reverse_iterator(begin());
505 inline std::size_t
Count() const noexcept {
506 return m_values.size();
510 std::vector<std::pair<std::string, Value>> m_values;
ConstIterator & operator--() noexcept
Pre-decrement operator.
Definition row.hxx:217
ConstIterator & operator++()
Pre-increment operator.
Definition row.hxx:198
bool operator==(const ConstIterator &other) const noexcept
Equality operator.
Definition row.hxx:295
ConstIterator & operator+=(difference_type n) noexcept
Addition assignment operator.
Definition row.hxx:237
pointer operator->() const
Arrow operator.
Definition row.hxx:190
ConstIterator & operator-=(difference_type n) noexcept
Subtraction assignment operator.
Definition row.hxx:247
bool operator!=(const ConstIterator &other) const noexcept
Inequality operator.
Definition row.hxx:304
difference_type operator-(const ConstIterator &other) const noexcept
Difference operator.
Definition row.hxx:279
ConstIterator operator--(int) noexcept
Post-decrement operator.
Definition row.hxx:226
ConstIterator operator+(difference_type n) const noexcept
Addition operator.
Definition row.hxx:257
reference operator*() const
Dereference operator.
Definition row.hxx:182
ConstIterator operator-(difference_type n) const noexcept
Subtraction operator.
Definition row.hxx:268
ConstIterator operator++(int)
Post-increment operator.
Definition row.hxx:207
reference operator[](difference_type n) const
Definition row.hxx:286
Iterator class for Row.
Definition row.hxx:24
Iterator & operator--() noexcept
Pre-decrement operator.
Definition row.hxx:71
Iterator operator--(int) noexcept
Post-decrement operator.
Definition row.hxx:80
Iterator operator-(difference_type n) const noexcept
Subtraction operator.
Definition row.hxx:122
bool operator==(const Iterator &other) const noexcept
Equality operator.
Definition row.hxx:142
reference operator*()
Dereference operator.
Definition row.hxx:36
Iterator & operator++()
Pre-increment operator.
Definition row.hxx:52
Iterator operator+(difference_type n) const noexcept
Addition operator.
Definition row.hxx:111
pointer operator->()
Arrow operator.
Definition row.hxx:44
difference_type operator-(const Iterator &other) const noexcept
Difference operator.
Definition row.hxx:133
Iterator & operator-=(difference_type n) noexcept
Subtraction assignment operator.
Definition row.hxx:101
Iterator & operator+=(difference_type n) noexcept
Addition assignment operator.
Definition row.hxx:91
bool operator!=(const Iterator &other) const noexcept
Inequality operator.
Definition row.hxx:151
Iterator operator++(int)
Post-increment operator.
Definition row.hxx:61
Row class for databases.
Definition row.hxx:18
reverse_iterator rbegin() noexcept
Gets reverse begin iterator.
Definition row.hxx:473
std::size_t Count() const noexcept
Gets number of columns in the Row.
Definition row.hxx:505
const_iterator begin() const noexcept
Gets const begin iterator.
Definition row.hxx:441
const_reverse_iterator rend() const noexcept
Gets const reverse end iterator.
Definition row.hxx:497
reverse_iterator rend() noexcept
Gets reverse end iterator.
Definition row.hxx:481
const_iterator cbegin() const noexcept
Gets const begin iterator.
Definition row.hxx:457
const_iterator end() const noexcept
Gets const end iterator.
Definition row.hxx:449
iterator begin() noexcept
Gets begin iterator.
Definition row.hxx:425
iterator end() noexcept
Gets end iterator.
Definition row.hxx:433
const_iterator cend() const noexcept
Gets const end iterator.
Definition row.hxx:465
Row() noexcept=default
Default Constructor.
const_reverse_iterator rbegin() const noexcept
Gets const reverse begin iterator.
Definition row.hxx:489
Value class for databases.
Definition value.hxx:20