FlatCityBuf C++ reader 0.8.0
Native C++17 reader for FlatCityBuf, the cloud-optimized CityJSON format
Loading...
Searching...
No Matches
attribute.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <fcb/error.hpp>
4#include <fcb/header.hpp>
5#include <fcb/span.hpp>
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
11#ifdef FCB_WITH_JSON
12# include <nlohmann/json.hpp>
13#endif
14
15namespace fcb {
16
23struct AttrValue {
24 enum class Type {
25 Null,
26 Bool,
27 Int, // any signed integer column
28 UInt, // any unsigned integer column
29 Double, // Float or Double
30 String, // String or DateTime
31 Json, // Json column, still as its raw text
32 Binary, // Binary column; `s` holds the raw bytes
33 };
34
36 bool b = false;
37 std::int64_t i = 0;
38 std::uint64_t u = 0;
39 double d = 0.0;
40 std::string s;
41};
42
58std::vector<std::pair<std::string, AttrValue>>
59decode_attributes(bytes_view blob, const std::vector<ColumnInfo>& schema);
60
61#ifdef FCB_WITH_JSON
63nlohmann::json attributes_to_json(bytes_view blob, const std::vector<ColumnInfo>& schema);
64#endif
65
66} // namespace fcb
Minimal C++17 stand-in for std::span: a non-owning view over contiguous memory.
Definition span.hpp:13
nlohmann::json attributes_to_json(bytes_view blob, const std::vector< ColumnInfo > &schema)
Same decode, rendered as a JSON object for CityJSON emission.
std::vector< std::pair< std::string, AttrValue > > decode_attributes(bytes_view blob, const std::vector< ColumnInfo > &schema)
Decode a feature's attribute blob against the column schema.
Definition attribute.cpp:47
One decoded attribute value.
Definition attribute.hpp:23
std::uint64_t u
Definition attribute.hpp:38
std::int64_t i
Definition attribute.hpp:37
std::string s
Definition attribute.hpp:40