MQTTSuite
Loading...
Searching...
No Matches
mqtt::lib::plugins::storage_plugin::Storage Class Reference

#include <Storage.h>

Collaboration diagram for mqtt::lib::plugins::storage_plugin::Storage:

Public Member Functions

 Storage (const Storage &)=delete
Storageoperator= (const Storage &)=delete
 ~Storage ()=default

Static Public Member Functions

static Storageinstance ()
static void store (const inja::Arguments &args)
static const std::string & recall (const inja::Arguments &args)
static int recall_as_int (const inja::Arguments &args)
static double recall_as_float (const inja::Arguments &args)
static bool is_empty (const inja::Arguments &args)
static bool exists (const inja::Arguments &args)

Private Member Functions

 Storage ()=default

Private Attributes

std::map< std::string, std::string > storage

Detailed Description

Definition at line 70 of file Storage.h.

Constructor & Destructor Documentation

◆ Storage() [1/2]

mqtt::lib::plugins::storage_plugin::Storage::Storage ( )
privatedefault

◆ Storage() [2/2]

mqtt::lib::plugins::storage_plugin::Storage::Storage ( const Storage & )
delete

◆ ~Storage()

mqtt::lib::plugins::storage_plugin::Storage::~Storage ( )
default

Member Function Documentation

◆ exists()

bool mqtt::lib::plugins::storage_plugin::Storage::exists ( const inja::Arguments & args)
static

Definition at line 109 of file Storage.cpp.

109 {
110 return instance().storage.contains(args.at(0)->get<std::string>());
111 }
std::map< std::string, std::string > storage
Definition Storage.h:95

References instance(), and storage.

Referenced by is_empty(), recall_as_float(), and recall_as_int().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instance()

Storage & mqtt::lib::plugins::storage_plugin::Storage::instance ( )
static

Definition at line 57 of file Storage.cpp.

57 {
58 static Storage storage;
59
60 return storage;
61 }

Referenced by exists(), is_empty(), recall(), recall_as_float(), recall_as_int(), and store().

Here is the caller graph for this function:

◆ is_empty()

bool mqtt::lib::plugins::storage_plugin::Storage::is_empty ( const inja::Arguments & args)
static

Definition at line 99 of file Storage.cpp.

99 {
100 bool result = true;
101
102 if (exists(args)) {
103 result = instance().storage[args.at(0)->get<std::string>()].empty();
104 }
105
106 return result;
107 }
static bool exists(const inja::Arguments &args)
Definition Storage.cpp:109

References exists(), instance(), and storage.

Here is the call graph for this function:

◆ operator=()

Storage & mqtt::lib::plugins::storage_plugin::Storage::operator= ( const Storage & )
delete

◆ recall()

const std::string & mqtt::lib::plugins::storage_plugin::Storage::recall ( const inja::Arguments & args)
static

Definition at line 67 of file Storage.cpp.

67 {
68 return instance().storage[args.at(0)->get<std::string>()];
69 }

References instance(), and storage.

Here is the call graph for this function:

◆ recall_as_float()

double mqtt::lib::plugins::storage_plugin::Storage::recall_as_float ( const inja::Arguments & args)
static

Definition at line 85 of file Storage.cpp.

85 {
86 double result = 0;
87
88 if (exists(args)) {
89 try {
90 result = std::stod(instance().storage[args.at(0)->get<std::string>()]);
91 } catch (const std::logic_error&) {
92 // no error if not exist - just return '0'
93 }
94 }
95
96 return result;
97 }

References exists(), instance(), and storage.

Here is the call graph for this function:

◆ recall_as_int()

int mqtt::lib::plugins::storage_plugin::Storage::recall_as_int ( const inja::Arguments & args)
static

Definition at line 71 of file Storage.cpp.

71 {
72 int result = 0;
73
74 if (exists(args)) {
75 try {
76 result = std::stoi(instance().storage[args.at(0)->get<std::string>()]);
77 } catch (const std::logic_error&) {
78 // no error if not exist - just return '0'
79 }
80 }
81
82 return result;
83 }

References exists(), instance(), and storage.

Here is the call graph for this function:

◆ store()

void mqtt::lib::plugins::storage_plugin::Storage::store ( const inja::Arguments & args)
static

Definition at line 63 of file Storage.cpp.

63 {
64 instance().storage[args.at(0)->get<std::string>()] = args.at(1)->get<std::string>();
65 }

References instance(), and storage.

Here is the call graph for this function:

Member Data Documentation

◆ storage

std::map<std::string, std::string> mqtt::lib::plugins::storage_plugin::Storage::storage
private

Definition at line 95 of file Storage.h.

Referenced by exists(), is_empty(), recall(), recall_as_float(), recall_as_int(), and store().


The documentation for this class was generated from the following files: