diff options
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/example/db.cpp | 30 | ||||
-rw-r--r-- | src/example/savemgr.cpp | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 8158d60..9698c41 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -26,4 +26,5 @@ add_example(particle) add_example(physics) add_example(savemgr) add_example(proxy) +add_example(db) diff --git a/src/example/db.cpp b/src/example/db.cpp new file mode 100644 index 0000000..b1ab196 --- /dev/null +++ b/src/example/db.cpp @@ -0,0 +1,30 @@ +#include <crepe/DB.h> +#include <crepe/api/Config.h> +#include <crepe/util/log.h> + +using namespace crepe; +using namespace std; + +// run before main +static auto _ = [] () { + auto & cfg = api::Config::get_instance(); + cfg.log.level = util::LogLevel::TRACE; + return 0; +}(); + +int main() { + dbg_trace(); + + DB db("file.db"); + + const char * test_key = "test-key"; + string test_data = "Hello world!"; + + dbg_logf("DB has key = %d", db.has(test_key)); + + db.set(test_key, test_data); + + dbg_logf("key = \"%s\"", db.get(test_key).c_str()); + + return 0; +} diff --git a/src/example/savemgr.cpp b/src/example/savemgr.cpp index 5c034c4..2c03e3a 100644 --- a/src/example/savemgr.cpp +++ b/src/example/savemgr.cpp @@ -14,6 +14,7 @@ using namespace crepe::util; int main() { const char * key = "mygame.test"; + SaveManager & mgr = SaveManager::get_instance(); ValueBroker<unsigned int> & prop = mgr.get<unsigned int>(key, 0); |