Loading...
Searching...
No Matches
device_addr.hpp
Go to the documentation of this file.
//
// Copyright 2010-2011 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <uhd/types/dict.hpp>
#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <map>
#include <stdexcept>
#include <string>
#include <vector>
namespace uhd {
class UHD_API device_addr_t : public dict<std::string, std::string>
{
public:
device_addr_t(const std::string& args = "");
device_addr_t(const char* args);
device_addr_t(const std::map<std::string, std::string>& info);
std::string to_pp_string(void) const;
std::string to_string(void) const;
template <typename T>
T cast(const std::string& key, const T& def) const
{
if (not this->has_key(key))
return def;
try {
return boost::lexical_cast<T>((*this)[key]);
} catch (const boost::bad_lexical_cast&) {
throw std::runtime_error("cannot cast " + key + " = " + (*this)[key]);
}
}
};
typedef std::vector<device_addr_t> device_addrs_t;
UHD_API device_addrs_t separate_device_addr(const device_addr_t& dev_addr);
UHD_API device_addr_t combine_device_addrs(const device_addrs_t& dev_addrs);
} // 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