ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
rux::database Namespace Reference

Classes

class  CloudRouter
 Router for point cloud resources. More...
class  InputHandler
 Handles input for set operations. More...
class  MeshRouter
 Router for mesh resources. More...
class  PanoramaRouter
 Router for panoramic image resources. More...
class  PassportRouter
 Router for material passport resources. More...
class  PathError
 Exception thrown when path parsing fails. More...
struct  PathComponent
 Represents a single component in a resource path. More...
class  ProjectRouter
 Router for project metadata. More...
class  ResourceRouter
 Base interface for resource routers. More...
class  RouterRegistry
 Router registry for dispatching paths to appropriate routers. More...

Typedefs

using DataPayload
 Data payload that can be returned by routers.

Enumerations

enum class  OutputFormat { Binary , JSON , Text }
 Output format types. More...
enum class  InputSource { Stdin , Inline , None }
 Input source for set operations. More...
enum class  ComponentType { Collection , Item , Property , Index }
 Type of path component. More...

Functions

OutputFormat detect_format (const DataPayload &payload)
 Detect format from payload type.
void write_output (const DataPayload &payload, bool force_pretty=false)
 Write data to stdout with appropriate formatting.
void write_to_file (const DataPayload &payload, const std::filesystem::path &file_path)
 Write data to a file.
bool is_stdout_tty ()
 Check if stdout is a TTY (for format detection).
std::string json_to_text (const nlohmann::json &j)
 Convert JSON to text (for scalar values).
std::vector< PathComponentparse_path (std::string_view path)
 Parse a resource path into components.
bool is_valid_collection (std::string_view name)
 Check if a collection name is valid.
std::vector< std::string > expand_wildcard (std::string_view pattern, const std::vector< std::string > &items)
 Expand wildcard patterns in item names.
bool matches_wildcard (std::string_view str, std::string_view pattern)
 Check if a string matches a wildcard pattern.
std::vector< std::vector< PathComponent > > expand_wildcards (const std::vector< PathComponent > &components, ResourceRouter &router)
 Helper to expand wildcards in path components.

Typedef Documentation

◆ DataPayload

Initial value:
std::variant<std::string, std::vector<uint8_t>, nlohmann::json>

Data payload that can be returned by routers.

Variant of:

  • std::string (text data)
  • std::vector<uint8_t> (binary data)
  • nlohmann::json (structured data)

Definition at line 33 of file format_handler.hpp.

Enumeration Type Documentation

◆ ComponentType

enum class rux::database::ComponentType
strong

Type of path component.

Enumerator
Collection 
Item 
Property 
Index 

Definition at line 27 of file path_parser.hpp.

◆ InputSource

enum class rux::database::InputSource
strong

Input source for set operations.

Enumerator
Stdin 
Inline 
None 

Definition at line 19 of file input_handler.hpp.

◆ OutputFormat

enum class rux::database::OutputFormat
strong

Output format types.

Enumerator
Binary 
JSON 
Text 

Definition at line 19 of file format_handler.hpp.

Function Documentation

◆ detect_format()

OutputFormat rux::database::detect_format ( const DataPayload & payload)

Detect format from payload type.

Parameters
payloadData payload
Returns
Detected output format

◆ expand_wildcard()

std::vector< std::string > rux::database::expand_wildcard ( std::string_view pattern,
const std::vector< std::string > & items )

Expand wildcard patterns in item names.

Parameters
patternPattern with wildcards (e.g., "scan*", "*_preprocessed")
itemsAvailable items to match against
Returns
Vector of matching item names

◆ expand_wildcards()

std::vector< std::vector< PathComponent > > rux::database::expand_wildcards ( const std::vector< PathComponent > & components,
ResourceRouter & router )

Helper to expand wildcards in path components.

Parameters
componentsPath components (may contain wildcards)
routerRouter for the collection
Returns
Expanded paths (one per matching item)

◆ is_stdout_tty()

bool rux::database::is_stdout_tty ( )

Check if stdout is a TTY (for format detection).

Returns
true if stdout is connected to a terminal

◆ is_valid_collection()

bool rux::database::is_valid_collection ( std::string_view name)

Check if a collection name is valid.

Valid collections: clouds, materials, meshes, projects

Parameters
nameCollection name to validate
Returns
true if valid collection name

◆ json_to_text()

std::string rux::database::json_to_text ( const nlohmann::json & j)

Convert JSON to text (for scalar values).

Extracts the value from JSON and returns as plain text string. Works for strings, numbers, booleans.

Parameters
jJSON value
Returns
Text representation

◆ matches_wildcard()

bool rux::database::matches_wildcard ( std::string_view str,
std::string_view pattern )

Check if a string matches a wildcard pattern.

Parameters
strString to match
patternPattern with wildcards
Returns
true if string matches pattern

◆ parse_path()

std::vector< PathComponent > rux::database::parse_path ( std::string_view path)

Parse a resource path into components.

Syntax:

  • Dot notation (primary): "clouds.mycloud.metadata"
  • Slash notation (backward compat): "clouds/mycloud/metadata"
  • Array indexing: "clouds[0]" or "clouds[0].metadata"
  • Wildcards: "clouds.*" or "clouds.scan*"

Grammar: path ::= collection | collection.item | collection.item.property | collection[index] | collection[index].property

Parameters
pathResource path to parse
Returns
Vector of path components
Exceptions
PathErrorif path is invalid

Examples:

  • "clouds" → [{Collection, "clouds"}]
  • "clouds.scan1" → [{Collection, "clouds"}, {Item, "scan1"}]
  • "clouds.scan1.metadata" → [{Collection, "clouds"}, {Item, "scan1"}, {Property, "metadata"}]
  • "clouds[0]" → [{Collection, "clouds"}, {Index, "", 0}]
  • "clouds.*" → [{Collection, "clouds"}, {Item, "*"}]

◆ write_output()

void rux::database::write_output ( const DataPayload & payload,
bool force_pretty = false )

Write data to stdout with appropriate formatting.

Handles:

  • Binary data (sets stdout to binary mode on Windows)
  • JSON data (pretty-printed for TTY, compact for pipes)
  • Text data (plain output)
Parameters
payloadData to write
force_prettyForce pretty-print JSON even for non-TTY

◆ write_to_file()

void rux::database::write_to_file ( const DataPayload & payload,
const std::filesystem::path & file_path )

Write data to a file.

Parameters
payloadData to write
file_pathOutput file path