39#include <ament_index_cpp/get_package_prefix.hpp>
40#include <ament_index_cpp/get_package_share_directory.hpp>
44#include <yaml-cpp/yaml.h>
51inline std::filesystem::path
getSharePath(
const std::string& package_name)
55 return std::filesystem::path(ament_index_cpp::get_package_share_directory(package_name));
57 catch (
const std::runtime_error& e)
59 return std::filesystem::path();
69 return std::filesystem::is_directory(output_path) || std::filesystem::create_directories(output_path);
89 std::filesystem::path& relative_filepath);
113tinyxml2::XMLElement*
uniqueInsert(tinyxml2::XMLDocument& doc, tinyxml2::XMLElement& element,
const char* tag,
114 const std::vector<XMLAttribute>& attributes = {},
const char* text =
nullptr);
118inline bool getYamlProperty(
const YAML::Node& node,
const std::string& key, T& storage,
const T& default_value = T())
120 const YAML::Node& n = node[key];
121 bool valid = n.IsDefined();
122 storage = valid ? n.as<T>() : default_value;
126inline bool getYamlProperty(
const YAML::Node& node,
const std::string& key, std::filesystem::path& storage,
127 const std::string& default_value =
"")
129 std::string storage_s;
bool getYamlProperty(const YAML::Node &node, const std::string &key, T &storage, const T &default_value=T())
std::filesystem::path getSharePath(const std::string &package_name)
Return a path for the given package's share folder.
tinyxml2::XMLElement * uniqueInsert(tinyxml2::XMLDocument &doc, tinyxml2::XMLElement &element, const char *tag, const std::vector< XMLAttribute > &attributes={}, const char *text=nullptr)
Insert a new XML element with a given tag, attributes, and text.
bool extractPackageNameFromPath(const std::filesystem::path &path, std::string &package_name, std::filesystem::path &relative_filepath)
bool createParentFolders(const std::filesystem::path &file_path)
Create parent folders (recursively)
bool createFolders(const std::filesystem::path &output_path)
Create folders (recursively)
Simple structure for easy xml creation.