### Initializing GyverLibs Pairs Classes (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Provides examples demonstrating how to initialize instances of the Pairsext, Pairs, Pairsstatic, and Pairsfile classes, highlighting the differences in their constructors and setup requirements. ```C++ // PAIRSEXT Char str [100] = {0}; PAIRSEXT P (str, 100); // PAIRSEXT Pairs p; // PAIRSEXT PAIRSSTATIC <00> p; // Pairsfile Pairsfile P (& Littlefs, "/data.dat"); // Before calling Begin () the file system must be launched! ``` -------------------------------- ### Performing Basic Operations with Pairs Objects (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Shows common operations like setting, getting, and removing key-value pairs using different data types and access methods (array-like access, Set, Get, Remove). It also illustrates string manipulation and mentions potential memory fragmentation with dynamic pairs. ```C++ // Record.Data types in any combinations p ["key0"] = "val0"; p [f ("key1")] = 1234; p [0] = f ("abcd"); P.Set ("Key2", 3.14); P.Setn (0, ("New Val 0")); // Reading Serial.println (p ["key0"]);// Auto-Cast in String int i = p ["key1"]. Toint (); Float F = P.Get ("Key2"). Tofloat (); // Deleting P.remove (F ("Key1")); P.removen (0); // Work with String.So - it will also work String Val = "Value"; P [String ("Key") + 1] = Val; // But you need to remember that this can create a fragmentation of memory // If dynamic pairs are used ``` -------------------------------- ### Using Pairsfile with ESP Filesystem (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Provides a basic example demonstrating how to use the Pairsfile class with an ESP filesystem (LittleFS). It shows initializing the filesystem, reading data from the file using Begin, modifying data, and calling Tick in the main loop for automatic saving. ```C++ Pairsfile Data (& Littlefs, "/data.dat", 3000); VOID setup () { Littlefs.Begin (); Data.Begin ();// read from the file Data ["key"] = "value";// changed } VOID loop () { Data.tick ();// tick here.Will update itself after the timeout } ``` -------------------------------- ### Pairs Data Format Example Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Illustrates the basic text format used by the Pairs library for storing key-value pairs. Each pair is on a new line, with the key in double quotes, followed by a colon and the value. ```Text "Key0": Value0 "Key1": value1 "Key2": value2 ``` -------------------------------- ### Defining Pairsext Class API (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Lists the constructor, member variables, and methods available in the Pairsext class, which is based on an external character buffer. It details functions for buffer management, data access, type conversion, and pair manipulation. ```C++ // Designer Pairsext (); Pairsext (char* str, uint16_t size);// connect an external size size buffer // variables Char* str;// Line for manual access uint16_t size;// specified Max.size // Methods VOID SetBuffer (Char* str, uint16_t len); // Connect the buffer Void Clear ();// Clean the line Bool Changed ();// there was a change in data.Will drop in FALSE itself Bool Contains (Anytext Key);// existence uint16_t Length ();// Actual line length uint16_t amount ();// The number of steam VOID Refresh ();// count the length of the line and the number of pairs (after manual changes) Bool Set (Anytext Key, Anyvalue Value);// install on the key Bool setn (Uint16_t IDX, ANYVALUE VALUE); // Install the index Pair get (Anytext Key);// get on the key Pair getn (uint16_t IDX);// Get the index int32_t toint ();// Bend into int Float Tofloat ();// Bring to Float String Tostring ();// Bring to String Bool Tochar (Char* Buf, Uint16_T LEN);// Bring out in the Char Bool Remove (Anytext Key);// Delete on the key Bool Removen (Uint16_T IDX);// Delete the index ``` -------------------------------- ### Defining Pairsfile Class API (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Lists the constructor and methods for the Pairsfile class, designed for automatic storage and updating of key-value pairs in a file (specifically for ESP8266/ESP32). It inherits from Pairs and adds file-specific methods like setFs, setTimeout, Begin, update, and Tick. ```C++ // Designer // install the file system, file name and timut PAIRSFILE (fs :: fs* nfs = nullptr, constel* path = nullptr, uint32_t tout = 10000); // Methods // inherits everything from pairs // install the file system 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 in the buffer.Optionally expand the additional place.True if you read Bool Begin (uint16_t res = 0); // update data in the file 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 Pairs Class API (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Lists the constructor and methods for the Pairs class, which uses a dynamic string for storage. It notes that it inherits most methods from Pairsext but adds a Reserve method. ```C++ // Designer Pairs (); Pairs (uint16_t size);// indicating the string reserve // Methods Bool Reserve (Uint16_T LEN);// Reserve a line // inherits everything from PAIRSEXT ``` -------------------------------- ### Defining Pairsstatic Class API (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Lists the constructor for the Pairsstatic class. This class is based on Pairsext but uses an internal, fixed-size array for storage, specified via a template parameter. It inherits methods from Pairsext. ```C++ // Designer Pairsstatic (); // Methods // inherits everything from PAIRSEXT ``` -------------------------------- ### Defining pair_t Struct API (C++) Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Lists the members and methods of the pair_t object, which represents a single key-value pair. It stores pointers and lengths for the key and value and provides methods for converting the value to different data types. ```C++ Const Char* Key;// key uint16_t key_len;// Key length const chaar* valle;// meaning uint16_t val_len;// length of the value // Bring the value to the chamber array Bool Tochar (Char* Buf, Uint16_T LEN); int32_t toint ();// Bring value in int Float Tofloat ();// Bring the valuein Float String Tostring ();// Bring the value to string String Tostring (false);// display a value in string without screens \\ ``` -------------------------------- ### Shielding Double Quotes in Pairs Text Format Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Shows how to correctly escape double quotes within a value when storing data in the Pairs text format. A backslash (\) is used before the double quote. ```Text "Key0": Val "ue0 - wrong "Key1": val \"ue1 - correctly ``` -------------------------------- ### Shielding Double Quotes in C++ String Assignment for Pairs Source: https://github.com/gyverlibs/pairs/blob/main/README_EN.md Demonstrates the correct way to escape double quotes within a string literal in C++ when assigning a value that contains a double quote to a Pairs object. Double backslashes (\\) are needed before the escaped double quote (\" becomes \\\"). ```CPP Data ["Key"] = "Val \" ue "; // is wrong (equivalent to the value of val\" ue) Data ["Key"] = "Val \\\" UE "; // Correctly (equivalent to the value of val \" ue) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.