ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
path_parser.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2
//
3
// SPDX-License-Identifier: GPL-3.0-or-later
4
5
#pragma once
6
7
#include <optional>
8
#include <stdexcept>
9
#include <string>
10
#include <string_view>
11
#include <vector>
12
13
namespace
rux::database
{
14
18
class
PathError
:
public
std::runtime_error {
19
public
:
20
explicit
PathError
(
const
std::string &message)
21
: std::runtime_error(message) {}
22
};
23
27
enum class
ComponentType
{
28
Collection
,
// e.g., "clouds", "meshes", "frames"
29
Item
,
// e.g., "mycloud", "123"
30
Property
,
// e.g., "metadata", "point_count"
31
Index
// e.g., "[0]", "[5]"
32
};
33
43
struct
PathComponent
{
44
ComponentType
type
;
45
std::string
value
;
46
std::optional<int>
index
;
47
48
PathComponent
(
ComponentType
t, std::string v)
49
:
type
(t),
value
(std::move(v)),
index
(std::nullopt) {}
50
51
PathComponent
(
ComponentType
t, std::string v,
int
idx)
52
:
type
(t),
value
(std::move(v)),
index
(idx) {}
53
54
bool
is_collection
()
const
{
return
type
==
ComponentType::Collection
; }
55
bool
is_item
()
const
{
return
type
==
ComponentType::Item
; }
56
bool
is_property
()
const
{
return
type
==
ComponentType::Property
; }
57
bool
is_index
()
const
{
return
type
==
ComponentType::Index
; }
58
bool
has_wildcard
()
const
{
return
value
.find(
'*'
) != std::string::npos; }
59
};
60
89
std::vector<PathComponent>
parse_path
(std::string_view path);
90
99
bool
is_valid_collection
(std::string_view name);
100
108
std::vector<std::string>
expand_wildcard
(std::string_view pattern,
109
const
std::vector<std::string> &items);
110
118
bool
matches_wildcard
(std::string_view str, std::string_view pattern);
119
120
}
// namespace rux::database
rux::database::PathError::PathError
PathError(const std::string &message)
Definition
path_parser.hpp:20
rux::database
Definition
cloud_router.hpp:9
rux::database::expand_wildcard
std::vector< std::string > expand_wildcard(std::string_view pattern, const std::vector< std::string > &items)
Expand wildcard patterns in item names.
rux::database::is_valid_collection
bool is_valid_collection(std::string_view name)
Check if a collection name is valid.
rux::database::parse_path
std::vector< PathComponent > parse_path(std::string_view path)
Parse a resource path into components.
rux::database::ComponentType
ComponentType
Type of path component.
Definition
path_parser.hpp:27
rux::database::ComponentType::Property
@ Property
Definition
path_parser.hpp:30
rux::database::ComponentType::Item
@ Item
Definition
path_parser.hpp:29
rux::database::ComponentType::Index
@ Index
Definition
path_parser.hpp:31
rux::database::ComponentType::Collection
@ Collection
Definition
path_parser.hpp:28
rux::database::matches_wildcard
bool matches_wildcard(std::string_view str, std::string_view pattern)
Check if a string matches a wildcard pattern.
rux::database::PathComponent::index
std::optional< int > index
Definition
path_parser.hpp:46
rux::database::PathComponent::is_item
bool is_item() const
Definition
path_parser.hpp:55
rux::database::PathComponent::is_collection
bool is_collection() const
Definition
path_parser.hpp:54
rux::database::PathComponent::PathComponent
PathComponent(ComponentType t, std::string v)
Definition
path_parser.hpp:48
rux::database::PathComponent::type
ComponentType type
Definition
path_parser.hpp:44
rux::database::PathComponent::value
std::string value
Definition
path_parser.hpp:45
rux::database::PathComponent::is_property
bool is_property() const
Definition
path_parser.hpp:56
rux::database::PathComponent::is_index
bool is_index() const
Definition
path_parser.hpp:57
rux::database::PathComponent::PathComponent
PathComponent(ComponentType t, std::string v, int idx)
Definition
path_parser.hpp:51
rux::database::PathComponent::has_wildcard
bool has_wildcard() const
Definition
path_parser.hpp:58
apps
rux
include
database
path_parser.hpp
Generated by
1.17.0