USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
cast.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2014-2015 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_UTILS_CAST_HPP
8 #define INCLUDED_UHD_UTILS_CAST_HPP
9 
10 #include <uhd/config.hpp>
11 #include <string>
12 #include <sstream>
13 
14 namespace uhd{ namespace cast{
16  //
17  // Example:
18  // uint16_t x = hexstr_cast<uint16_t>("0xDEADBEEF");
19  // Uses stringstream.
20  template<typename T> UHD_INLINE T hexstr_cast(const std::string &in)
21  {
22  T x;
23  std::stringstream ss;
24  ss << std::hex << in;
25  ss >> x;
26  return x;
27  }
28 
29 }} //namespace uhd::cast
30 
31 #endif /* INCLUDED_UHD_UTILS_CAST_HPP */
32 
UHD_INLINE T hexstr_cast(const std::string &in)
Convert a hexadecimal string into a value.
Definition: cast.hpp:20
Definition: build_info.hpp:14
#define UHD_INLINE
Definition: config.h:52