From 876d4150aa3da531ddd687b48afada6e43f79146 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 2 Mar 2020 15:25:13 -0800 Subject: uhd: Apply clang-format against all .cpp and .hpp files in host/ Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of files that clang-format gets applied against. --- host/lib/include/uhdlib/utils/config_parser.hpp | 36 +++++++++---------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'host/lib/include/uhdlib/utils/config_parser.hpp') diff --git a/host/lib/include/uhdlib/utils/config_parser.hpp b/host/lib/include/uhdlib/utils/config_parser.hpp index 0cff0868d..13a6346e8 100644 --- a/host/lib/include/uhdlib/utils/config_parser.hpp +++ b/host/lib/include/uhdlib/utils/config_parser.hpp @@ -35,20 +35,20 @@ public: * * \throws uhd::runtime_error if the parsing failed. */ - config_parser(const std::string &path=""); + config_parser(const std::string& path = ""); /*! Load another config file and update the current values. * * If a value exists in both the new and current file, the new value wins. */ - void read_file(const std::string &path); + void read_file(const std::string& path); //! Return a list of sections std::vector sections(); //! Return a list of options (keys) in a section, or an empty list if // section does not exist - std::vector options(const std::string §ion); + std::vector options(const std::string& section); /*! Return the value of a key * @@ -57,15 +57,12 @@ public: * \param def Default value, in case the key does not exist */ template - T get( - const std::string §ion, - const std::string &key, - const T &def - ) { + T get(const std::string& section, const std::string& key, const T& def) + { try { const auto child = _pt.get_child(section); return child.get(key, def); - } catch (const boost::property_tree::ptree_bad_path &) { + } catch (const boost::property_tree::ptree_bad_path&) { return def; } } @@ -78,27 +75,20 @@ public: * \throws uhd::key_error if the key or the section don't exist */ template - T get( - const std::string §ion, - const std::string &key - ) { + T get(const std::string& section, const std::string& key) + { try { const auto child = _pt.get_child(section); return child.get(key); - } catch (const boost::property_tree::ptree_bad_path &) { - throw uhd::key_error( - std::string("[config_parser] Key ") + key + - " not found in section " + section - ); + } catch (const boost::property_tree::ptree_bad_path&) { + throw uhd::key_error(std::string("[config_parser] Key ") + key + + " not found in section " + section); } } template - void set( - const std::string §ion, - const std::string &key, - const T &value - ) { + void set(const std::string& section, const std::string& key, const T& value) + { _pt.put(section + "." + key, value); } -- cgit v1.2.3