Tesseract 0.28.4
Loading...
Searching...
No Matches
property_tree.h File Reference

This is a property tree class. More...

#include <string>
#include <string_view>
#include <map>
#include <vector>
#include <optional>
#include <functional>
#include <iosfwd>
#include <yaml-cpp/yaml.h>

Classes

class  tesseract::common::PropertyTree
 Represents a node in a hierarchical property tree. More...
 
class  tesseract::common::PropertyTreeBuilder
 Fluent builder for constructing PropertyTree schemas with minimal boilerplate. More...
 

Functions

std::string tesseract::common::property_type::createList (std::string_view type, std::size_t length=0)
 A utility for constructing the vector<type>
 
std::string tesseract::common::property_type::createMap (std::string_view type)
 A utility for constructing the map<std::string, type>
 
std::string tesseract::common::property_type::createMap (std::string_view key, std::string_view type)
 A utility for constructing the map<key, type>
 
std::optional< std::pair< std::string, std::size_t > > tesseract::common::isSequenceType (std::string_view type)
 Check if type is a sequence.
 
std::optional< std::pair< std::string, std::string > > tesseract::common::isMapType (std::string_view type)
 Check if type is a map.
 
void tesseract::common::validateRequired (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validator: ensure 'required' attribute is present and non-null.
 
void tesseract::common::validateEnum (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validator: enforce that node's value is in 'enum' list.
 
void tesseract::common::validateMap (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validator: ensure node value is of type YAML::NodeType::Map.
 
void tesseract::common::validateSequence (const PropertyTree &node, std::size_t length, const std::string &path, std::vector< std::string > &errors)
 Validator: ensure node value is of type YAML::NodeType::Sequence.
 
void tesseract::common::validateContainer (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validator: ensure property is a container of child properties. The property should have children and the value should be null.
 
void tesseract::common::validateCustomType (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validator: Retrieve schema for the custom type and run its validators.
 
template<typename T >
void tesseract::common::validateTypeCast (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validate that the node's value can be interpreted as the provided type.
 
template<typename T >
void tesseract::common::validateTypeCastWithRange (const PropertyTree &node, const std::string &path, std::vector< std::string > &errors)
 Validator: type cast and enforce 'minimum'/'maximum' range constraints.
 

Variables

constexpr std::string_view tesseract::common::property_type::BOOL { "bool" }
 
constexpr std::string_view tesseract::common::property_type::CHAR { "char" }
 
constexpr std::string_view tesseract::common::property_type::STRING { "std::string" }
 
constexpr std::string_view tesseract::common::property_type::INT { "int" }
 
constexpr std::string_view tesseract::common::property_type::UNSIGNED_INT { "unsigned int" }
 
constexpr std::string_view tesseract::common::property_type::LONG_INT { "long int" }
 
constexpr std::string_view tesseract::common::property_type::LONG_UNSIGNED_INT { "long unsigned int" }
 
constexpr std::string_view tesseract::common::property_type::FLOAT { "float" }
 
constexpr std::string_view tesseract::common::property_type::DOUBLE { "double" }
 
constexpr std::string_view tesseract::common::property_type::CONTAINER { "container" }
 
constexpr std::string_view tesseract::common::property_type::ONEOF { "oneOf" }
 
constexpr std::string_view tesseract::common::property_type::EIGEN_ISOMETRY_3D { "Eigen::Isometry3d" }
 
constexpr std::string_view tesseract::common::property_type::EIGEN_VECTOR_XD { "Eigen::VectorXd" }
 
constexpr std::string_view tesseract::common::property_type::EIGEN_VECTOR_2D { "Eigen::Vector2d" }
 
constexpr std::string_view tesseract::common::property_type::EIGEN_VECTOR_3D { "Eigen::Vector3d" }
 
constexpr std::string_view tesseract::common::property_attribute::TYPE { "type" }
 
constexpr std::string_view tesseract::common::property_attribute::DOC { "doc" }
 
constexpr std::string_view tesseract::common::property_attribute::REQUIRED { "required" }
 
constexpr std::string_view tesseract::common::property_attribute::DEFAULT { "default" }
 
constexpr std::string_view tesseract::common::property_attribute::ENUM { "enum" }
 
constexpr std::string_view tesseract::common::property_attribute::MINIMUM { "minimum" }
 
constexpr std::string_view tesseract::common::property_attribute::MAXIMUM { "maximum" }
 
constexpr std::string_view tesseract::common::property_attribute::LABEL { "label" }
 
constexpr std::string_view tesseract::common::property_attribute::PLACEHOLDER { "placeholder" }
 
constexpr std::string_view tesseract::common::property_attribute::GROUP { "group" }
 
constexpr std::string_view tesseract::common::property_attribute::READ_ONLY { "read_only" }
 
constexpr std::string_view tesseract::common::property_attribute::HIDDEN { "hidden" }
 

Detailed Description

This is a property tree class.

Defines PropertyTree, a hierarchical structure for YAML-based configuration with metadata and validation support.

Author
Levi Armstrong
Date
March 1, 2026
License
Software License Agreement (Apache License)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ createList()

std::string tesseract::common::property_type::createList ( std::string_view  type,
std::size_t  length = 0 
)

A utility for constructing the vector<type>

Parameters
typeThe type assoicated with the list
lengthThe length if fixed size
Returns
The string representation of the vector<type>, aka. type[] and type[length] for fixed size

◆ createMap() [1/2]

std::string tesseract::common::property_type::createMap ( std::string_view  type)

A utility for constructing the map<std::string, type>

Parameters
typeThe value type assoicated with the map
Returns
The string representation of the map<std::string, type>, aka. {string,string}

◆ createMap() [2/2]

std::string tesseract::common::property_type::createMap ( std::string_view  key,
std::string_view  type 
)

A utility for constructing the map<key, type>

Parameters
typeThe value type assoicated with the map
Returns
The string representation of the map<key, type>, aka. {string, string} or {string[2], string}

◆ isSequenceType()

std::optional< std::pair< std::string, std::size_t > > tesseract::common::isSequenceType ( std::string_view  type)

Check if type is a sequence.

Parameters
typeThe type to check
Returns
If it is a sequence, the underlying type is returned and size

◆ isMapType()

std::optional< std::pair< std::string, std::string > > tesseract::common::isMapType ( std::string_view  type)

Check if type is a map.

Parameters
typeThe type to check
Returns
If it is a map, the underlying pair<key,type> is returned

◆ validateRequired()

void tesseract::common::validateRequired ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: ensure 'required' attribute is present and non-null.

Parameters
nodeNode to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateEnum()

void tesseract::common::validateEnum ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: enforce that node's value is in 'enum' list.

Parameters
nodeNode to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateMap()

void tesseract::common::validateMap ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: ensure node value is of type YAML::NodeType::Map.

Parameters
nodeNode to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateSequence()

void tesseract::common::validateSequence ( const PropertyTree node,
std::size_t  length,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: ensure node value is of type YAML::NodeType::Sequence.

Parameters
nodeNode to validate.
lengthThe length if fixed size. If zero, it is considered dynamic size sequence.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateContainer()

void tesseract::common::validateContainer ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: ensure property is a container of child properties. The property should have children and the value should be null.

Parameters
nodeNode to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateCustomType()

void tesseract::common::validateCustomType ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: Retrieve schema for the custom type and run its validators.

Parameters
nodeNode to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateTypeCast()

template<typename T >
void tesseract::common::validateTypeCast ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validate that the node's value can be interpreted as the provided type.

Parameters
nodePropertyTree node whose value to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

◆ validateTypeCastWithRange()

template<typename T >
void tesseract::common::validateTypeCastWithRange ( const PropertyTree node,
const std::string &  path,
std::vector< std::string > &  errors 
)

Validator: type cast and enforce 'minimum'/'maximum' range constraints.

Parameters
nodeNode to validate.
pathDot-separated path for error messages.
errorsOutput vector to append errors to.

Variable Documentation

◆ LABEL

constexpr std::string_view tesseract::common::property_attribute::LABEL { "label" }
constexpr

Display name for the property (e.g. "Format Result")

◆ PLACEHOLDER

constexpr std::string_view tesseract::common::property_attribute::PLACEHOLDER { "placeholder" }
constexpr

Hint text shown when the field is empty

◆ GROUP

constexpr std::string_view tesseract::common::property_attribute::GROUP { "group" }
constexpr

Category/section for organizing properties in the GUI

◆ READ_ONLY

constexpr std::string_view tesseract::common::property_attribute::READ_ONLY { "read_only" }
constexpr

If true, the property is not user-editable

◆ HIDDEN

constexpr std::string_view tesseract::common::property_attribute::HIDDEN { "hidden" }
constexpr

If true, the property is hidden from the GUI