-
Notifications
You must be signed in to change notification settings - Fork 23
/
mosquittoauthoptcompatwrap.h
58 lines (45 loc) · 1.67 KB
/
mosquittoauthoptcompatwrap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef MOSQUITTOAUTHOPTCOMPATWRAP_H
#define MOSQUITTOAUTHOPTCOMPATWRAP_H
#include <vector>
#include <unordered_map>
#include <cstring>
#include <string>
/**
* @brief The mosquitto_auth_opt struct is a resource managed class of auth options, compatible with passing as arguments to Mosquitto
* auth plugins.
*
* It's fully assignable and copyable.
*/
struct mosquitto_auth_opt
{
char *key = nullptr;
char *value = nullptr;
mosquitto_auth_opt(const std::string &key, const std::string &value);
mosquitto_auth_opt(mosquitto_auth_opt &&other);
mosquitto_auth_opt(const mosquitto_auth_opt &other);
~mosquitto_auth_opt();
mosquitto_auth_opt& operator=(const mosquitto_auth_opt &other);
};
/**
* @brief The AuthOptCompatWrap struct contains a vector of mosquitto auth options, with a head pointer and count which can be passed to
* Mosquitto auth plugins.
*/
struct AuthOptCompatWrap
{
std::vector<struct mosquitto_auth_opt> optArray;
AuthOptCompatWrap(const std::unordered_map<std::string, std::string> &authOpts);
AuthOptCompatWrap(const AuthOptCompatWrap &other) = default;
AuthOptCompatWrap(AuthOptCompatWrap &&other) = delete;
AuthOptCompatWrap() = default;
struct mosquitto_auth_opt *head() { return &optArray[0]; }
int size() { return optArray.size(); }
AuthOptCompatWrap &operator=(const AuthOptCompatWrap &other) = default;
};
#endif // MOSQUITTOAUTHOPTCOMPATWRAP_H