Updated core for tptr support
This commit is contained in:
@@ -45,13 +45,13 @@ public:
|
||||
JSONDB(const std::string &basePath) :
|
||||
_basePath(basePath)
|
||||
{
|
||||
_reload(_basePath);
|
||||
_reload(_basePath,std::string());
|
||||
}
|
||||
|
||||
inline void reload()
|
||||
{
|
||||
_db.clear();
|
||||
_reload(_basePath);
|
||||
_reload(_basePath,std::string());
|
||||
}
|
||||
|
||||
bool writeRaw(const std::string &n,const std::string &obj);
|
||||
@@ -63,12 +63,12 @@ public:
|
||||
inline bool put(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4,const nlohmann::json &obj) { return this->put((n1 + "/" + n2 + "/" + n3 + "/" + n4),obj); }
|
||||
inline bool put(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4,const std::string &n5,const nlohmann::json &obj) { return this->put((n1 + "/" + n2 + "/" + n3 + "/" + n4 + "/" + n5),obj); }
|
||||
|
||||
const nlohmann::json &get(const std::string &n,unsigned long maxSinceCheck = 0);
|
||||
const nlohmann::json &get(const std::string &n);
|
||||
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,unsigned long maxSinceCheck = 0) { return this->get((n1 + "/" + n2),maxSinceCheck); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,const std::string &n3,unsigned long maxSinceCheck = 0) { return this->get((n1 + "/" + n2 + "/" + n3),maxSinceCheck); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4,unsigned long maxSinceCheck = 0) { return this->get((n1 + "/" + n2 + "/" + n3 + "/" + n4),maxSinceCheck); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4,const std::string &n5,unsigned long maxSinceCheck = 0) { return this->get((n1 + "/" + n2 + "/" + n3 + "/" + n4 + "/" + n5),maxSinceCheck); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2) { return this->get((n1 + "/" + n2)); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,const std::string &n3) { return this->get((n1 + "/" + n2 + "/" + n3)); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4) { return this->get((n1 + "/" + n2 + "/" + n3 + "/" + n4)); }
|
||||
inline const nlohmann::json &get(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4,const std::string &n5) { return this->get((n1 + "/" + n2 + "/" + n3 + "/" + n4 + "/" + n5)); }
|
||||
|
||||
void erase(const std::string &n);
|
||||
|
||||
@@ -78,11 +78,11 @@ public:
|
||||
inline void erase(const std::string &n1,const std::string &n2,const std::string &n3,const std::string &n4,const std::string &n5) { this->erase(n1 + "/" + n2 + "/" + n3 + "/" + n4 + "/" + n5); }
|
||||
|
||||
template<typename F>
|
||||
inline void filter(const std::string &prefix,unsigned long maxSinceCheck,F func)
|
||||
inline void filter(const std::string &prefix,F func)
|
||||
{
|
||||
for(std::map<std::string,_E>::iterator i(_db.lower_bound(prefix));i!=_db.end();) {
|
||||
if ((i->first.length() >= prefix.length())&&(!memcmp(i->first.data(),prefix.data(),prefix.length()))) {
|
||||
if (!func(i->first,get(i->first,maxSinceCheck))) {
|
||||
if (!func(i->first,get(i->first))) {
|
||||
std::map<std::string,_E>::iterator i2(i); ++i2;
|
||||
this->erase(i->first);
|
||||
i = i2;
|
||||
@@ -95,16 +95,13 @@ public:
|
||||
inline bool operator!=(const JSONDB &db) const { return (!(*this == db)); }
|
||||
|
||||
private:
|
||||
void _reload(const std::string &p);
|
||||
void _reload(const std::string &p,const std::string &b);
|
||||
bool _isValidObjectName(const std::string &n);
|
||||
std::string _genPath(const std::string &n,bool create);
|
||||
|
||||
struct _E
|
||||
{
|
||||
nlohmann::json obj;
|
||||
uint64_t lastModifiedOnDisk;
|
||||
uint64_t lastCheck;
|
||||
|
||||
inline bool operator==(const _E &e) const { return (obj == e.obj); }
|
||||
inline bool operator!=(const _E &e) const { return (obj != e.obj); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user