ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
resource_keys.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
12
13#include "reusex/core/ProjectDB.hpp"
14#include "reusex/core/materialepas_traits.hpp"
15
16#include <optional>
17#include <stdexcept>
18#include <string>
19#include <string_view>
20#include <utility>
21#include <vector>
22
23namespace reusex::core {
24
28enum class KeyScope { type, part };
29std::string_view to_string(KeyScope); // "type" | "part"
30
31inline constexpr std::string_view kBuiltinCategory = "Kortlægning";
32inline constexpr std::string_view kColumnCategory = "Egne felter";
33
35 std::string id;
36 std::string label;
37 std::string category;
42 std::string data_type = "text";
43 std::string unit;
44 std::vector<std::string> options;
45 bool editable = true;
49 std::string field;
51 bool integer = false;
52};
53
61
63std::vector<LeksikonField> leksikon_fields();
65std::vector<std::string> leksikon_categories();
66
67std::vector<ResourceKey> builtin_keys();
68std::vector<ResourceKey> leksikon_keys();
72std::vector<ResourceKey>
73key_catalogue(const std::vector<ProjectDB::PropertyDefinition> &columns);
74std::vector<ResourceKey> key_catalogue(const ProjectDB &db);
76const ResourceKey *find_key(const std::vector<ResourceKey> &catalogue,
77 std::string_view id);
78
81class KeyValueError : public std::invalid_argument {
82 public:
83 KeyValueError(std::string key, const std::string &message)
84 : std::invalid_argument(message), key_(std::move(key)) {}
85 const std::string &key() const noexcept { return key_; }
86
87 private:
88 std::string key_;
89};
90
93std::optional<double> parse_number(std::string_view text);
95std::string format_number(double v);
96
106std::optional<std::string>
108 const std::optional<std::string> &value);
109
110} // namespace reusex::core
KeyValueError(std::string key, const std::string &message)
const std::string & key() const noexcept
PropertyType
Property type enumeration for MaterialPassport serialization.
Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs...
std::vector< ResourceKey > builtin_keys()
the 11 sys: keys, spec order
KeySource
Where a key's value lives.
std::vector< ResourceKey > key_catalogue(const std::vector< ProjectDB::PropertyDefinition > &columns)
Built-in, then leksikon, then user columns (in the given order) — the "catalogue order" template cate...
constexpr std::string_view kBuiltinCategory
std::optional< std::string > normalise_value(const ResourceKey &key, const std::optional< std::string > &value)
Validate value for key and return it normalised for storage (numbers with '.
const ResourceKey * find_key(const std::vector< ResourceKey > &catalogue, std::string_view id)
nullptr when id is not in catalogue.
auto to_string(Material value) -> std::string_view
Convert Material enum to its string identifier.
std::vector< std::string > leksikon_categories()
Distinct categories of leksikon_fields(), in order.
KeyScope
What a write changes: the survey type (all its parts) or the one part.
std::vector< ResourceKey > leksikon_keys()
constexpr std::string_view kColumnCategory
ResourceKey column_key(const ProjectDB::PropertyDefinition &def)
std::vector< LeksikonField > leksikon_fields()
Nested object-array fields (dangerous substances, emissions) are skipped: they are rows,...
std::optional< double > parse_number(std::string_view text)
Finite number with '.
std::string format_number(double v)
Shortest round-trip text: 290.0 -> "290", 0.1 -> "0.1".
A user-defined column in the Notion-like material editor.
One top-level leksikon property, in leksikon (MaterialEPAS section) order.
traits::PropertyType type
std::string category
== property_definitions.category
std::string field_name
== property_definitions.name_en
std::string guid
leksikon GUID == property_definitions.leksikon_guid
bool integer
Number keys that only take whole numbers (leksikon Integer fields).
std::string unit
"" when none
std::vector< std::string > options
enum / multiselect choices
std::string field
Storage name: the sys name ("quantity"), the leksikon field name_en ("width_mm") or the user column's...
std::string data_type
text | number | enum | multiselect | boolean | date.
std::string id
"sys:<name>" | "lex:<leksikon_guid>" | "col:<column id>"