72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
//
|
|
// Created by dongl on 23-5-7.
|
|
//
|
|
|
|
#ifndef IM2_POJSON_H
|
|
#define IM2_POJSON_H
|
|
|
|
#include <string>
|
|
#include <map>
|
|
|
|
#include "rapidjson.h"
|
|
|
|
// uint8_t belong_grouping; // 所属分组 默认好友列表
|
|
// time_t add_time; // 添加时间
|
|
// uint8_t add_source; // 添加来源
|
|
|
|
class PoJsonFriends {
|
|
public:
|
|
PoJsonFriends() {};
|
|
virtual ~PoJsonFriends() {}
|
|
public:
|
|
PoJsonFriends* append(uint64_t account, uint8_t belong_grouping, time_t add_time, uint8_t add_source) {
|
|
temp.insert({"belong_grouping", belong_grouping});
|
|
temp.insert({"add_time", add_time});
|
|
temp.insert({"add_source", add_source});
|
|
|
|
friends.insert({account, temp});
|
|
|
|
temp.clear();
|
|
return this;
|
|
}
|
|
|
|
public:
|
|
std::map<uint64_t, std::map<std::string, uint64_t>> to_map() {
|
|
return friends;
|
|
}
|
|
|
|
std::string to_string() {
|
|
|
|
std::string ret;
|
|
ret.append("{ \n");
|
|
|
|
for (const auto &item: friends) {
|
|
ret.append(std::to_string(item.first));
|
|
ret.append(" : { ");
|
|
|
|
for (const auto &it: item.second) {
|
|
ret.append(it.first);
|
|
ret.push_back(':');
|
|
ret.append(std::to_string(it.second));
|
|
ret.append(", ");
|
|
}
|
|
ret.pop_back();
|
|
ret.pop_back();
|
|
|
|
ret.append(" }\n");
|
|
}
|
|
|
|
|
|
ret.append("}");
|
|
return ret;
|
|
}
|
|
|
|
private:
|
|
// uid : userinfo
|
|
std::map<uint64_t, std::map<std::string, uint64_t>> friends;
|
|
std::map<std::string, uint64_t> temp;
|
|
};
|
|
|
|
|
|
#endif //IM2_POJSON_H
|