载入中...
搜索中...
未找到
AttributeTable.cpp
浏览该文件的文档.
21Result<std::size_t> AttributeTable::appendRowFrom(const AttributeTable& source, std::size_t sourceRow) {
24 Diagnostic::error(DiagnosticCode::InvalidArgument, "source attribute row is out of range", "sourceRow"));
83 Diagnostic::error(DiagnosticCode::InvalidArgument, "builtin selectors cannot be renamed", "from"));
86 Diagnostic::error(DiagnosticCode::InvalidArgument, "builtin selectors cannot be rename targets", "to"));
93 Diagnostic::error(DiagnosticCode::NotFound, "attribute '" + fromKey + "' does not exist", "from"));
96 Diagnostic::error(DiagnosticCode::AlreadyExists, "attribute '" + toKey + "' already exists", "to"));
113 Diagnostic::error(DiagnosticCode::InvalidArgument, "attribute name must not be empty", "name"));
115 Diagnostic::error(DiagnosticCode::InvalidArgument, "builtin selectors cannot be deleted", "name"));
123 staged.order_.erase(std::remove(staged.order_.begin(), staged.order_.end(), key), staged.order_.end());
130 Diagnostic::error(DiagnosticCode::InvalidArgument, "attribute name must not be empty", "name"));
133 Diagnostic::error(DiagnosticCode::InvalidArgument, "copyColumn only supports metadata column names", "name"));
140 Diagnostic::error(DiagnosticCode::NotFound, "attribute '" + fromKey + "' does not exist", "from"));
157Result<AttributeTable::Column*> AttributeTable::ensureColumn(std::string_view name, ProcgenAttributeType type) {
174 case ProcgenAttributeType::Float: replacement.storage = std::vector<std::optional<float>>(rows_); break;
175 case ProcgenAttributeType::Int: replacement.storage = std::vector<std::optional<std::int64_t>>(rows_); break;
176 case ProcgenAttributeType::Bool: replacement.storage = std::vector<std::optional<bool>>(rows_); break;
180 case ProcgenAttributeType::String: replacement.storage = std::vector<std::optional<std::string>>(rows_); break;
193Result<void> AttributeTable::set(std::size_t row, std::string_view name, ProcgenAttributeType type, T value) {
195 Diagnostic::error(DiagnosticCode::InvalidArgument, "attribute name must not be empty", "name"));
205std::optional<T> AttributeTable::get(std::size_t row, std::string_view name, ProcgenAttributeType type) const {
214Result<void> AttributeTable::setInt(std::size_t row, std::string_view name, std::int64_t value) {
220Result<void> AttributeTable::setVector(std::size_t row, std::string_view name, ProcgenAttributeVector value) {
223Result<void> AttributeTable::setString(std::size_t row, std::string_view name, std::string value) {
229std::optional<std::int64_t> AttributeTable::getInt(std::size_t row, std::string_view name) const {
235std::optional<ProcgenAttributeVector> AttributeTable::getVector(std::size_t row, std::string_view name) const {
238std::optional<std::string_view> AttributeTable::getString(std::size_t row, std::string_view name) const {
240 if (found == columns_.end() || found->second.type != ProcgenAttributeType::String || row >= rows_)
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Schema-bearing column store aligned with a PointSet's point rows.
Definition AttributeTable.h:33
std::optional< std::string_view > getString(std::size_t row, std::string_view name) const
Borrow a string value until the next table mutation, or return no value.
Definition AttributeTable.cpp:238
Result< void > copyColumn(std::string_view from, std::string_view to)
Copy one typed column onto another name, creating or overwriting a compatible target.
Definition AttributeTable.cpp:128
std::optional< std::int64_t > getInt(std::size_t row, std::string_view name) const
Read an integer value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:229
bool has(std::size_t row, std::string_view name) const
Return whether a row contains a value in the named column.
Definition AttributeTable.cpp:72
std::optional< ProcgenAttributeVector > getVector(std::size_t row, std::string_view name) const
Read a vector value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:235
std::size_t appendRow()
Append one empty row and return its stable row index.
Definition AttributeTable.cpp:16
std::size_t columnCount() const noexcept
Return the number of declared columns.
Definition AttributeTable.cpp:64
std::size_t rowCount() const noexcept
Return the number of aligned point rows.
Definition AttributeTable.cpp:11
std::optional< bool > getBool(std::size_t row, std::string_view name) const
Read a Boolean value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:232
Result< void > removeColumn(std::string_view name)
Remove one metadata column and its values from every row.
Definition AttributeTable.cpp:111
Result< void > setBool(std::size_t row, std::string_view name, bool value)
Set a Boolean value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:217
Result< void > setInt(std::size_t row, std::string_view name, std::int64_t value)
Set an integer value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:214
Result< void > setFloat(std::size_t row, std::string_view name, float value)
Set a float value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:211
Result< std::size_t > appendRowFrom(const AttributeTable &source, std::size_t sourceRow)
Append one row copied from another table, merging compatible schema columns.
Definition AttributeTable.cpp:21
std::string_view columnName(std::size_t index) const noexcept
Return a stable insertion-ordered column name or an empty string.
Definition AttributeTable.cpp:65
Result< void > setVector(std::size_t row, std::string_view name, ProcgenAttributeVector value)
Set a vector value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:220
Result< void > renameColumn(std::string_view from, std::string_view to)
Rename one metadata column without changing values or type.
Definition AttributeTable.cpp:78
Result< void > setString(std::size_t row, std::string_view name, std::string value)
Set a string value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:223
void resize(std::size_t rows)
Resize every column to the same row count.
Definition AttributeTable.cpp:12
Result< void > clearRow(std::size_t row)
Clear every value in one row while preserving the table schema.
Definition AttributeTable.cpp:53
std::optional< float > getFloat(std::size_t row, std::string_view name) const
Read a float value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:226
std::optional< ProcgenAttributeType > typeOf(std::string_view name) const
Return the declared type for a name, or no value when absent.
Definition AttributeTable.cpp:68
Definition EvpackPointGraphLoader.h:12
ProcgenAttributeType
Closed set of column types supported by procedural point metadata.
Definition AttributeTable.h:23
std::string_view procgenAttributeTypeName(ProcgenAttributeType type) noexcept
Return the stable script/persistence name for an attribute type.
Definition AttributeTable.cpp:246
@ InvalidArgument
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
@ NotFound
@ AlreadyExists
Compact three-component value used by typed procedural metadata.
Definition AttributeTable.h:16