opatIO-cpp 0.3.0a
Open Parametrized Array Table
|
Namespaces | |
namespace | lattice |
Namespace for table lattice interpolation of OPAT files. | |
Classes | |
struct | Bounds |
Structure to hold the minimum and maximum values for a dimension. More... | |
struct | CardCatalog |
Structure to hold the catalog of tables in a DataCard. More... | |
struct | CardCatalogEntry |
Structure to hold the index information of a table in an OPAT file. More... | |
struct | CardHeader |
Structure to hold the header information of a DataCard in an OPAT file. More... | |
struct | DataCard |
Structure to hold a DataCard, which contains multiple tables. More... | |
struct | Header |
Structure to hold the header information of an OPAT file. More... | |
struct | OPAT |
Structure to hold the entire OPAT file. More... | |
struct | OPATTable |
Structure to hold the data of an OPAT table. More... | |
struct | Slice |
Structure to represent a slice of data. More... | |
struct | TableIndex |
Structure to hold the index of tables within a DataCard. More... | |
struct | TableIndexEntry |
Structure to hold the index information of a table within a DataCard. More... | |
Functions | |
bool | is_big_endian () |
Determines if the system is big-endian. | |
bool | hasMagic (const std::string &filename) |
Checks if a file has the correct magic number for an OPAT file. | |
OPAT | readOPAT (const std::string &filename) |
Reads an OPAT file and returns its contents as an OPAT structure. | |
Header | readHeader (std::ifstream &file) |
Reads the header of an OPAT file. | |
CardCatalogEntry | readCardCatalogEntry (std::ifstream &file, uint64_t offset, uint16_t numIndex, uint8_t hashPrecision) |
Reads a CardCatalogEntry from the file. | |
CardCatalog | readCardCatalog (std::ifstream &file, const Header &header) |
Reads the CardCatalog from the file. | |
std::unordered_map< FloatIndexVector, DataCard > | readDataCards (std::ifstream &file, const Header &header, const CardCatalog &cardCatalog) |
Reads all DataCards from the file. | |
DataCard | readDataCard (std::ifstream &file, const CardCatalogEntry &entry) |
Reads a single DataCard from the file. | |
CardHeader | readDataCardHeader (std::ifstream &file, const CardCatalogEntry &entry) |
Reads the header of a DataCard from the file. | |
TableIndex | readTableIndex (std::ifstream &file, const CardCatalogEntry &entry, const CardHeader &header) |
Reads the TableIndex from a DataCard. | |
OPATTable | readOPATTable (std::ifstream &file, const CardCatalogEntry &cardEntry, const TableIndexEntry &tableEntry) |
Reads an OPATTable from the file. | |
std::ostream & | operator<< (std::ostream &os, const Header &header) |
std::ostream & | operator<< (std::ostream &os, const CardHeader &header) |
std::ostream & | operator<< (std::ostream &os, const CardCatalogEntry &entry) |
std::ostream & | operator<< (std::ostream &os, const CardCatalog &catalog) |
std::ostream & | operator<< (std::ostream &os, const TableIndexEntry &entry) |
std::ostream & | operator<< (std::ostream &os, const TableIndex &index) |
std::ostream & | operator<< (std::ostream &os, const OPATTable &table) |
std::ostream & | operator<< (std::ostream &os, const DataCard &card) |
std::ostream & | operator<< (std::ostream &os, const OPAT &opat) |
std::ostream & | operator<< (std::ostream &os, const Slice &slice) |
std::ostream & | operator<< (std::ostream &os, const Bounds &bounds) |
template<typename T> | |
T | swap_bytes (T value) |
Swaps the byte order of a value. | |
bool opat::hasMagic | ( | const std::string & | filename | ) |
Checks if a file has the correct magic number for an OPAT file.
This function reads the first four bytes of the file and compares them to the expected "OPAT" magic number.
filename | Path to the file. |
Example:
bool opat::is_big_endian | ( | ) |
Determines if the system is big-endian.
This utility function checks the system's endianness by examining the byte order of a test value.
Example:
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const Bounds & | bounds ) |
os | Output stream. |
bounds | Bounds to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const CardCatalog & | catalog ) |
os | Output stream. |
catalog | CardCatalog to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const CardCatalogEntry & | entry ) |
os | Output stream. |
entry | CardCatalogEntry to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const CardHeader & | header ) |
os | Output stream. |
header | CardHeader to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const DataCard & | card ) |
os | Output stream. |
card | DataCard to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const Header & | header ) |
os | Output stream. |
header | Header to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const OPAT & | opat ) |
os | Output stream. |
opat | OPAT structure to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const OPATTable & | table ) |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const Slice & | slice ) |
os | Output stream. |
slice | Slice to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const TableIndex & | index ) |
os | Output stream. |
index | TableIndex to print. |
std::ostream & opat::operator<< | ( | std::ostream & | os, |
const TableIndexEntry & | entry ) |
os | Output stream. |
entry | TableIndexEntry to print. |
CardCatalog opat::readCardCatalog | ( | std::ifstream & | file, |
const Header & | header ) |
Reads the CardCatalog from the file.
This function reads all entries in the card catalog, using the header information to determine the number of entries and their locations.
file | Input file stream. |
header | The header of the OPAT file. |
std::runtime_error | if the card catalog cannot be read or is incomplete. |
Example:
CardCatalogEntry opat::readCardCatalogEntry | ( | std::ifstream & | file, |
uint64_t | offset, | ||
uint16_t | numIndex, | ||
uint8_t | hashPrecision ) |
Reads a CardCatalogEntry from the file.
This function reads a single entry from the card catalog, including its index, byte range, and SHA-256 hash. It also performs byte-swapping for compatibility with big-endian systems.
file | Input file stream. |
offset | Offset to the entry in the file. |
numIndex | Number of indices in the entry. |
hashPrecision | Precision of the hash used for validation. |
std::runtime_error | if the entry cannot be read or is incomplete. |
Example:
DataCard opat::readDataCard | ( | std::ifstream & | file, |
const CardCatalogEntry & | entry ) |
Reads a single DataCard from the file.
This function reads the header, table index, and table data for a single DataCard.
file | Input file stream. |
entry | The CardCatalogEntry for the DataCard. |
std::runtime_error | if the DataCard cannot be read or is incomplete. |
Example:
CardHeader opat::readDataCardHeader | ( | std::ifstream & | file, |
const CardCatalogEntry & | entry ) |
Reads the header of a DataCard from the file.
This function reads the header structure of a DataCard and performs byte-swapping for compatibility with big-endian systems.
file | Input file stream. |
entry | The CardCatalogEntry for the DataCard. |
std::runtime_error | if the DataCard header cannot be read or is incomplete. |
Example:
std::unordered_map< FloatIndexVector, DataCard > opat::readDataCards | ( | std::ifstream & | file, |
const Header & | header, | ||
const CardCatalog & | cardCatalog ) |
Reads all DataCards from the file.
This function reads all DataCards in the OPAT file, using the card catalog to locate each card and its associated data.
file | Input file stream. |
header | The header of the OPAT file. |
cardCatalog | The CardCatalog of the OPAT file. |
std::runtime_error | if any DataCard cannot be read or is incomplete. |
Example:
Header opat::readHeader | ( | std::ifstream & | file | ) |
Reads the header of an OPAT file.
This function reads the header structure from the file and performs byte-swapping if the system is big-endian.
file | Input file stream positioned at the start of the header. |
std::runtime_error | if the header cannot be read or is incomplete. |
Example:
OPAT opat::readOPAT | ( | const std::string & | filename | ) |
Reads an OPAT file and returns its contents as an OPAT structure.
This function validates the file's magic number, reads the header, card catalog, and all data cards, and constructs an OPAT object representing the file's contents.
filename | Path to the OPAT file. |
std::runtime_error | if the file cannot be opened, is invalid, or has an incorrect magic number. |
Example:
OPATTable opat::readOPATTable | ( | std::ifstream & | file, |
const CardCatalogEntry & | cardEntry, | ||
const TableIndexEntry & | tableEntry ) |
Reads an OPATTable from the file.
This function reads the row values, column values, and data for a single table within a DataCard.
file | Input file stream. |
cardEntry | The CardCatalogEntry for the DataCard. |
tableEntry | The TableIndexEntry for the table. |
std::runtime_error | if the table cannot be read or is incomplete. |
Example:
TableIndex opat::readTableIndex | ( | std::ifstream & | file, |
const CardCatalogEntry & | entry, | ||
const CardHeader & | header ) |
Reads the TableIndex from a DataCard.
This function reads the table index of a DataCard, which maps table tags to their metadata and locations within the card.
file | Input file stream. |
entry | The CardCatalogEntry for the DataCard. |
header | The CardHeader of the DataCard. |
std::runtime_error | if the TableIndex cannot be read or is incomplete. |
Example:
T opat::swap_bytes | ( | T | value | ) |
Swaps the byte order of a value.
This function is useful for handling endianness when reading binary files. It ensures compatibility across systems with different byte orders.
T | The type of the value (must be trivially copyable). |
value | The value to swap. |
Example: