nw::TwoDA
-
struct TwoDA
Public Types
-
using RowType = std::vector<detail::StringVariant>
Public Functions
-
TwoDA() = default
-
TwoDA(const TwoDA&) = delete
-
TwoDA(TwoDA&&) = default
-
~TwoDA() = default
-
explicit TwoDA(const std::filesystem::path &filename)
Constructs TwoDA object from a file.
-
explicit TwoDA(ResourceData data)
Constructs TwoDA object from an array of bytes.
-
explicit TwoDA(std::string_view data)
Constructs TwoDA object from a string.
-
bool add_column(StringView name)
Appends new column with default
****values.
-
size_t column_index(StringView column) const
Finds the index of a column, or -1.
-
inline const Vector<String> &column_names() const noexcept
Gets list of column names.
-
size_t columns() const noexcept
Get the number of columns.
-
template<typename T>
std::optional<T> get(size_t row, size_t col) const Gets an element.
-
template<typename T>
std::optional<T> get(size_t row, StringView col) const Gets an element.
-
template<typename T>
bool get_to(size_t row, size_t col, T &out) const Gets an element.
-
template<typename T>
bool get_to(size_t row, StringView col, T &out) const Gets an element.
-
StringView get_raw(size_t row, size_t col) const
Gets raw twoda value.
-
bool is_valid() const noexcept
Is the 2da parsed without error.
-
void pad(size_t count)
Pads the 2da with
countrows.
-
size_t rows() const noexcept
Number of rows.
-
template<typename T>
void set(size_t row, size_t col, const T &value) Sets an element.
-
template<typename T>
void set(size_t row, StringView col, const T &value) Sets an element.
Public Static Attributes
-
static constexpr size_t npos = std::numeric_limits<size_t>::max()
Friends
-
friend std::ostream &operator<<(std::ostream &out, const TwoDA &tda)
Overload for
operator<<
-
using RowType = std::vector<detail::StringVariant>