USRP Hardware Driver and USRP Manual Version: 4.1.0.1
UHD and USRP Manual
byte_vector.hpp
Go to the documentation of this file.
1//
2// Copyright 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#pragma once
9
10#include <uhd/config.hpp>
11#include <boost/range.hpp>
12#include <algorithm>
13#include <string>
14#include <vector>
15
16namespace uhd {
17
19typedef std::vector<uint8_t> byte_vector_t;
20
21template <typename RangeSrc, typename RangeDst>
22UHD_INLINE void byte_copy(const RangeSrc& src, RangeDst& dst)
23{
24 std::copy(boost::begin(src), boost::end(src), boost::begin(dst));
25}
26
28UHD_API std::string bytes_to_string(const byte_vector_t& bytes);
29
31UHD_API byte_vector_t string_to_bytes(const std::string& str, size_t max_length);
32
33} // namespace uhd
#define UHD_INLINE
Definition: config.h:55
#define UHD_API
Definition: config.h:70
Definition: build_info.hpp:12
std::vector< uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition: byte_vector.hpp:19
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:22
UHD_API std::string bytes_to_string(const byte_vector_t &bytes)
Create a string from a byte vector, terminate when invalid ASCII encountered.