twister-core/src/twister_utils.h

42 lines
1.0 KiB
C
Raw Normal View History

#ifndef TWISTER_UTILS_H
#define TWISTER_UTILS_H
2013-10-08 18:39:07 -03:00
#include "json/json_spirit.h"
#include "libtorrent/entry.hpp"
#include <string>
#include <vector>
2013-10-08 22:37:29 -03:00
#include <set>
// in-memory unencrypted DMs
struct StoredDirectMsg {
int64_t m_utcTime;
std::string m_text;
bool m_fromMe;
};
// in-memory data per wallet user
struct UserData {
std::set<std::string> m_following;
// m_directmsg key is the other username
std::map<std::string, std::vector<StoredDirectMsg> > m_directmsg;
2013-10-08 22:37:29 -03:00
};
class twister_utils
{
public:
twister_utils();
};
int load_file(std::string const& filename, std::vector<char>& v, int limit = 8000000);
int save_file(std::string const& filename, std::vector<char>& v);
json_spirit::Value entryToJson(const libtorrent::entry &e);
libtorrent::entry jsonToEntry(const json_spirit::Value &v);
2013-10-08 22:37:29 -03:00
int saveUserData(std::string const& filename, std::map<std::string,UserData> const &users);
int loadUserData(std::string const& filename, std::map<std::string,UserData> &users);
#endif // TWISTER_UTILS_H