Class Row

Synopsis

#include <orm_lib/inc/drogon/orm/Row.h>

class Row

Description

Reference to one row in a result.

A row represents one row (also called a row) in a query result set. It also acts as a container mapping column numbers or names to field values (see below):

    cout << row["date"].as<std::string>() << ": " <<
*row["name"].as<std::string>() << endl;

The row itself acts like a (non-modifyable) container, complete with its own const_iterator and const_reverse_iterator.

Mentioned in

Inheritance

Decsendents: ConstResultIterator

Methods

Row
at
begin
capacity
cbegin
cend
crbegin
crend
end
operator[]
rbegin
rend
size

Source

Lines 44-95 in orm_lib/inc/drogon/orm/Row.h. Line 45 in orm_lib/inc/drogon/orm/Row.h.

class Row
{
  public:
    using SizeType = unsigned long;
    using Reference = Field;
    using ConstIterator = ConstRowIterator;
    using Iterator = ConstIterator;
    using ConstReverseIterator = ConstReverseRowIterator;

    using DifferenceType = long;

    Reference operator[](SizeType index) const noexcept;
    Reference operator[](const char columnName[]) const;
    Reference operator[](const std::string &columnName) const;

    Reference at(SizeType index) const;
    Reference at(const char columnName[]) const;
    Reference at(const std::string &columnName) const;

    SizeType size() const;
    SizeType capacity() const noexcept
    {
        return size();
    }
    ConstIterator begin() const noexcept;
    ConstIterator cbegin() const noexcept;
    ConstIterator end() const noexcept;
    ConstIterator cend() const noexcept;

    ConstReverseIterator rbegin() const;
    ConstReverseIterator crbegin() const;
    ConstReverseIterator rend() const;
    ConstReverseIterator crend() const;

    Row(const Row &r) noexcept = default;
    Row(Row &&) noexcept = default;

  private:
    const Result result_;

  protected:
    friend class Field;
    /**
     * Row number
     * You'd expect this to be a size_t, but due to the way reverse iterators
     * are related to regular iterators, it must be allowed to underflow to -1.
     */
    long index_{0};
    Row::SizeType end_{0};
    friend class Result;
    Row(const Result &r, SizeType index) noexcept;
};





Add Discussion as Guest

Log in to DocsForge