IOFormat 1.12.0
Loading...
Searching...
No Matches
OptionMap.h
1#pragma once
2
3#include <cstdint>
4#include <string>
5
6#include <iolink/DataType.h>
7
8#include <ioformat/IOFormatAPI.h>
9
10namespace ioformat
11{
12
33class IOFORMAT_API OptionMap
34{
35public:
39 class IOFORMAT_API iterator
40 {
41 public:
42 class Private;
43
44 iterator(Private* p);
45 ~iterator();
46
47 iterator(const iterator& other);
48 iterator& operator=(const iterator& other);
49 iterator(iterator&& other) noexcept;
50 iterator& operator=(iterator&& other) noexcept;
51
52 // deference operators
53 const std::string& operator*() const;
54 const std::string* operator->() const;
55
56 // increment operators
57 iterator& operator++();
58 iterator operator++(int);
59
60 // comparison operators
61 bool operator==(const iterator& other) const;
62 bool operator!=(const iterator& other) const;
63
64 private:
65 Private* m_private;
66 };
67
68 OptionMap();
69 ~OptionMap();
70
71 OptionMap(const OptionMap& other);
72 OptionMap& operator=(const OptionMap& other);
73 OptionMap(OptionMap&& other) noexcept;
74 OptionMap& operator=(OptionMap&& other) noexcept;
75
79 size_t size() const;
80
84 bool empty() const;
85
91 bool has(const std::string& key) const;
92
100 iolink::DataType dtype(const std::string& key) const;
101
112 size_t count(const std::string& key) const;
113
121 void remove(const std::string& key);
122
126 std::string toString() const;
127
128 // === //
129 // GET //
130 // === //
131
140 bool getBool(const std::string& key) const;
141
150 const std::string& getString(const std::string& key) const;
151
160 const int64_t* getIntPtr(const std::string& key) const;
161
172 int64_t getInt(const std::string& key, size_t index) const;
173
184 int64_t getInt(const std::string& key) const;
185
194 const double* getFloatPtr(const std::string& key) const;
195
206 double getFloat(const std::string& key, size_t index) const;
207
218 double getFloat(const std::string& key) const;
219
220 // === //
221 // SET //
222 // === //
223
230 void setBool(const std::string& key, bool value);
231
238 void setString(const std::string& key, const std::string& value);
239
247 void setInt(const std::string& key, const int64_t* values, size_t count);
248
257 void setInt(const std::string& key, int64_t value);
258
266 void setFloat(const std::string& key, const double* values, size_t count);
267
276 void setFloat(const std::string& key, double value);
277
278 // ========= //
279 // ITERATORS //
280 // ========= //
281
286
290 iterator end() const;
291
292private:
293 class Private;
294 Private* m_private;
295};
296
297} // namespace ioformat
An iterator on OptionMap keys.
Definition OptionMap.h:40
A map of heterogeneous options.
Definition OptionMap.h:34
iterator begin() const
Get an iterator on the beginning of the option map.
double getFloat(const std::string &key) const
Get a float value.
void setString(const std::string &key, const std::string &value)
Associate a string value with a specific key.
bool has(const std::string &key) const
Check if a key is present.
void setInt(const std::string &key, int64_t value)
Associate an integer value with a specific key.
iolink::DataType dtype(const std::string &key) const
Get the option data type.
size_t size() const
Get the number of element in the option map.
const int64_t * getIntPtr(const std::string &key) const
Get a pointer to the integer array first value.
size_t count(const std::string &key) const
Get the number of values associated with a key.
double getFloat(const std::string &key, size_t index) const
Get the float value at the given index.
const double * getFloatPtr(const std::string &key) const
Get a pointer to the float array first value.
void remove(const std::string &key)
Remove a key from the option map.
int64_t getInt(const std::string &key, size_t index) const
Get the integer value at a given index.
bool empty() const
Check if the option map is empty.
std::string toString() const
Get a string representation of the option map.
void setFloat(const std::string &key, const double *values, size_t count)
Associate a float array with a specific key.
void setBool(const std::string &key, bool value)
Associate a boolean value with a specific key.
void setFloat(const std::string &key, double value)
Associate a float value with a specific key.
void setInt(const std::string &key, const int64_t *values, size_t count)
Associate an integer array with a specific key.
const std::string & getString(const std::string &key) const
Get a string value.
iterator end() const
Get an iterator on the end of the option map.
int64_t getInt(const std::string &key) const
Get an integer value.
bool getBool(const std::string &key) const
Get a boolean value.
Global namespace which contains all methods to encode/decode data from/into different resources (file...
Definition Error.h:6