### Using Gyverdbfile with LittleFS (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Provides a complete example demonstrating how to initialize and use the Gyverdbfile class with the LittleFS filesystem on ESP platforms. It shows how to set up the filesystem, initialize the database from a file, use the `init()` method to create entries if they don't exist, and call the `tick()` method in the loop for automatic saving. ```C++ #include #include Gyverdbfile DB (& Littlefs, "DB.BIN"); VOID setup () { Littlefs.Begin (); db.begin ();// read data from the file // For work in this mode, the Init () method is very useful: // creates a record of the corresponding type and writes out "initial" data, // If such a record is not yet in the database db.init ("key", 123);// int db.init ("uint", (uint8_t) 123);// uint8 db.init ("str", "");// line } VOID loop () { db.tick (); } ``` -------------------------------- ### Gyverdb Class Methods (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Documents the public methods available in the Gyverdb class for core database operations. This includes methods for construction, configuration, checking changes, dumping content, getting size, exporting/importing data, creating/getting/removing entries, checking existence, and setting/initializing data. ```C++ // Designer // you can reserve cells Gyverdb (uint16_t reserve = 0); // Do not change the type of recording (convert data if the type is different) (silence. True) VOID Keeptypes (Bool Keep); // Use the glass updates (silence. FALSE) VOID USEUPDATES (BOOL USE); // there was a change in data.After the response, it will drop in FALSE Bool Changed (); // Determine all the contents of the database VOID DUMP (Print & P); // Full weight of the database size_t size (); // Export size of the database (for writeto) Size_t Writesize (); // export the database in Stream (e.g. file) Bool Writeto (Stream & Stream); // export the database in the size of the size of writesize () Bool Writeto (Uint8_t* Buffer); // import a database from Stream (e.g. file) Bool Readfrom (Stream & Stream, Size_t Len); // import a databar from the buffer Bool Readfrom (Consta Uint8_t* Buffer, Size_t Len); // Create a record.If exists - rewrite empty with a new type Bool Create (Size_t Hash, GDB :: Type Type, Uint16_t Reserv = 0); // completely free memory VOID Reset (); // erase all notes (does not free up the reserved place) Void Clear (); // get an entry GDB :: Entry Get (Size_t Hash); GDB :: Entry Get (Constra Text & Key); // Delete the recording VOID REMOVE (SIZE_T HASH); VOID Remove (Const Text & Key); // database contains an entry with the name Bool has (size_t hash); Bool Has (Consta Text & Key); // Write data.Data - Any Type of Data Bool Set (Size_t Hash, Data); Bool Set (Consta Text & Key Hash, Data); // initialize the data (create a cell and write down if it is not).Data - Any Type of Data Bool Set (Size_t Hash, Data); Bool Set (Consta Text & Key Hash, Data); ``` -------------------------------- ### Entry Class Methods (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Documents the methods available on a database Entry object, which is returned by the `Get` method. These methods allow checking the entry's type, writing its raw bytes, converting its value to various C++ types, and converting it to text or string representations. ```C++ // type of record GDB :: Type Type (); // Bring the data to the size of size ().Does not add a 0-terminator if this is a line VOID Writebytes (VOID* BUF); // bring to the variable Bool Writeto (T & Dest); Value Totext (); String Tostring (); Bool Tobool (); int toint (); int8_t toint8 (); int16_t toint16 (); int32_t toint32 (); int64_t toint64 (); Double Tofloat (); ``` -------------------------------- ### Accessing Gyverdb Entries (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Demonstrates different ways to access database entries using string keys, hash codes generated by the compile-time SH() function, or the _h literal. ```CPP db ["key1"]; DB [SH ("Key2")]; db ["key3" _h]; ``` -------------------------------- ### Defining Gyverdb Keys with Enum (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Shows how to use a C++ enum with SH() or _h to create a base of hash keys, improving code readability and enabling IDE autocompletion for key names. ```CPP enum keys: size_t { Key1 = SH ("Key1"), key2 = "key1" _h, Mykey = "Mykey" _H, }; ``` -------------------------------- ### Recording and Reading Data in Gyverdb (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Illustrates how to record and read various data types, including integers, floats, strings, and binary data/arrays. Shows automatic type conversion during recording and reading, comparison methods, and handling composite types. ```CPP Gyverdb DB; // Record db ["key1"] = 1234; DB [SH ("Key2")] = 1234; db ["key3" _h] = 1234; // This cell is declared as int, the text is correctly adjusted to the number db ["key1"] = "123456"; // Reading.The library itself converts into the right type int i = db ["key1"]; Float F = DB [SH ("Key2")]; // Any data "printed", even binary Serial.println (db ["key3" _h]); // you can specify a specific type when output db ["key3" _h] .toint32 (); // can be compared with integer int i = 123; 123 == DB ["key1"]; // Comparison directly with lines works only in records with the type of string db ["key1"] == "str"; // but you can and like this, for any type of records // Totext () converts all types of database entries into a temporary line db ["key1"]. Totext () == "12345"; // gyverdb can record data from any type, even composite (arrays, structures) uint8_t arr [5] = {1, 2, 3, 4, 5}; db ["arr"] = arr; // Conclusion back.The type must have the same size! uint8_t arr2 [5]; db ["arr"]. Writeto (arr2); ``` -------------------------------- ### Gyverdbfile Class Methods (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Documents the public methods available in the Gyverdbfile class. This class inherits from Gyverdb and adds functionality for automatic persistence to a flash drive (like on ESP8266/ESP32), including setting the filesystem and path, configuring the write timeout, beginning file operations, forcing an update, and a tick method for use in the main loop. ```C++ Gyverdbfile (fs :: fs* nfs = nullptr, const char* PATH = NULLPTR, UINT32_T TOUT = 10000); // Installsystem and file name VOID setfs (fs :: fs* nfs, const char* Path); // Install the Takeout of the Records, MS (silence 1000) VOID settimeout (uint32_t tout = 10000); // Read the data Bool Begin (); // update data in the file now Bool update (); // ticker, call in LOOP.He will update the data himself when the timuta is changed and output, it will return True Bool Tick (); ``` -------------------------------- ### Defining Gyverdb Keys with Db_keys Macro (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Introduces the Db_keys macro as a convenient shorthand for defining the enum-based key base, simplifying the process compared to manual enum definition. ```CPP Db_keys (keys, Db_key (my_key), Db_key (key1), Db_key (wifi_ssid), ); ``` -------------------------------- ### Defining GyverDB Keywords - Syntax Definition Source: https://github.com/gyverlibs/gyverdb/blob/main/keywords.txt These lines map specific GyverDB datatypes to the 'KEYWORD1' syntax highlighting category. This helps text editors recognize and color these terms appropriately. ```Syntax Definition GyverDB KEYWORD1 GyverDBFile KEYWORD1 ``` -------------------------------- ### Define Compilation Settings (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Defines preprocessor macros to configure Gyverdb features before including the library header. These settings allow disabling specific features like updates, float support, int64 support, or automatic data conversion to reduce code size or change behavior. ```C++ #define db_no_updates // Remove glass updates #define db_no_float // Remove support for Float #define db_no_int64 // Remove support for int64 #define db_no_convert // Do not convert data (forcibly change the type of record, KeeptyPes does not work) ``` -------------------------------- ### Supported Data Types (C++) Source: https://github.com/gyverlibs/gyverdb/blob/main/README_EN.md Lists the data types supported by the Gyverdb library for storing values in key-value pairs. These types are used when creating or initializing database entries. ```C++ None Int8 Uint8 Int16 Uint16 Int32 Uint32 Int64 Uint64 Float String Bin ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.