| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
device_addr.hpp
Go to the documentation of this file.
1//
2// Copyright 2010-2011 Ettus Research LLC
3// Copyright 2018 Ettus Research, a National Instruments Company
4//
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
7
8#pragma once
9
10#include <uhd/config.hpp>
11#include <uhd/types/dict.hpp>
12#include <boost/lexical_cast.hpp>
13#include <algorithm>
14#include <map>
15#include <stdexcept>
16#include <string>
17#include <vector>
18
19 namespace uhd {
20
38 class UHD_API device_addr_t : public dict<std::string, std::string>
39{
40 public:
45 device_addr_t(const std::string& args = "");
46
51 device_addr_t(const char* args);
52
57 device_addr_t(const std::map<std::string, std::string>& info);
58
63 std::string to_pp_string(void) const;
64
70 std::string to_string(void) const;
71
80 template <typename T>
81 T cast(const std::string& key, const T& def) const
82 {
83 if (not this->has_key(key))
84 return def;
85 try {
86 return boost::lexical_cast<T>((*this)[key]);
87 } catch (const boost::bad_lexical_cast&) {
88 throw std::runtime_error("cannot cast " + key + " = " + (*this)[key]);
89 }
90 }
91};
92
94 typedef std::vector<device_addr_t> device_addrs_t;
95
97 UHD_API device_addrs_t separate_device_addr(const device_addr_t& dev_addr);
98
100 UHD_API device_addr_t combine_device_addrs(const device_addrs_t& dev_addrs);
101
102} // namespace uhd
uhd::device_addr_t
Definition device_addr.hpp:39
uhd::device_addr_t::device_addr_t
device_addr_t(const std::string &args="")
uhd::device_addr_t::cast
T cast(const std::string &key, const T &def) const
Definition device_addr.hpp:81
uhd::device_addr_t::to_string
std::string to_string(void) const
uhd::device_addr_t::device_addr_t
device_addr_t(const std::map< std::string, std::string > &info)
uhd::device_addr_t::to_pp_string
std::string to_pp_string(void) const
uhd::device_addr_t::device_addr_t
device_addr_t(const char *args)
uhd::dict< std::string, std::string >::has_key
bool has_key(const std::string &key) const
uhd::dict< std::string, std::string >::dict
dict(void)
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
dict.hpp
uhd
Definition build_info.hpp:12
uhd::separate_device_addr
UHD_API device_addrs_t separate_device_addr(const device_addr_t &dev_addr)
Separate an indexed device address into a vector of device addresses.
uhd::combine_device_addrs
UHD_API device_addr_t combine_device_addrs(const device_addrs_t &dev_addrs)
Combine a vector of device addresses into an indexed device address.
uhd::device_addrs_t
std::vector< device_addr_t > device_addrs_t
A typedef for a vector of device addresses.
Definition device_addr.hpp:94