USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
byte_vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2015 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_TYPES_BYTE_VECTOR_HPP
8 #define INCLUDED_UHD_TYPES_BYTE_VECTOR_HPP
9 
10 #include <algorithm>
11 #include <string>
12 #include <vector>
13 
14 #include <boost/assign.hpp>
15 #include <stdint.h>
16 
17 #include <uhd/config.hpp>
18 
19 namespace uhd{
20 
22  typedef std::vector<uint8_t> byte_vector_t;
23 
24  template<typename RangeSrc, typename RangeDst> UHD_INLINE
25  void byte_copy(const RangeSrc &src, RangeDst &dst){
26  std::copy(boost::begin(src), boost::end(src), boost::begin(dst));
27  }
28 
30  UHD_API std::string bytes_to_string(const byte_vector_t &bytes);
31 
33  UHD_API byte_vector_t string_to_bytes(const std::string &str, size_t max_length);
34 
35 } //namespace uhd
36 
37 #endif /* INCLUDED_UHD_TYPES_BYTE_VECTOR_HPP */
UHD_API std::string bytes_to_string(const byte_vector_t &bytes)
Create a string from a byte vector, terminate when invalid ASCII encountered.
UHD_API byte_vector_t string_to_bytes(const std::string &str, size_t max_length)
Create a byte vector from a string, end at null terminator or max length.
UHD_INLINE void byte_copy(const RangeSrc &src, RangeDst &dst)
Definition: byte_vector.hpp:25
Definition: build_info.hpp:14
#define UHD_INLINE
Definition: config.h:52
#define UHD_API
Definition: config.h:62
std::vector< uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition: byte_vector.hpp:22