diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-03-02 15:25:13 -0800 |
---|---|---|
committer | atrnati <54334261+atrnati@users.noreply.github.com> | 2020-03-03 08:51:32 -0600 |
commit | 876d4150aa3da531ddd687b48afada6e43f79146 (patch) | |
tree | fd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/include/uhdlib/utils/config_parser.hpp | |
parent | 1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff) | |
download | uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2 uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip |
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.
Diffstat (limited to 'host/lib/include/uhdlib/utils/config_parser.hpp')
-rw-r--r-- | host/lib/include/uhdlib/utils/config_parser.hpp | 36 |
1 files changed, 13 insertions, 23 deletions
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<std::string> sections(); //! Return a list of options (keys) in a section, or an empty list if // section does not exist - std::vector<std::string> options(const std::string §ion); + std::vector<std::string> 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 <typename T> - 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<T>(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 <typename T> - 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<T>(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 <typename T> - 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<T>(section + "." + key, value); } |