forked from holalula/hbqj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCItemInfo.cpp
More file actions
25 lines (22 loc) · 703 Bytes
/
Copy pathCItemInfo.cpp
File metadata and controls
25 lines (22 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "CItemInfo.h"
void CItemInfo::update() {
readJ.ReadJsonFile("ItemInfo.json");
id2name.erase(id2name.begin(), id2name.end());
name2id.erase(name2id.begin(), name2id.end());
for (Value::ConstMemberIterator itr = readJ.document.MemberBegin(); itr != readJ.document.MemberEnd(); itr++) {
Value jkey;
Value jvalue;
Document::AllocatorType allocator;
jkey.CopyFrom(itr->name, allocator);
jvalue.CopyFrom(itr->value, allocator);
if (jkey.IsString()) {
if (jvalue.IsInt()) {
string strKey = jkey.GetString();
int intValue = jvalue.GetInt();
//
this->id2name.insert(make_pair(intValue, strKey));
this->name2id.insert(make_pair(strKey, intValue));
}
}
}
}