USRP Hardware Driver and USRP Manual  Version: 3.15.0.0-4+b1satnogs1
UHD and USRP Manual
cast.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2014-2015 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 #ifndef INCLUDED_UHD_UTILS_CAST_HPP
9 #define INCLUDED_UHD_UTILS_CAST_HPP
10 
11 #include <uhd/config.hpp>
12 #include <sstream>
13 #include <string>
14 
15 namespace uhd { namespace cast {
17 //
18 // Example:
19 // uint16_t x = hexstr_cast<uint16_t>("0xDEADBEEF");
20 // Uses stringstream.
21 template <typename T>
22 UHD_INLINE T hexstr_cast(const std::string& in)
23 {
24  T x;
25  std::stringstream ss;
26  ss << std::hex << in;
27  ss >> x;
28  return x;
29 }
30 
31 }} // namespace uhd::cast
32 
33 #endif /* INCLUDED_UHD_UTILS_CAST_HPP */
#define UHD_INLINE
Definition: config.h:53
UHD_INLINE T hexstr_cast(const std::string &in)
Convert a hexadecimal string into a value.
Definition: cast.hpp:22
Definition: build_info.hpp:13