6#include <boost/property_tree/ptree.hpp>
20extern template class boost::property_tree::basic_ptree<
21 std::string, std::string, std::less<>>;
41template <
typename Iterator>
117 using Iterator = boost::property_tree::ptree::const_assoc_iterator;
178 if (st.hasChildren())
181 "> has child elements.");
193 template <
typename ValueType>
203 using Iterator = boost::property_tree::ptree::const_assoc_iterator;
228 .getValue<ValueType>();
249 using PTree = boost::property_tree::ptree;
258 using Callback = std::function<void(
const std::string& filename,
259 const std::string& path,
260 const std::string& message)>;
278 std::string filename,
312 template <
typename T>
324 template <
typename T>
326 T
const& default_value)
const;
337 template <
typename T>
347 template <
typename T>
349 std::string
const& param)
const;
381 std::string
const& param)
const;
391 std::string
const& param)
const;
399 template <
typename T>
408 template <
typename T>
422 template <
typename T>
432 template <
typename T>
457 template <
typename T>
466 std::string_view
const value)
const;
487 std::string
const& root)
const;
538 static void onerror(std::string
const& filename, std::string
const& path,
539 std::string
const& message);
543 static void onwarning(std::string
const& filename, std::string
const& path,
544 std::string
const& message);
551 template <
typename T>
556 template <
typename T>
558 std::string
const& param, std::vector<T>* )
const;
575 std::string
const& root);
581 [[noreturn]]
void error(std::string
const& message)
const;
585 void warning(std::string
const& message)
const;
591 std::string
joinPaths(std::string
const& p1, std::string
const& p2)
const;
606 template <
typename T>
608 bool peek_only)
const;
618 bool const peek_only)
const;
636 static std::string
shortString(std::string
const& s);
SubtreeIterator(Iterator const &it, std::string const &root, ConfigTree const &parent)
Inherit the constructor.
bool operator!=(SubtreeIterator const &other) const
std::input_iterator_tag iterator_category
boost::property_tree::ptree::const_assoc_iterator Iterator
std::string const tagname_
ConfigTree const & parent_
SubtreeIterator & operator++()
SubtreeIterator(Iterator const &it, std::string const &root, ConfigTree const &parent)
std::ptrdiff_t difference_type
bool operator==(SubtreeIterator const &other) const
boost::property_tree::ptree::const_assoc_iterator Iterator
std::ptrdiff_t difference_type
std::input_iterator_tag iterator_category
ValueIterator< ValueType > & operator++()
ConfigTree const & parent_
bool operator==(ValueIterator< ValueType > const &other) const
ValueIterator(Iterator const &it, std::string const &root, ConfigTree const &parent)
std::string const tagname_
bool operator!=(ValueIterator< ValueType > const &other) const
T peekConfigParameter(std::string const ¶m) const
void markVisitedDecrement(Attr const is_attr, std::string const &key) const
void ignoreConfigParameter(std::string const ¶m) const
static void onerror(std::string const &filename, std::string const &path, std::string const &message)
void checkAndInvalidate()
static void assertNoSwallowedErrors()
Asserts that there have not been any errors reported in the destructor.
Callback onwarning_
Custom warning callback.
static const char pathseparator
Character separating two path components.
void checkUniqueAttr(std::string const &attr) const
Asserts that the attribute attr has not been read yet.
std::map< KeyType, CountType > visited_params_
static std::string shortString(std::string const &s)
returns a short string at suitable for error/warning messages
std::shared_ptr< PTree const > top_level_tree_
void error(std::string const &message) const
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
std::filesystem::path projectDirectory() const
std::optional< T > getConfigParameterOptional(std::string const ¶m) const
void ignoreConfigAttribute(std::string const &attr) const
std::filesystem::path filepath_
The path of the file from which this tree has been read.
void checkUnique(std::string const &key) const
Asserts that the key has not been read yet.
T getConfigParameter(std::string const ¶m) const
T getConfigAttribute(std::string const &attr) const
Attr
Used to indicate if dealing with XML tags or XML attributes.
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
static const std::string key_chars_start
Set of allowed characters as the first letter of a key name.
ConfigTree getConfigSubtree(std::string const &root) const
std::pair< Attr, std::string > KeyType
A pair (is attribute, tag/attribute name).
std::string path_
A path printed in error/warning messages.
CountType & markVisited(std::string const &key, Attr const is_attr, bool peek_only) const
void ignoreConfigParameterAll(std::string const ¶m) const
Callback onerror_
Custom error callback.
std::string joinPaths(std::string const &p1, std::string const &p2) const
Used to generate the path of a subtree.
std::filesystem::path const & projectFilePath() const
Used to get the project file name.
std::optional< T > getConfigParameterOptionalImpl(std::string const ¶m, T *) const
Default implementation of reading a value of type T.
ConfigTree(ConfigTree const &)=delete
copying is not compatible with the semantics of this class
Range< ValueIterator< T > > getConfigParameterList(std::string const ¶m) const
std::optional< T > getConfigAttributeOptional(std::string const &attr) const
void warning(std::string const &message) const
bool hasChildren() const
Checks if this tree has any children.
PTree const * tree_
The wrapped tree.
ConfigTree(PTree &&top_level_tree, std::string filename, Callback error_cb, Callback warning_cb)
void checkConfigParameter(std::string const ¶m, std::string_view const value) const
boost::property_tree::ptree PTree
The tree being wrapped by this class.
ConfigTree & operator=(ConfigTree const &)=delete
copying is not compatible with the semantics of this class
void checkKeyname(std::string const &key) const
Checks if key complies with the rules [a-z0-9_].
std::function< void(const std::string &filename, const std::string &path, const std::string &message)> Callback
static void onwarning(std::string const &filename, std::string const &path, std::string const &message)
static const std::string key_chars
Set of allowed characters in a key name.
Wraps a pair of iterators for use as a range in range-based for-loops.
void checkAndInvalidate(ConfigTree &conf)
This is an overloaded member function, provided for convenience. It differs from the above function o...