USRP Hardware Driver and USRP Manual  Version: 003.009.007-0-g50839059
UHD and USRP Manual
byte_vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2015 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_TYPES_BYTE_VECTOR_HPP
19 #define INCLUDED_UHD_TYPES_BYTE_VECTOR_HPP
20 
21 #include <algorithm>
22 #include <string>
23 #include <vector>
24 
25 #include <boost/assign.hpp>
26 #include <boost/cstdint.hpp>
27 
28 #include <uhd/config.hpp>
29 
30 namespace uhd{
31 
33  typedef std::vector<boost::uint8_t> byte_vector_t;
34 
35  template<typename RangeSrc, typename RangeDst> UHD_INLINE
36  void byte_copy(const RangeSrc &src, RangeDst &dst){
37  std::copy(boost::begin(src), boost::end(src), boost::begin(dst));
38  }
39 
41  UHD_API std::string bytes_to_string(const byte_vector_t &bytes);
42 
44  UHD_API byte_vector_t string_to_bytes(const std::string &str, size_t max_length);
45 
46 } //namespace uhd
47 
48 #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:36
Definition: convert.hpp:28
#define UHD_INLINE
Definition: config.h:56
std::vector< boost::uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition: byte_vector.hpp:33
#define UHD_API
Definition: config.h:66