get_values_from_table
Function: get_values_from_table
get_values_from_tableThe get_values_from_table function retrieves all records (rows) stored in memory for a specified table. These records are returned as a vector of key-value pairs, where the keys represent column names and the values are stored using std::any.
Declaration
std::vector<std::unordered_map<std::string, std::any>>* get_values_from_table(std::string table);Parameters
table(std::string) The name of the table from which values should be retrieved. The table must already exist and be loaded in memory.
Return Value
std::vector<std::unordered_map<std::string, std::any>>*A pointer to the in-memory vector containing all records for the specified table:Each element in the vector represents a single record (or row).
Each record is a map where:
The key is the column name.
The value is the data stored in that column, wrapped in
std::any.
Functionality
Database Validation The function does not explicitly validate whether the database is open or whether the table exists. It directly accesses the
tablesattribute of thedata_baseclass, relying on the integrity of this map.Access Records in Memory It retrieves the vector of records associated with the specified table from the
tablesmap.Pointer Return The function returns a pointer to the in-memory vector, allowing efficient access to the data for further processing.
Example
Here’s an example demonstrating how to use the get_values_from_table function:
Last updated