StovePCMatchmaking(Native dll): D:/workspace/messenger/matchmaking_xmpp/stove_pc_matchmaking_sample/MetadataHelper.h Source File

StovePCMatchmaking(Native dll) 1.0.4.1

- Main Page
- Modules
- Classes
- Files
- Examples

- File List
- File Members

MetadataHelper.h
1 #ifndef MATCHMAKING_METADATA_HELPER_H_
2 #define MATCHMAKING_METADATA_HELPER_H_
3
4 #pragma once
5 #include <StovePCMatchmakingDefine.h>
6
7 #include <map>
8 #include <string>
9
10 // callback pointer => metadata conversion object
11 class MetadataHelper
12 {
13 using ItemMap = std::map<std::wstring, std::wstring>;
14
15 public:
16 MetadataHelper()
17 {
18 }
19 MetadataHelper(const StovePCMatchmakingMetadata* metadataArray, int32_t count)
20 {
21 if (nullptr == metadataArray)
22 return;
23
24 for (int32_t i = 0; i < count; ++i)
25 {
26 _items.insert(std::pair<std::wstring, std::wstring>(metadataArray[i].key, metadataArray[i].value));
27 }
28 }
29 ~MetadataHelper()
30 {
31 }
32
33 bool keyexist(const std::wstring& key)
34 {
35 ItemMap::iterator iter = _items.find(key);
36 if (iter != _items.end())
37 {
38 return true;
39 }
40 return false;
41 }
42
43 ItemMap::iterator find(const std::wstring& key)
44 {
45 return _items.find(key);
46 }
47
48 ItemMap::const_iterator find(const std::wstring& key) const
49 {
50 return _items.find(key);
51 }
52
53 bool empty() const
54 {
55 return _items.empty();
56 }
57
58 std::size_t size() const
59 {
60 return _items.size();
61 }
62
63 std::wstring& operator[](const std::wstring& key)
64 {
65 return _items[key];
66 }
67
68 const ItemMap::const_iterator cbegin() const { return _items.cbegin(); }
69 const ItemMap::const_iterator cend() const { return _items.cend(); }
70
71 const ItemMap::const_reverse_iterator crbegin() const { return _items.crbegin(); }
72 const ItemMap::const_reverse_iterator crend() const { return _items.crend(); }
73
74 ItemMap::iterator begin() { return _items.begin(); }
75 ItemMap::iterator end() { return _items.end(); }
76
77 ItemMap::reverse_iterator rbegin() { return _items.rbegin(); }
78 ItemMap::reverse_iterator rend() { return _items.rend(); }
79
80 private:
81 ItemMap _items;
82 };
83
84 #endif //MATCHMAKING_METADATA_HELPER_H_
MetadataHelper
Definition: MetadataHelper.h:11
StovePCMatchmakingDefine.h
StovePCMatchmakingDefine 헤더파일
StovePCMatchmakingMetadata
메타 구조체입니다.
Definition: StovePCMatchmakingDefine.h:478