USRP Hardware Driver and USRP Manual: byte_vector.hpp Source File

| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
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 <cstddef>
14#include <cstdint>
15#include <string>
16#include <vector>
17
18namespace uhd {
19
21 typedef std::vector<uint8_t> byte_vector_t;
22
23template <typename RangeSrc, typename RangeDst>
24 UHD_INLINE void byte_copy(const RangeSrc& src, RangeDst& dst)
25{
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
UHD_INLINE
#define UHD_INLINE
Definition config.h:65
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
uhd
Definition build_info.hpp:12
uhd::byte_vector_t
std::vector< uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition byte_vector.hpp:21
uhd::string_to_bytes
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::byte_copy
UHD_INLINE void byte_copy(const RangeSrc &src, RangeDst &dst)
Definition byte_vector.hpp:24
uhd::bytes_to_string
UHD_API std::string bytes_to_string(const byte_vector_t &bytes)
Create a string from a byte vector, terminate when invalid ASCII encountered.