diff options
-rw-r--r-- | host/include/uhd/property_tree.hpp | 2 | ||||
-rw-r--r-- | host/include/uhd/property_tree.ipp | 3 | ||||
-rw-r--r-- | host/lib/property_tree.cpp | 43 |
3 files changed, 30 insertions, 18 deletions
diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp index 7edadcbda..9fc9b3b97 100644 --- a/host/include/uhd/property_tree.hpp +++ b/host/include/uhd/property_tree.hpp @@ -65,7 +65,7 @@ namespace uhd { * - T must have an assignment operator */ template <typename T> -class property : uhd::noncopyable +class UHD_API_HEADER property : uhd::noncopyable { public: typedef std::function<void(const T&)> subscriber_type; diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index b1b95c2c8..273227174 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -179,8 +179,7 @@ namespace uhd { template <typename T> property<T>& property_tree::create(const fs_path& path, coerce_mode_t coerce_mode) { - this->_create(path, - typename std::shared_ptr<property<T> >(new property_impl<T>(coerce_mode))); + this->_create(path, std::make_shared<property_impl<T> >(coerce_mode)); return this->access<T>(path); } diff --git a/host/lib/property_tree.cpp b/host/lib/property_tree.cpp index 14d3ae8c4..a21254336 100644 --- a/host/lib/property_tree.cpp +++ b/host/lib/property_tree.cpp @@ -30,16 +30,18 @@ fs_path::fs_path(const std::string& p) : std::string(p) {} std::string fs_path::leaf(void) const { const size_t pos = this->rfind("/"); - if (pos == std::string::npos) + if (pos == std::string::npos) { return *this; + } return this->substr(pos + 1); } fs_path fs_path::branch_path(void) const { const size_t pos = this->rfind("/"); - if (pos == std::string::npos) + if (pos == std::string::npos) { return *this; + } return fs_path(this->substr(0, pos)); } @@ -93,13 +95,15 @@ public: node_type* parent = NULL; node_type* node = &_guts->root; for (const std::string& name : path_tokenizer(path)) { - if (not node->has_key(name)) + if (not node->has_key(name)) { throw_path_not_found(path); + } parent = node; node = &(*node)[name]; } - if (parent == NULL) + if (parent == NULL) { throw uhd::runtime_error("Cannot uproot"); + } parent->pop(fs_path(path.leaf())); } @@ -110,8 +114,9 @@ public: node_type* node = &_guts->root; for (const std::string& name : path_tokenizer(path)) { - if (not node->has_key(name)) + if (not node->has_key(name)) { return false; + } node = &(*node)[name]; } return true; @@ -124,8 +129,9 @@ public: node_type* node = &_guts->root; for (const std::string& name : path_tokenizer(path)) { - if (not node->has_key(name)) + if (not node->has_key(name)) { throw_path_not_found(path); + } node = &(*node)[name]; } @@ -140,16 +146,19 @@ public: node_type* parent = NULL; node_type* node = &_guts->root; for (const std::string& name : path_tokenizer(path)) { - if (not node->has_key(name)) + if (not node->has_key(name)) { throw_path_not_found(path); + } parent = node; node = &(*node)[name]; } - if (node->prop.get() == NULL) + if (node->prop.get() == NULL) { throw uhd::runtime_error("Cannot access! Property uninitialized at: " + path); - if (parent == NULL) + } + if (parent == NULL) { throw uhd::runtime_error("Cannot pop"); + } auto prop = node->prop; parent->pop(fs_path(path.leaf())); return prop; @@ -162,14 +171,16 @@ public: node_type* node = &_guts->root; for (const std::string& name : path_tokenizer(path)) { - if (not node->has_key(name)) + if (not node->has_key(name)) { (*node)[name] = node_type(); + } node = &(*node)[name]; } - if (node->prop.get() != NULL) + if (node->prop.get() != NULL) { throw uhd::runtime_error( "Cannot create! Property already exists at: " + path); - node->prop = prop; + } + node->prop = prop; } std::shared_ptr<void>& _access(const fs_path& path_) const override @@ -179,12 +190,14 @@ public: node_type* node = &_guts->root; for (const std::string& name : path_tokenizer(path)) { - if (not node->has_key(name)) + if (not node->has_key(name)) { throw_path_not_found(path); + } node = &(*node)[name]; } - if (node->prop.get() == NULL) + if (node->prop.get() == NULL) { throw uhd::runtime_error("Cannot access! Property uninitialized at: " + path); + } return node->prop; } @@ -222,5 +235,5 @@ property_tree::~property_tree(void) **********************************************************************/ uhd::property_tree::sptr uhd::property_tree::make(void) { - return sptr(new property_tree_impl()); + return std::make_shared<property_tree_impl>(); } |