LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
urirecord.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_URIRECORD_HPP
8#define LOGICALACCESS_URIRECORD_HPP
9
11#include <unordered_map>
12#include <functional>
13#include <iostream>
14
15namespace logicalaccess
16{
18 {
19 NO_PREFIX = 0x00, // no prefix
20 HTTP_WWW = 0x01, // http://www.
21 HTTPS_WWW = 0x02, // https://www.
22 HTTP = 0x03, // http://
23 HTTPS = 0x04, // https://
24 TEL = 0x05, // tel:
25 MAIL_TO = 0x06, // mailto:
26 URI_FILE = 0x1D // file://
27 };
28}
29
30namespace std {
31#ifdef SWIG
32// Hackfix to avoid SWIG warning about specializing a non template type.
33template<typename T> struct hash;
34#endif
35 template <> struct hash<logicalaccess::UriType>
36 {
37 size_t operator()(const logicalaccess::UriType & x) const
38 {
39 return hash<int>()(x);
40 }
41 };
42}
43
44namespace logicalaccess
45{
46 class LLA_CORE_API UriRecord : public NdefRecord
47 {
48 public:
50 : NdefRecord()
51 {
52 m_prefixeMap[NO_PREFIX] = "";
53 m_prefixeMap[HTTP_WWW] = "http://www.";
54 m_prefixeMap[HTTPS_WWW] = "https://www.";
55 m_prefixeMap[HTTP] = "http://";
56 m_prefixeMap[HTTPS] = "https://";
57 m_prefixeMap[TEL] = "tel:";
58 m_prefixeMap[MAIL_TO] = "mailto:";
59 m_prefixeMap[URI_FILE] = "file://";
60 m_prefixe = NO_PREFIX;
61 }
62
63 virtual ~UriRecord()
64 {
65 }
66
67 void init(TNF tnf, ByteVector type, ByteVector id, ByteVector payload) override;
68 void updatePayload();
69 void setUri(std::string uri);
70 std::string getUri();
71 void setPrefixe(UriType prefixe);
72 UriType getPrefixe() const;
73 private:
74 std::string m_uri;
76 std::unordered_map<UriType, std::string> m_prefixeMap;
77};
78}
79
80#endif
Definition: ndefrecord.hpp:28
Definition: urirecord.hpp:47
UriRecord()
Definition: urirecord.hpp:49
std::unordered_map< UriType, std::string > m_prefixeMap
Definition: urirecord.hpp:76
virtual ~UriRecord()
Definition: urirecord.hpp:63
std::string m_uri
Definition: urirecord.hpp:74
UriType m_prefixe
Definition: urirecord.hpp:75
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
TNF
Definition: ndefrecord.hpp:16
UriType
Definition: urirecord.hpp:18
@ HTTPS
Definition: urirecord.hpp:23
@ TEL
Definition: urirecord.hpp:24
@ MAIL_TO
Definition: urirecord.hpp:25
@ HTTP
Definition: urirecord.hpp:22
@ URI_FILE
Definition: urirecord.hpp:26
@ HTTPS_WWW
Definition: urirecord.hpp:21
@ NO_PREFIX
Definition: urirecord.hpp:19
@ HTTP_WWW
Definition: urirecord.hpp:20
Definition: urirecord.hpp:30
size_t operator()(const logicalaccess::UriType &x) const
Definition: urirecord.hpp:37