LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
tlv.hpp
Go to the documentation of this file.
1//
2// Created by xaqq on 3/20/15.
3//
4#pragma once
5
6#include <logicalaccess/lla_core_api.hpp>
8
9namespace logicalaccess
10{
21class LLA_CORE_API TLV
22{
23 public:
27 explicit TLV(uint8_t t);
28
29 virtual ~TLV() = default;
30
31 TLV(const TLV &) = delete;
32 TLV(TLV &&) = delete;
33 TLV &operator=(const TLV &) = delete;
34 TLV &operator=(TLV &&) = delete;
35
36
37 uint8_t tag() const;
38 void tag(uint8_t t);
39
44 ByteVector value() const;
45
50 uint8_t value_u1() const;
51
55 void value(bool v);
56
60 void value(unsigned char v);
61
65 void value(const ByteVector &v);
66
71 void value(TLVPtr tlv);
72
76 void value(std::vector<TLVPtr> tlv);
77
81 ByteVector compute() const;
82
83 TLVPtr get_child(uint8_t tag) const;
84
85 std::vector<TLVPtr> get_childs() const;
86
87 uint8_t getSizeTag() const;
88 void setSizeTag(uint8_t tag);
89 ByteVector getSizeVector() const;
90 void setSizeVector(ByteVector size);
91 ByteVector getCompletTLV() const;
92 static TLVPtr get_child(std::vector<TLVPtr> tlvs, uint8_t tag, bool required = true);
93
94 static std::vector<TLVPtr> parse_tlvs(const ByteVector &bytes,
95 size_t &bytes_consumed);
96 static std::vector<TLVPtr> parse_tlvs(const ByteVector &bytes, bool strict = false);
97 static ByteVector value_tlvs(std::vector<TLVPtr> tlvs);
98
99 private:
101 uint8_t tag_;
102 uint8_t sizeTag_;
103 ByteVector value_; // Either one of those
104 std::vector<TLVPtr> subTLVs_; // will be used, but not both.
105};
106
107} // namespace logicalaccess
Definition: tlv.hpp:22
uint8_t tag_
Definition: tlv.hpp:101
ByteVector sizeVector_
Definition: tlv.hpp:100
TLV(const TLV &)=delete
TLV(TLV &&)=delete
uint8_t sizeTag_
Definition: tlv.hpp:102
ByteVector value_
Definition: tlv.hpp:103
TLV & operator=(const TLV &)=delete
TLV & operator=(TLV &&)=delete
virtual ~TLV()=default
std::vector< TLVPtr > subTLVs_
Definition: tlv.hpp:104
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
std::shared_ptr< TLV > TLVPtr
Definition: lla_fwd.hpp:77