13#include <boost/property_tree/ptree.hpp>
24extern template class boost::property_tree::basic_ptree<
25 std::string, std::string, std::less<>>;
45template <
typename Iterator>
121 using Iterator = boost::property_tree::ptree::const_assoc_iterator;
182 if (st.hasChildren())
185 "> has child elements.");
197 template <
typename ValueType>
207 using Iterator = boost::property_tree::ptree::const_assoc_iterator;
253 using PTree = boost::property_tree::ptree;
262 using Callback = std::function<void(
const std::string& filename,
263 const std::string& path,
264 const std::string& message)>;
282 std::string filename,
314 template <
typename T>
326 template <
typename T>
328 T
const& default_value)
const;
339 template <
typename T>
349 template <
typename T>
351 std::string
const& param)
const;
383 std::string
const& root)
const;
393 std::string
const& param)
const;
401 template <
typename T>
410 template <
typename T>
424 template <
typename T>
434 template <
typename T>
459 template <
typename T>
467 template <
typename T>
471 template <
typename Ch>
493 std::string
const& root)
const;
544 static void onerror(std::string
const& filename, std::string
const& path,
545 std::string
const& message);
549 static void onwarning(std::string
const& filename, std::string
const& path,
550 std::string
const& message);
557 template <
typename T>
562 template <
typename T>
564 std::string
const& param, std::vector<T>* )
const;
581 std::string
const& root);
587 [[noreturn]]
void error(std::string
const& message)
const;
591 void warning(std::string
const& message)
const;
597 std::string
joinPaths(std::string
const& p1, std::string
const& p2)
const;
612 template <
typename T>
614 bool peek_only)
const;
624 bool const peek_only)
const;
642 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.
void checkConfigParameter(std::string const ¶m, T const &value) const
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.
std::function< void(const std::string &filename, const std::string &path, const std::string &message)> Callback
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.
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_].
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...