# simplekv **Repository Path**: sklink/simplekv ## Basic Information - **Project Name**: simplekv - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-10-27 - **Last Updated**: 2023-10-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SimpleKV Simple Key-Value database (in memory so far) #### Usage ##### [More detials](https://github.com/Forairaaaaa/simplekv/blob/main/example/basic_usage.cpp) ```cpp #include SIMPLEKV::SimpleKV db; ``` #### Basic type ```cpp db.Add("Age", 666); printf("Age: %d\n", db.Get("Age")->value()); // > Age: 666 db.Put("Age", -777); printf("Age: %d\n", db.Get("Age")->value()); // > Age: -777 db.Add("float", 6.666); db.Add("double", 2333.3333333333); printf("%f\n", db.Get("float")->value()); // > 6.666000 printf("%.10f\n", db.Get("double")->value()); // > 2333.3333333333 ``` #### Array ```cpp uint16_t data[10] = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27}; db.Add("Data", data); for (int i = 0; i < 10; i++) { printf("%d ", db.Get("Data")->value()[i]); } printf("\n"); // > 0 3 6 9 12 15 18 21 24 27 ``` #### Custom type ```cpp struct MyType_t { int a; float b; std::string status; }; MyType_t my_type_1 = {11, 1.11, "nihao"}; MyType_t my_type_2 = {-22, -2.22, "wohao"}; MyType_t my_type_temp = {0}; db.Add("MyType_1", (void*)&my_type_1, sizeof(MyType_t)); db.Add("MyType_2", (void*)&my_type_2, sizeof(MyType_t)); my_type_temp = db.Get("MyType_1")->value(); printf("%d %.2f %s\n", my_type_temp.a, my_type_temp.b, my_type_temp.status.c_str()); // > 11 1.11 nihao my_type_temp = db.Get("MyType_2")->value(); printf("%d %.2f %s\n", my_type_temp.a, my_type_temp.b, my_type_temp.status.c_str()); // > -22 -2.22 wohao ```