-
Notifications
You must be signed in to change notification settings - Fork 2
row_base
A xlang::meta::reader::row_base<Row> structure represents a row in a database table, as well as a random-access iterator to that row.
The row_base<Row> is unusual in that it is its own iterator. (Dereferencing the row_base<Row> returns itself!)
A row_base<Row> can be empty. All operations on an empty row_base<Row> are invalid, aside from the operator bool() that reports whether the object is valid or empty.
Do not construct a row_base<Row> object directly. Use only row_base<Row> objects obtained from the database.
A row_base<Row> object is valid only as long as its corresponding database is loaded.
operator bool() const noexcept;Returns true if the row_base<Row> is valid, or false if it is empty. If the row_base<Row> is empty, then no other methods may be called.
Performance: O(1). Very fast.
xlang::meta::reader::database const& get_database() const noexcept;Returns a reference to the database that contains this row.
Performance: O(1). Very fast.
xlang::meta::reader::cache const& get_cache() const noexcept;Returns a reference to the cache that contains this row's database.
Performance: O(1). Very fast.
The row_base<Row> defines the operations and namespace types as required for it to be considered a random-access iterator by standard algorithms.
-
iterator_categoryisstd::random_access_iterator_tag. -
value_typeisRow, the type this row represents. -
difference_typeisint32_t. -
pointerisRow*. -
referenceisRow&. -
const_referenceisRow const&.
-
row + nandrow - nreturn a new iterator that is ahead of or behind the current iterator. -
++row,row++,--row, androw--move the iterator forward or backward one step. -
row +=nandrow -= nmove the iterator forward or backward by multiple steps. -
*rowaccesses the object pointed to by the iterator. -
row[n]accesses the objectnsteps ahead of (or behind, if negative) the current iterator. -
row1 - row2returns the signed distance between the two rows. - All relational operators are supported in the natural way.
You will typically not call these members directly, but will instead use wrapper functions provided by derived types.
template<typename T> T
get_value(uint32_t column) const;Returns the value in the specified column of the row.
T must be an enumeration or an unsigned integer type.
If T is not large enough to represent the value of the column, the value is truncated.
Performance: O(1). This looks up data in the table and parses it.
Exceptions: Throws std::invalid_argument if the row is not valid. This typically is the result of a corrupted database.
template<typename T> std::pair<T, T>
get_list(uint32_t column) const;Returns a range of T objects (in the form of a pair of iterators) referenced by the specified column of the row.
Performance: O(1). This looks up multiple pieces of data in the table.
Exceptions: Throws std::invalid_argument if the row is not valid. This typically is the result of a corrupted database.
- get_target_row
template<typename T> xmr::row_base<T>
get_target_row(uint32_t column) const;Returns a row from the T table as indexed by the value in the indicated column. The returned row is not validated.
Performance: O(1). This looks up data in the table and parses it.
Exceptions: Throws std::invalid_argument if the row is not valid. This typically is the result of a corrupted database.
- get_parent_row
template<typename T, uint32_t ParentColumn>
xmr::row_base<T> get_parent_row() const;Returns a row from the T table as indexed by the value in the indicated column of the T table. The returned row is not validated.
This is the inverse of get_target_row. The T table must be sorted on the ParentColumn, and the ParentColumn must contain the index of a row in the current table.
Performance: O(log n) where n is the size of the T table.
Exceptions: Throws std::invalid_argument if the row is not valid. This typically is the result of a corrupted database.
These members are primarily for internal use by the database management code.
uint32_t index() const noexcept;Returns the row number of the row within its table.
Performance: O(1). Very fast.
template<typename T> xmr::coded_index<T> coded_index() const noexcept;Returns a coded_index that captures information on how to locate this row.
This method is useful if you have a row, and you need to produce a particular kind of coded_index that refers to it. For example, you have a TypeDef object, but you need to pass it to a function that expects a coded_index<TypeDefOrRef>. Call coded_index<TypeDefOrRef>() to produce the value that resolves back to the original TypeDef object.
Arguably, since this is a conversion, it should be named as_coded_index.
Performance: O(1). Very fast.