13#include <boost/property_tree/ptree.hpp>
26extern template class boost::property_tree::basic_ptree<
27 std::string, std::string, std::less<>>;
47template <
typename Iterator>
123 using Iterator = boost::property_tree::ptree::const_assoc_iterator;
184 if (st.hasChildren())
187 "> has child elements.");
199 template <
typename ValueType>
209 using Iterator = boost::property_tree::ptree::const_assoc_iterator;
234 .getValue<ValueType>();
255 using PTree = boost::property_tree::ptree;
264 using Callback = std::function<void(
const std::string& filename,
265 const std::string& path,
266 const std::string& message)>;
284 std::string filename,
316 template <
typename T>
328 template <
typename T>
330 T
const& default_value)
const;
341 template <
typename T>
351 template <
typename T>
353 std::string
const& param)
const;
385 std::string
const& param)
const;
395 std::string
const& param)
const;
403 template <
typename T>
412 template <
typename T>
426 template <
typename T>
436 template <
typename T>
461 template <
typename T>
470 std::string_view
const value)
const;
491 std::string
const& root)
const;
542 static void onerror(std::string
const& filename, std::string
const& path,
543 std::string
const& message);
547 static void onwarning(std::string
const& filename, std::string
const& path,
548 std::string
const& message);
555 template <
typename T>
560 template <
typename T>
562 std::string
const& param, std::vector<T>* )
const;
579 std::string
const& root);
585 [[noreturn]]
void error(std::string
const& message)
const;
589 void warning(std::string
const& message)
const;
595 std::string
joinPaths(std::string
const& p1, std::string
const& p2)
const;
610 template <
typename T>
612 bool peek_only)
const;
622 bool const peek_only)
const;
640 static std::string
shortString(std::string
const& s);
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_
std::string const & getProjectFileName() const
Used to get the project file name.
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::optional< T > getConfigParameterOptional(std::string const ¶m) const
void ignoreConfigAttribute(std::string const &attr) const
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::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
std::string filename_
The path of the file from which this tree has been read.
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...