Schema & Dictionary¶
Type Enum¶
Data type identifiers used throughout the library.
enum Type {
kByte = 1, // int8_t, 1 byte, schema char: B
kShort = 2, // int16_t, 2 bytes, schema char: S
kInt = 3, // int32_t, 4 bytes, schema char: I
kFloat = 4, // float, 4 bytes, schema char: F
kDouble = 5, // double, 8 bytes, schema char: D
kLong = 8, // int64_t, 8 bytes, schema char: L
};
schemaEntry_t¶
Metadata for a single column in a bank.
| Field | Type | Description |
|---|---|---|
name |
std::string |
Column name (e.g., "px") |
type |
std::string |
Type character (e.g., "F") |
typeId |
int |
Numeric type ID (from Type enum) |
typeSize |
int |
Size in bytes |
offset |
int |
Byte offset within a row |
hipo::schema¶
Defines the column layout of a bank.
Construction¶
Parsing¶
Format string: "col1/T,col2/T,..." where T is the type character (B, S, I, F, D, L).
Metadata¶
std::string getName(); // schema name
int getGroup(); // group ID
int getItem(); // item ID
int getEntries(); // number of columns
int getRowLength(); // bytes per row
std::string getEntryName(int idx); // column name by index
int getEntryType(int idx); // column type by index
int getEntryType(const char *name); // column type by name
Column Lookup¶
Returns the column index for a given name, or -1 if not found.
Returns true if the column name exists.
Offset Computation¶
Display¶
hipo::dictionary¶
Collection of schemas, typically loaded from a file header.
Adding Schemas¶
Querying¶
Warning
getSchema() throws hipo::schema_error if the schema does not exist. Check with hasSchema() first if unsure.
Listing¶
Parsing¶
Parses the dictionary text format used in HIPO file headers:
Display¶
Example¶
// Create and configure a schema
hipo::schema s("REC::Particle", 300, 1);
s.parse("pid/I,px/F,py/F,pz/F,vx/D,vy/D,vz/D,charge/B,status/L");
// Query schema properties
printf("Name: %s\n", s.getName().c_str());
printf("Columns: %d\n", s.getEntries());
printf("Row length: %d bytes\n", s.getRowLength());
// Column lookup
int pidCol = s.getEntryOrder("pid"); // 0
int pxCol = s.getEntryOrder("px"); // 1
// Check existence
if (s.exists("missing_column")) { /* ... */ }
// Add to dictionary
hipo::dictionary dict;
dict.addSchema(s);
// Retrieve from dictionary
auto& schema = dict.getSchema("REC::Particle");