Container System 0.1.0
High-performance C++20 type-safe container framework with SIMD-accelerated serialization
Loading...
Searching...
No Matches
value_store_example.cpp
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
13
14#include <kcenon/container/value_store.h>
15
16#include <iostream>
17#include <string>
18
19using namespace kcenon::container;
20
21int main()
22{
23 std::cout << "=== Value Store Example ===" << std::endl;
24
25 value_store store;
26
27 // 1. Add typed values
28 std::cout << "\n1. Adding values:" << std::endl;
29 store.add("host", value("host", std::string("localhost")));
30 store.add("port", value("port", static_cast<int32_t>(8080)));
31 store.add("debug", value("debug", true));
32 std::cout << " Size: " << store.size() << std::endl;
33
34 // 2. Get values
35 std::cout << "\n2. Reading values:" << std::endl;
36 auto host = store.get("host");
37 if (host.has_value())
38 {
39 std::cout << " host found: yes" << std::endl;
40 }
41
42 // 3. Check existence
43 std::cout << "\n3. Contains check:" << std::endl;
44 std::cout << " 'host': " << (store.contains("host") ? "yes" : "no") << std::endl;
45 std::cout << " 'missing': " << (store.contains("missing") ? "yes" : "no") << std::endl;
46
47 // 4. Remove
48 std::cout << "\n4. Remove 'debug':" << std::endl;
49 store.remove("debug");
50 std::cout << " Size after remove: " << store.size() << std::endl;
51
52 // 5. Statistics
53 std::cout << "\n5. Access statistics:" << std::endl;
54 std::cout << " Read count: " << store.get_read_count() << std::endl;
55 std::cout << " Write count: " << store.get_write_count() << std::endl;
56
57 store.reset_statistics();
58 std::cout << " After reset - reads: " << store.get_read_count()
59 << ", writes: " << store.get_write_count() << std::endl;
60
61 // 6. Clear
62 store.clear();
63 std::cout << "\n6. After clear: empty=" << (store.empty() ? "yes" : "no") << std::endl;
64
65 std::cout << "\nDone." << std::endl;
66 return 0;
67}
Enhanced type-safe value with perfect legacy compatibility.
Definition value.h:129
int main()