mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-02 16:52:49 +00:00
.
This commit is contained in:
parent
cae9041c2a
commit
0d108d37f6
@ -63,24 +63,6 @@ using json = nlohmann::json;
|
|||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
// JSON blob I/O
|
|
||||||
/*
|
|
||||||
static json _readJson(const std::string &path)
|
|
||||||
{
|
|
||||||
std::string buf;
|
|
||||||
if (OSUtils::readFile(path.c_str(),buf)) {
|
|
||||||
try {
|
|
||||||
return json::parse(buf);
|
|
||||||
} catch ( ... ) {}
|
|
||||||
}
|
|
||||||
return json::object();
|
|
||||||
}
|
|
||||||
static bool _writeJson(const std::string &path,const json &obj)
|
|
||||||
{
|
|
||||||
return OSUtils::writeFile(path.c_str(),obj.dump(2));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Get JSON values as unsigned integers, strings, or booleans, doing type conversion if possible
|
// Get JSON values as unsigned integers, strings, or booleans, doing type conversion if possible
|
||||||
static uint64_t _jI(const json &jv,const uint64_t dfl)
|
static uint64_t _jI(const json &jv,const uint64_t dfl)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#ifndef ZT_JSONDB_HPP
|
#ifndef ZT_JSONDB_HPP
|
||||||
#define ZT_JSONDB_HPP
|
#define ZT_JSONDB_HPP
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -75,7 +78,7 @@ public:
|
|||||||
inline void filter(const std::string &prefix,unsigned long maxSinceCheck,F func)
|
inline void filter(const std::string &prefix,unsigned long maxSinceCheck,F func)
|
||||||
{
|
{
|
||||||
for(std::map<std::string,_E>::iterator i(_db.lower_bound(prefix));i!=_db.end();) {
|
for(std::map<std::string,_E>::iterator i(_db.lower_bound(prefix));i!=_db.end();) {
|
||||||
if (i->first.substr(0,prefix.length()) == prefix) {
|
if ((i->first.length() >= prefix.length())&&(!memcmp(i->first.data(),prefix.data(),prefix.length()))) {
|
||||||
if (!func(i->first,get(i->second.obj,maxSinceCheck))) {
|
if (!func(i->first,get(i->second.obj,maxSinceCheck))) {
|
||||||
std::map<std::string,_E>::iterator i2(i); ++i2;
|
std::map<std::string,_E>::iterator i2(i); ++i2;
|
||||||
this->erase(i->first);
|
this->erase(i->first);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user