From da40a1aebc16ca05219883c18b2cf96989c470fd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 22 Jul 2011 01:19:03 -0700 Subject: uhd: replaced boost filesystem path with fs_path in property tree --- host/include/uhd/property_tree.hpp | 35 +++++++++++++++++++++++++---------- host/include/uhd/property_tree.ipp | 4 ++-- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp index cd8cba7e5..47b2c5736 100644 --- a/host/include/uhd/property_tree.hpp +++ b/host/include/uhd/property_tree.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include namespace uhd{ @@ -98,41 +97,57 @@ public: virtual bool empty(void) const = 0; }; +/*! + * FS Path: A glorified string with path manipulations. + * Inspired by boost filesystem path, but without the dependency. + * + * Notice: we do not declare UHD_API on the whole structure + * because MSVC will do weird things with std::string and linking. + */ +struct fs_path : std::string{ + UHD_API fs_path(void); + UHD_API fs_path(const char *); + UHD_API fs_path(const std::string &); + UHD_API std::string leaf(void) const; + UHD_API fs_path branch_path(void) const; +}; + +UHD_API fs_path operator/(const fs_path &, const fs_path &); + /*! * The property tree provides a file system structure for accessing properties. */ class UHD_API property_tree : boost::noncopyable{ public: typedef boost::shared_ptr sptr; - typedef boost::filesystem::path path_type; //! Create a new + empty property tree static sptr make(void); //! Get a subtree with a new root starting at path - virtual sptr subtree(const path_type &path) const = 0; + virtual sptr subtree(const fs_path &path) const = 0; //! Remove a property or directory (recursive) - virtual void remove(const path_type &path) = 0; + virtual void remove(const fs_path &path) = 0; //! True if the path exists in the tree - virtual bool exists(const path_type &path) const = 0; + virtual bool exists(const fs_path &path) const = 0; //! Get an iterable to all things in the given path - virtual std::vector list(const path_type &path) const = 0; + virtual std::vector list(const fs_path &path) const = 0; //! Create a new property entry in the tree - template property &create(const path_type &path); + template property &create(const fs_path &path); //! Get access to a property in the tree - template property &access(const path_type &path); + template property &access(const fs_path &path); private: //! Internal create property with wild-card type - virtual void _create(const path_type &path, const boost::shared_ptr &prop) = 0; + virtual void _create(const fs_path &path, const boost::shared_ptr &prop) = 0; //! Internal access property with wild-card type - virtual boost::shared_ptr &_access(const path_type &path) const = 0; + virtual boost::shared_ptr &_access(const fs_path &path) const = 0; }; diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index 868cba475..85720dc6b 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -81,12 +81,12 @@ private: **********************************************************************/ namespace uhd{ - template property &property_tree::create(const path_type &path){ + template property &property_tree::create(const fs_path &path){ this->_create(path, typename boost::shared_ptr >(new property_impl())); return this->access(path); } - template property &property_tree::access(const path_type &path){ + template property &property_tree::access(const fs_path &path){ return *boost::static_pointer_cast >(this->_access(path)); } -- cgit v1.2.3