Dataset API Reference
This section provides details on the Windows System Data Dataset API, which enables the management and manipulation of structured data within the Windows operating system.
Dataset Structure
A Dataset object represents a collection of related tables, similar to a database or a spreadsheet. It facilitates the organization and retrieval of data through well-defined interfaces.
class Dataset { ... };
Members:
- Tables (Table Collection)
- A collection of
Tableobjects that are part of this dataset. - Relations (Relation Collection)
- Defines relationships between tables within the dataset.
- DataSetName (String)
- The name of the dataset.
Creating and Populating a Dataset
Datasets can be created programmatically and populated with data from various sources, such as files or other data structures.
Dataset::Dataset()
Dataset();
Constructs an empty Dataset object.
Dataset::AddTable(Table& table)
bool AddTable(Table& table);
Adds a Table object to the dataset. Returns true if successful, false otherwise.
Example:
// Assume 'myTable' is a valid Table object
Dataset myDataset;
if (myDataset.AddTable(myTable)) {
// Table successfully added
}
Accessing Tables
You can retrieve tables from a dataset by their name or index.
Dataset::GetTable(const std::string& tableName)
Table* GetTable(const std::string& tableName);
Retrieves a pointer to a Table object by its name. Returns nullptr if the table is not found.
Dataset::GetTableAt(int index)
Table* GetTableAt(int index);
Retrieves a pointer to a Table object by its zero-based index. Returns nullptr if the index is out of bounds.
nullptr when retrieving tables to handle cases where the table might not exist.
Dataset Operations
The Dataset API provides methods for various operations like merging, cloning, and serializing data.
Dataset::Merge(const Dataset& otherDataset)
void Merge(const Dataset& otherDataset);
Merges the contents of another dataset into the current dataset. This operation may involve merging tables with the same name or adding new tables.
Dataset::Clone() const
Dataset Clone() const;
Creates a deep copy of the dataset, including all its tables and their data.
Dataset::Save(const std::string& filePath) const
bool Save(const std::string& filePath) const;
Serializes the dataset to a specified file path. Supported formats include XML and binary. Returns true on success.
Dataset::Load(const std::string& filePath)
bool Load(const std::string& filePath);
Loads a dataset from a specified file path. Returns true on success.