39#include <ament_index_cpp/get_package_prefix.hpp>
54#include <ament_index_cpp/version.h>
55#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0)
56#include <ament_index_cpp/get_package_share_path.hpp>
58#include <ament_index_cpp/get_package_share_directory.hpp>
63#include <yaml-cpp/yaml.h>
70inline std::filesystem::path
getSharePath(
const std::string& package_name)
74#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0)
75 return ament_index_cpp::get_package_share_path(package_name);
76#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0)
77 std::filesystem::path path;
78 ament_index_cpp::get_package_share_directory(package_name, path);
81 return std::filesystem::path(ament_index_cpp::get_package_share_directory(package_name));
84 catch (
const std::runtime_error& e)
86 return std::filesystem::path();
96 return std::filesystem::is_directory(output_path) || std::filesystem::create_directories(output_path);
116 std::filesystem::path& relative_filepath);
140tinyxml2::XMLElement*
uniqueInsert(tinyxml2::XMLDocument& doc, tinyxml2::XMLElement& element,
const char* tag,
141 const std::vector<XMLAttribute>& attributes = {},
const char* text =
nullptr);
145inline bool getYamlProperty(
const YAML::Node& node,
const std::string& key, T& storage,
const T& default_value = T())
147 const YAML::Node& n = node[key];
148 bool valid = n.IsDefined();
149 storage = valid ? n.as<T>() : default_value;
153inline bool getYamlProperty(
const YAML::Node& node,
const std::string& key, std::filesystem::path& storage,
154 const std::string& default_value =
"")
156 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.