LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
bufferhelper.hpp
Go to the documentation of this file.
1
7#ifndef BUFFERHELPER_HPP
8#define BUFFERHELPER_HPP
9
10#include <stdint.h>
11#include <vector>
12#include <string>
13#include <logicalaccess/lla_core_api.hpp>
15
16namespace logicalaccess
17{
21class LLA_CORE_API BufferHelper
22{
23 public:
24 static std::string toBase64(const ByteVector &buf);
25
26 static ByteVector fromBase64(const std::string &b64str);
27
28 static std::string getHex(const ByteVector &buffer);
29
30 static std::string getHex(const std::string &buffer);
31
32 static ByteVector fromHexString(std::string hexString);
33
34 static std::string getStdString(const ByteVector &buffer);
35
36 static void setUShort(ByteVector &buffer, const unsigned short &value);
37
38 static unsigned short getUShort(const ByteVector &buffer, size_t &offset);
39
40 static void setInt32(ByteVector &buffer, const long &value);
41
42 static long getInt32(const ByteVector &buffer, size_t &offset);
43
44 static unsigned long getUInt32(const ByteVector &buffer, size_t &offset);
45
46 static void setUInt32(ByteVector &buffer, const unsigned long &value);
47
48 static void setUInt64(ByteVector &buffer, const unsigned long long &value);
49
50 static uint64_t getUInt64(const ByteVector &buffer, size_t &offset);
51
52 static void setUInt16(ByteVector &buffer, const unsigned long &value);
53
54 static unsigned long getUInt16(const ByteVector &buffer, size_t &offset);
55
56 static void setString(ByteVector &buffer, const std::string &value);
57
61 template <typename Buffer>
62 static bool allZeroes(const Buffer &buf)
63 {
64 for (const auto &byte : buf)
65 {
66 if (byte)
67 return false;
68 }
69 return true;
70 }
71};
72}
73
74#endif /* BUFFERHELPER_HPP */
A buffer helper class.
Definition: bufferhelper.hpp:22
static bool allZeroes(const Buffer &buf)
Definition: bufferhelper.hpp:62
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9