diff options
author | Martin Braun <martin.braun@ettus.com> | 2014-08-19 16:40:09 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2014-09-23 16:02:14 -0700 |
commit | c431a66df3df4cff82bfa2d2b2c7b16895a7efd6 (patch) | |
tree | de7fc65147c688b3b4b18de4f787e3dca897b2ce /host/lib | |
parent | 4547d1c74a6c875057f23f8ea77033b9cd191539 (diff) | |
download | uhd-c431a66df3df4cff82bfa2d2b2c7b16895a7efd6.tar.gz uhd-c431a66df3df4cff82bfa2d2b2c7b16895a7efd6.tar.bz2 uhd-c431a66df3df4cff82bfa2d2b2c7b16895a7efd6.zip |
uhd: Added an operator/ for (fs_path, size_t)
This is useful when constructing property tree paths.
With this path, the following code would be valid:
size_t mb_index = 0;
fs_path mb_root = "/mboards";
mb_root = mb_root / mb_index;
This is a shortcut for the (in UHD very common)
mb_root = mb_root / boost::lexical_cast<std::string(mb_index);
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/property_tree.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/host/lib/property_tree.cpp b/host/lib/property_tree.cpp index 50e82a6ba..5666e2639 100644 --- a/host/lib/property_tree.cpp +++ b/host/lib/property_tree.cpp @@ -65,6 +65,12 @@ fs_path uhd::operator/(const fs_path &lhs, const fs_path &rhs){ return fs_path(lhs + "/" + rhs); } +fs_path uhd::operator/(const fs_path &lhs, size_t rhs) +{ + fs_path rhs_str = boost::lexical_cast<std::string>(rhs); + return lhs / rhs_str; +} + /*********************************************************************** * Property tree implementation **********************************************************************/ |