ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
resource_export.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
10
11#include "reusex/core/ProjectDB.hpp"
12#include "reusex/core/resource_keys.hpp"
13#include "reusex/core/resource_templates.hpp"
14#include "reusex/core/resources.hpp"
15
16#include <cstddef>
17#include <cstdint>
18#include <optional>
19#include <string>
20#include <string_view>
21#include <vector>
22
23namespace reusex::core {
24
27std::string display_value(const ResourceKey &key,
28 const std::optional<std::string> &value);
32std::string csv_cell(std::string_view value, std::string_view delimiter);
35inline constexpr std::string_view kCsvCodeLabel = "Kode";
36inline constexpr std::string_view kCsvCodeKey = "code";
40std::vector<std::string> csv_labels(const std::vector<ResourceKey> &columns);
45std::string build_resource_csv(const std::vector<ResourceKey> &columns,
46 const std::vector<Resource> &rows,
47 const CsvOptions &options);
50std::string export_resources_csv(const ProjectDB &db, int64_t template_id);
51
53 std::vector<std::string> headers;
54 std::vector<std::vector<std::string>> rows;
55};
56inline constexpr std::size_t kResourceTableMaxColumns = 8;
60std::vector<ResourceTable>
61resource_tables(const std::vector<ResourceKey> &columns,
62 const std::vector<Resource> &rows,
63 std::size_t max_columns = kResourceTableMaxColumns);
65 std::string template_name;
66 std::vector<ResourceTable> tables;
67};
68
71 int64_t template_id);
72
73} // namespace reusex::core
Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs...
std::vector< std::string > csv_labels(const std::vector< ResourceKey > &columns)
The CSV header labels of columns: each key's label, with " (<category>)" appended to every label that...
std::string csv_cell(std::string_view value, std::string_view delimiter)
One CSV cell: a cell starting with = + - @ TAB or CR gets a leading ' (formula injection),...
constexpr std::string_view kCsvCodeLabel
The leading resource-code column of the CSV: its header in label mode and in key mode.
std::string build_resource_csv(const std::vector< ResourceKey > &columns, const std::vector< Resource > &rows, const CsvOptions &options)
Header + one CRLF-terminated row per resource, led by the resource code.
std::vector< ResourceTable > resource_tables(const std::vector< ResourceKey > &columns, const std::vector< Resource > &rows, std::size_t max_columns=kResourceTableMaxColumns)
Wrap columns into tables of at most max_columns, each led by a "Betegnelse" column whose cell is "<sy...
std::string export_resources_csv(const ProjectDB &db, int64_t template_id)
The CSV for one template: its resolved keys, every resource by code, its CSV options.
std::string display_value(const ResourceKey &key, const std::optional< std::string > &value)
A value as a reader sees it: treatment and miljøstatus as their Danish labels, booleans as Ja/Nej,...
ResourceReportSection resource_report_section(const ProjectDB &db, int64_t template_id)
The PDF's Ressourcetabel for one template: every resource whose type is not rejected,...
constexpr std::string_view kCsvCodeKey
constexpr std::size_t kResourceTableMaxColumns
A template's CSV export options (templates.csv).
std::vector< ResourceTable > tables
std::vector< std::string > headers
std::vector< std::vector< std::string > > rows