nx_metadata_sdk 1.0 Metadata SDK

string_map.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <map>
6
7 #include <nx/sdk/helpers/ref_countable.h>
8 #include <nx/sdk/i_string_map.h>
9
10 namespace nx::sdk {
11
12 // TODO: Do something with O(N^2) complexity of lookup by index.
13 class StringMap: public RefCountable<IStringMap>
14 {
15 public:
16 using Map = std::map<std::string, std::string>;
17
18 StringMap() = default;
19
20 StringMap(Map map): m_map(std::move(map)) {}
21
22 void setItem(const std::string& key, const std::string& value);
23
24 void clear();
25
26 virtual int count() const override;
27
29 virtual const char* key(int i) const override;
30
32 virtual const char* value(int i) const override;
33
34 virtual const char* value(const char* key) const override;
35
36 private:
37 Map m_map;
38 };
39
40 } // namespace nx::sdk
nx::sdk::StringMap
Definition: string_map.h:13
nx::sdk::StringMap::key
virtual const char * key(int i) const override
Definition: string_map.cpp:27
nx::sdk
Definition: device_agent.h:12
nx::sdk::StringMap::value
virtual const char * value(int i) const override
Definition: string_map.cpp:37
nx::sdk::RefCountable
Definition: ref_countable.h:83