18 std::vector<std::string> entries;
19 std::vector<std::string> entry;
22 for(
int i = 0; i < entries.size(); i++){
32 schemaEntries.push_back(e);
33 schemaEntriesMap[e.
name] = i;
37 int schema::getTypeByString(std::string &typeName){
40 }
else if(typeName==
"S") {
42 }
else if(typeName==
"I") {
44 }
else if(typeName==
"F") {
46 }
else if(typeName==
"D") {
48 }
else if(typeName==
"L") {
54 int schema::getTypeSize(
int id){
68 printf(
"schema : %14s , group = %6d, item = %3d\n",
69 schemaName.c_str(),groupid,itemid);
70 for(
auto & schemaEntrie : schemaEntries){
71 printf(
"%16s : (%3s) %5d %5d , offset = %3d --> [%s]\n",
72 schemaEntrie.name.c_str(),schemaEntrie.type.c_str(),
73 schemaEntrie.typeId,schemaEntrie.typeSize, schemaEntrie.offset,
74 schemaEntrie.name.c_str()
81 int nentries = schemaEntries.size();
82 int offset =
getOffset(nentries-1,rows-1,rows) + schemaEntries[nentries-1].typeSize;
89 snprintf(parts,256,
"{%s/%d/%d}{",schemaName.c_str(),groupid,itemid);
91 for(
int loop = 0; loop < schemaEntries.size(); loop++){
92 snprintf(parts,256,
"%s/%s",schemaEntries[loop].name.c_str(), schemaEntries[loop].type.c_str());
93 if(loop!=0) result.append(
",");
103 snprintf(parts,256,
"{ \"name\": \"%s\", \"group\": %d, \"item\": %d, \"info\": \" \",",
104 schemaName.c_str(),groupid,itemid);
105 result.append(parts);
106 result.append(
"\"entries\": [ ");
107 for(
int loop = 0; loop < schemaEntries.size(); loop++){
108 snprintf(parts,256,
"{\"name\":\"%s\", \"type\":\"%s\", \"info\":\" \"}",
109 schemaEntries[loop].name.c_str(), schemaEntries[loop].type.c_str());
110 if(loop!=0) result.append(
",");
111 result.append(parts);
113 result.append(
"] }");
122 std::map<std::string, schema>::iterator it;
123 std::vector<std::string> vec;
124 for ( it = factory.begin(); it != factory.end(); it++ ){
125 vec.push_back(it->first);
131 std::vector<std::string> tokens;
134 int group = std::atoi(tokens[1].c_str());
135 int item = std::atoi(tokens[2].c_str());
145 for(
auto & i : list){
147 printf(
"%24s : %5d %5d %5d\n", sc.
getName().c_str(),
bool parse(const char *schemaString)
Parse a full schema string and add it to the dictionary.
void addSchema(schema sc)
Add a schema to the dictionary.
std::vector< std::string > getSchemaList()
Get a list of all schema names in the dictionary.
void show()
Print all schemas in the dictionary to standard output.
schema & getSchema(const char *name)
Retrieve a schema by name.
Schema definition for a HIPO bank.
void parse(const std::string &schString)
Parse a schema definition string and populate entries.
std::string getName() const
Get the schema name.
std::string getSchemaString()
Serialize the schema to a definition string (e.g. "pid/I,px/F").
int getSizeForRows(int rows)
Compute the total buffer size needed for a given number of rows.
int getOffset(int item, int order, int rows) const
Compute the byte offset for a column value by column index.
void show()
Print the schema to standard output.
int getItem()
Get the item identifier.
int getEntries() const noexcept
Get the number of columns in the schema.
int getGroup()
Get the group identifier.
std::string getSchemaStringJson()
Serialize the schema to a JSON-formatted string.
static std::string substring(const std::string &str, const char *start_delim, const char *end_delim, int order)
Extracts a substring between two delimiters.
static void tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Splits a string into tokens using the given delimiters.
static std::string & trim(std::string &str, const std::string &chars="\t\n\v\f\r ")
Trims both leading and trailing whitespace from a string.
Schema definitions and schema dictionary for HIPO banks.
@ kLong
64-bit signed integer.
@ kInt
32-bit signed integer.
@ kFloat
32-bit IEEE 754 floating point.
@ kShort
16-bit signed integer.
@ kByte
8-bit signed integer.
@ kDouble
64-bit IEEE 754 floating point.
Describes a single column (entry) within a schema.
int typeId
Numeric type identifier (see Type).
int offset
Byte offset of this column within a row.
std::string type
Type string (e.g. "B", "S", "I", "F", "D", "L").
std::string name
Column name.
int typeSize
Size of the type in bytes.
Utility functions and benchmark timer for HIPO library operations.