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
9 #include <nx/sdk/i_string_map.h>
10
11 namespace nx {
12 namespace sdk {
13
14 // TODO: Do something with O(N^2) complexity of lookup by index.
15 class StringMap: public RefCountable<IStringMap>
16 {
17 public:
18 using Map = std::map<std::string, std::string>;
19
20 StringMap() = default;
21
22 StringMap(Map map): m_map(std::move(map)) {}
23
24 void setItem(const std::string& key, const std::string& value);
25
26 void clear();
27
28 virtual int count() const override;
29
31 virtual const char* key(int i) const override;
32
34 virtual const char* value(int i) const override;
35
36 virtual const char* value(const char* key) const override;
37
38 private:
39 Map m_map;
40 };
41
42 } // namespace sdk
43 } // namespace nx
nx::sdk::StringMap
Definition: string_map.h:15
nx::sdk::StringMap::key
virtual const char * key(int i) const override
Definition: string_map.cpp:28
nx
Definition: apple_utils.h:6
nx::sdk::StringMap::value
virtual const char * value(int i) const override
Definition: string_map.cpp:38
nx::sdk::RefCountable
Definition: ref_countable.h:84