提交 c5f22628 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 5fab9b82
// g++ -std=c++1z test_database.cpp database.cpp -o test_database -lleveldb -Ivendor/include/ -Iinc -Lvendor/lib
#include "inc/database.h"
#include "spdlog/spdlog.h"
int main(){
json j;
int ret = 0;
// sn
ret = LVDB::delValue(LVDB_KEY_SN, LVDB_FILE_GENERAL);
spdlog::info("ret: {}", ret);
ret = LVDB::getSn(j, LVDB_FILE_GENERAL);
spdlog::info("ret2: {}, {}", ret, j.dump());
ret = LVDB::setSn(j, LVDB_FILE_GENERAL);
spdlog::info("ret: {}", ret);
j.clear();
ret = LVDB::getSn(j, LVDB_FILE_GENERAL);
spdlog::info("ret: {}, {}", ret, j.dump());
j.clear();
spdlog::info("ret: {}", ret);
ret = LVDB::getLocalConfig(j, LVDB_FILE_GENERAL);
spdlog::info("ret1: {}, {}", ret, j.dump());
ret= LVDB::setLocalConfig(j, LVDB_FILE_GENERAL);
spdlog::info("ret2: {}, {}", ret, j.dump());
ret = LVDB::getLocalConfig(j, LVDB_FILE_GENERAL);
spdlog::info("ret3: {}, {}", ret, j.dump());
return 0;
}
\ No newline at end of file
#include "inc/json.hpp"
#include <iostream>
using namespace nlohmann;
using namespace std;
int main() {
json origin = R"({"name": "john", "genda":"male"})"_json;
json newJ = R"({"name":"Jim", "age":10})"_json;
json diff = json::diff(origin, newJ);
cout << diff.dump();
}
\ No newline at end of file
#include "vendor/include/leveldb/db.h"
#include <iostream>
using namespace std;
int main(){
leveldb::DB* pdb;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/test.db", &pdb);
assert(status.ok());
string value;
status = pdb->Get(leveldb::ReadOptions(), "mykey1", &value);
if(!status.ok()) status = pdb->Put(leveldb::WriteOptions(), "mykey1", "myvalue1");
if(status.ok()) status = pdb->Get(leveldb::ReadOptions(), "mykey1", &value);
cout << value;
assert(value == "myvalue1");
if(status.ok()) status = pdb->Delete(leveldb::WriteOptions(), "mykey1");
delete pdb;
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论