58 std::vector<char> structureBuffer;
59 char *structureAddress{};
60 void setAddress(
const char *address);
75 structure(
int __group,
int __item, std::string &str);
81 int length = *
reinterpret_cast<uint32_t *
>(structureAddress+4);
87 int length = *
reinterpret_cast<uint32_t *
>(structureAddress+4);
98 void init(
const char *buffer,
int size);
102 virtual void show()
const;
108 return *
reinterpret_cast<int32_t*
>(&structureAddress[index+
dataOffset]);
112 return *
reinterpret_cast<int16_t*
>(&structureAddress[index+
dataOffset]);
115 return *
reinterpret_cast<int8_t*
>(&structureAddress[index+
dataOffset]);
118 return *
reinterpret_cast<float*
>(&structureAddress[index+
dataOffset]);
121 return *
reinterpret_cast<double*
>(&structureAddress[index+
dataOffset]);
124 return *
reinterpret_cast<int64_t*
>(&structureAddress[index+
dataOffset]);
130 *
reinterpret_cast<int32_t*
>(&structureAddress[index+
dataOffset]) = value;
134 *
reinterpret_cast<int16_t*
>(&structureAddress[index+
dataOffset]) = value;
138 *
reinterpret_cast<int8_t*
>(&structureAddress[index+
dataOffset]) = value;
142 *
reinterpret_cast<float*
>(&structureAddress[index+
dataOffset]) = value;
146 *
reinterpret_cast<double*
>(&structureAddress[index+
dataOffset]) = value;
150 *
reinterpret_cast<int64_t*
>(&structureAddress[index+
dataOffset]) = value;
167 std::vector<char> typeChars;
168 std::vector<int> offsets;
169 std::vector<int> types;
173 int getTypeSize(
int type);
183 void parse(std::string format);
198 int getInt (
int element,
int row)
const noexcept;
199 int64_t
getLong (
int element,
int row)
const noexcept;
200 float getFloat (
int element,
int row)
const noexcept;
201 void putInt (
int element,
int row,
int value);
202 void putLong (
int element,
int row, int64_t value);
203 void putFloat (
int element,
int row,
float value);
225 void reset(
int numRows = -1);
245 void filter(std::function<
bool(
bank&,
int)> func);
248 void filter(
char const* expression);
263 bank* m_owner_bank{
nullptr};
265 bool ownerBankIsUnknown(std::string_view caller =
"");
282 bankSchema = __schema;
287 bankSchema = __schema;
289 int size = bankSchema.getSizeForRows(__rows);
291 bankRowList.reset(bankRows);
298 int getRows() const noexcept{
return bankRows;}
300 int getInt(
int item,
int index)
const noexcept;
301 int getShort(
int item,
int index)
const noexcept;
302 int getByte(
int item,
int index)
const noexcept;
303 float getFloat(
int item,
int index)
const noexcept;
304 double getDouble(
int item,
int index)
const noexcept;
305 long getLong(
int item,
int index)
const noexcept;
307 std::vector<int>
getInt(
int item)
const noexcept;
308 std::vector<float>
getFloat(
int item)
const noexcept;
309 std::vector<double>
getDouble(
int item)
const noexcept;
311 template<
typename T =
double> T
get(
int item,
int index)
const noexcept {
312 auto type = bankSchema.getEntryType(item);
313 auto offset = bankSchema.getOffset(item, index, bankRows);
322 printf(
"---> error(get) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
327 int getInt(
const char *name,
int index)
const noexcept;
329 int getShort(
const char *name,
int index)
const noexcept;
330 int getByte(
const char *name,
int index)
const noexcept;
331 float getFloat(
const char *name,
int index)
const noexcept;
332 double getDouble(
const char *name,
int index)
const noexcept;
333 long getLong(
const char *name,
int index)
const noexcept;
335 std::vector<int>
getInt(
const char *name)
const noexcept;
336 std::vector<float>
getFloat(
const char *name)
const noexcept;
337 std::vector<double>
getDouble(
const char *name)
const noexcept;
339 template<
typename T =
double> T
get(
const char *name,
int index)
const noexcept {
340 return get<T>(bankSchema.getEntryOrder(name), index);
349 template<
typename T>
void put(
const char *name,
int index,
T value) {
350 put(bankSchema.getEntryOrder(name), index,
value);
359 template<
typename T>
void put(
int item,
int index,
T value) {
360 auto type = bankSchema.getEntryType(item);
369 printf(
"---> error(put) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
391 void show()
const override;
417 if(bankSchema.getEntryType(item)==
kFloat){
418 int offset = bankSchema.getOffset(item, index, bankRows);
419 return getFloatAt(offset);
425 if(bankSchema.getEntryType(item)==
kDouble){
426 int offset = bankSchema.getOffset(item, index, bankRows);
427 return getDoubleAt(offset);
429 if(bankSchema.getEntryType(item)==
kFloat){
430 int offset = bankSchema.getOffset(item, index, bankRows);
431 return getFloatAt(offset);
437 if(bankSchema.getEntryType(item)==
kLong){
438 int offset = bankSchema.getOffset(item, index, bankRows);
439 return getLongAt(offset);
445 int type = bankSchema.getEntryType(item);
446 int offset = bankSchema.getOffset(item, index, bankRows);
448 case kByte:
return (
int) getByteAt(offset);
449 case kShort:
return (
int) getShortAt(offset);
450 case kInt:
return getIntAt(offset);
451 default: printf(
"---> error : requested INT for [%s] type = %d\n",
452 bankSchema.getEntryName(item).c_str(),type);
break;
458 int type = bankSchema.getEntryType(item);
460 std::vector<int> row;
461 int nrows = getRows();
463 for(
int j = 0; j < nrows; j++){
464 int offset = bankSchema.getOffset(item, j, bankRows);
466 case kByte: row.push_back((
int) getByteAt(offset));
break;
467 case kShort: row.push_back((
int) getShortAt(offset));
break;
468 case kInt: row.push_back((
int) getIntAt(offset));
break;
469 default: printf(
"---> error : requested INT for [%s] type = %d\n",
470 bankSchema.getEntryName(item).c_str(),type);
break;
477 int type = bankSchema.getEntryType(item);
478 int offset = bankSchema.getOffset(item, index, bankRows);
480 case kByte:
return (
int) getByteAt(offset);
481 case kShort:
return (
int) getShortAt(offset);
482 default: printf(
"---> error : requested SHORT for [%s] type = %d\n",
483 bankSchema.getEntryName(item).c_str(),type);
break;
489 int type = bankSchema.getEntryType(item);
490 int offset = bankSchema.getOffset(item, index, bankRows);
492 case kByte:
return (
int) getByteAt(offset);
493 default: printf(
"---> error : requested BYTE for [%s] type = %d\n",
494 bankSchema.getEntryName(item).c_str(),type);
break;
499 int item = bankSchema.getEntryOrder(name);
500 int type = bankSchema.getEntryType(item);
501 int offset = bankSchema.getOffset(item, index, bankRows);
503 case kByte:
return (
int) getByteAt(offset);
504 case kShort:
return (
int) getShortAt(offset);
505 case kInt:
return getIntAt(offset);
506 default: printf(
"---> error : requested INT for [%s] type = %d\n",name,type);
break;
512 int item = bankSchema.getEntryOrder(name);
513 int type = bankSchema.getEntryType(item);
514 std::vector<int> row;
516 int nrows = getRows();
517 for(
int j = 0; j < nrows; j++){
518 int offset = bankSchema.getOffset(item, j, bankRows);
520 case kByte: row.push_back((
int) getByteAt(offset));
break;
521 case kShort: row.push_back((
int) getShortAt(offset));
break;
522 case kInt: row.push_back((
int) getIntAt(offset));
break;
523 default: printf(
"---> error : requested INT for [%s] type = %d\n",name,type);
break;
530 int item = bankSchema.getEntryOrder(name);
531 int type = bankSchema.getEntryType(item);
532 int offset = bankSchema.getOffset(item, index, bankRows);
534 case kByte:
return (
int) getByteAt(offset);
535 case kShort:
return (
int) getShortAt(offset);
536 default: printf(
"---> error : requested SHORT for [%s] type = %d\n",
537 bankSchema.getEntryName(item).c_str(),type);
break;
542 int item = bankSchema.getEntryOrder(name);
543 int type = bankSchema.getEntryType(item);
544 int offset = bankSchema.getOffset(item, index, bankRows);
546 case kByte:
return (
int) getByteAt(offset);
547 default: printf(
"---> error : requested BYTE for [%s] type = %d\n",
548 bankSchema.getEntryName(item).c_str(),type);
break;
554 int item = bankSchema.getEntryOrder(name);
555 if(bankSchema.getEntryType(item)==
kFloat){
556 int offset = bankSchema.getOffset(item, index, bankRows);
557 return getFloatAt(offset);
563 int item = bankSchema.getEntryOrder(name);
564 std::vector<float> row;
565 int nrows = getRows();
566 if(bankSchema.getEntryType(item)==
kFloat){
567 for(
int j = 0; j < nrows; j++){
568 int offset = bankSchema.getOffset(item, j, bankRows);
569 row.push_back( getFloatAt(offset));
576 std::vector<float> row;
577 int nrows = getRows();
578 if(bankSchema.getEntryType(item)==
kFloat){
579 for(
int j = 0; j < nrows; j++){
580 int offset = bankSchema.getOffset(item, j, bankRows);
581 row.push_back( getFloatAt(offset));
587 int item = bankSchema.getEntryOrder(name);
588 if(bankSchema.getEntryType(item)==
kDouble){
589 int offset = bankSchema.getOffset(item, index, bankRows);
590 return getDoubleAt(offset);
592 if(bankSchema.getEntryType(item)==
kFloat){
593 int offset = bankSchema.getOffset(item, index, bankRows);
594 return (
double) getFloatAt(offset);
600 std::vector<double> row;
601 int nrows = getRows();
603 if(bankSchema.getEntryType(item)==
kDouble){
604 for(
int j = 0; j < nrows; j++){
605 int offset = bankSchema.getOffset(item, j, bankRows);
606 row.push_back(getDoubleAt(offset));
609 if(bankSchema.getEntryType(item)==
kFloat){
610 for(
int j = 0; j < nrows; j++){
611 int offset = bankSchema.getOffset(item, j, bankRows);
612 row.push_back((
double) getFloatAt(offset));
619 std::vector<double> row;
620 int nrows = getRows();
621 int item = bankSchema.getEntryOrder(name);
623 if(bankSchema.getEntryType(item)==
kDouble){
624 for(
int j = 0; j < nrows; j++){
625 int offset = bankSchema.getOffset(item, j, bankRows);
626 row.push_back(getDoubleAt(offset));
629 if(bankSchema.getEntryType(item)==
kFloat){
630 for(
int j = 0; j < nrows; j++){
631 int offset = bankSchema.getOffset(item, j, bankRows);
632 row.push_back((
double) getFloatAt(offset));
639 int item = bankSchema.getEntryOrder(name);
640 if(bankSchema.getEntryType(item)==
kLong){
641 int offset = bankSchema.getOffset(item, index, bankRows);
642 return getLongAt(offset);
648 int offset = bankSchema.
getOffset(item, index, bankRows);
653 int offset = bankSchema.
getOffset(item, index, bankRows);
658 int offset = bankSchema.
getOffset(item, index, bankRows);
663 int offset = bankSchema.
getOffset(item, index, bankRows);
669 int offset = bankSchema.
getOffset(item, index, bankRows);
674 int offset = bankSchema.
getOffset(item, index, bankRows);
rowlist encapsulates a list of rows for this bank, providing a way to iterate over them
Definition bank.h:215
list_t const & getList() const
Definition bank.cpp:355
void setOwnerBank(bank *const ownerBank)
Definition bank.h:258
void filter(std::function< bool(bank &, int)> func)
filter the list according to a function
Definition bank.cpp:366
void setList(list_t const &list)
Definition bank.cpp:361
bool isInitialized() const
Definition bank.h:226
std::vector< int > list_t
Definition bank.h:218
static list_t createFullList(int num)
Definition bank.cpp:398
void setRows(int rows)
Definition bank.cpp:429
void putByte(const char *name, int index, int8_t value)
Definition bank.cpp:462
void reset()
Definition bank.cpp:437
void put(const char *name, int index, T value)
Definition bank.h:349
rowlist::list_t const & getRowList() const
Definition bank.cpp:484
void putFloat(const char *name, int index, float value)
Definition bank.cpp:467
bank(const schema &__schema, int __rows)
Definition bank.h:286
T get(int item, int index) const noexcept
Definition bank.h:311
rowlist & getMutableRowList()
Definition bank.cpp:492
int getInt(int item, int index) const noexcept
Definition bank.h:444
void putShort(const char *name, int index, int16_t value)
Definition bank.cpp:457
void notify() override
Definition bank.cpp:443
void putLong(const char *name, int index, int64_t value)
Definition bank.cpp:478
long getLong(int item, int index) const noexcept
Definition bank.h:436
void printValue(int schemaEntry, int row) const
print a stored value
Definition bank.cpp:530
int getRows() const noexcept
Definition bank.h:298
void put(int item, int index, T value)
Definition bank.h:359
std::size_t checksum(bool checkAllRows=false) const
calculate a checksum for this bank; useful for comparing two banks' equality
Definition bank.cpp:549
schema & getSchema()
Definition bank.h:296
void putDouble(const char *name, int index, double value)
Definition bank.cpp:472
T get(const char *name, int index) const noexcept
Definition bank.h:339
int getShort(int item, int index) const noexcept
Definition bank.h:476
void show() const override
show this bank's contents; only the rows in its current rowlist instance are shown
Definition bank.cpp:506
bank(const schema &__schema)
Definition bank.h:281
float getFloat(int item, int index) const noexcept
Definition bank.h:416
int getByte(int item, int index) const noexcept
Definition bank.h:488
rowlist::list_t const getFullRowList() const
Definition bank.cpp:488
void putInt(const char *name, int index, int32_t value)
Definition bank.cpp:452
double getDouble(int item, int index) const noexcept
Definition bank.h:424
rowlist::list_t const getRowListLinked(int const row, int const column) const
Definition bank.cpp:497
int getRows() const noexcept
Definition bank.h:190
int getInt(int element, int row) const noexcept
Definition bank.cpp:214
composite(const char *format)
Definition bank.h:180
virtual void notify()
Definition bank.cpp:282
int getEntries() const noexcept
Definition bank.h:192
composite(int group, int item, int size)
Definition bank.h:179
void print()
Definition bank.cpp:307
void putLong(int element, int row, int64_t value)
Definition bank.cpp:265
float getFloat(int element, int row) const noexcept
Definition bank.cpp:241
void putInt(int element, int row, int value)
Definition bank.cpp:251
int getEntryType(int index) const noexcept
Definition bank.h:193
void parse(std::string format)
Definition bank.cpp:160
void reset()
Definition bank.cpp:148
int getRowSize() const noexcept
Definition bank.h:196
int64_t getLong(int element, int row) const noexcept
Definition bank.cpp:231
void putFloat(int element, int row, float value)
Definition bank.cpp:273
virtual ~composite()
Definition bank.h:185
composite(int size)
Definition bank.h:178
composite()
Definition bank.h:177
void setRows(int rows)
Definition bank.cpp:164
int group()
Definition node.h:148
int item()
Definition node.h:149
int size() const noexcept
Definition node.h:92
int capacity() const noexcept
Definition node.h:98
int dataLength() const noexcept
Definition node.h:126
int type()
Definition node.h:150
bool allocate(int size)
Definition node.h:84
Schema definition for a HIPO bank.
Definition dictionary.h:56
int getOffset(int item, int order, int rows) const
Definition dictionary.h:109
float getFloatAt(int index) const noexcept
Definition bank.h:117
void initStructureBySize(int __group, int __item, int __type, int __size)
Definition bank.cpp:65
void putShortAt(int index, int16_t value)
Definition bank.h:133
int getItem() const
Definition bank.cpp:106
int getSize() const noexcept
Definition bank.h:80
void putIntAt(int index, int value)
Definition bank.h:129
int getDataSize() const noexcept
Definition bank.h:91
void putByteAt(int index, int8_t value)
Definition bank.h:137
std::vector< char > & getStructureBuffer()
Definition bank.h:65
bool allocate(int size)
Definition bank.cpp:58
int getGroup() const
Definition bank.cpp:101
virtual ~structure()=default
void putStringAt(int index, std::string &str)
Definition bank.cpp:135
structure()
Definition bank.h:73
int getStructureBufferSize()
Definition bank.h:66
void setSize(int size)
Definition bank.cpp:74
int16_t getShortAt(int index) const noexcept
Definition bank.h:111
virtual void show() const
Definition bank.cpp:120
int dataOffset
Definition bank.h:67
void putLongAt(int index, int64_t value)
Definition bank.h:149
long getLongAt(int index) const noexcept
Definition bank.h:123
int getType() const
Definition bank.cpp:96
void initNoCopy(const char *buffer, int size)
Definition bank.cpp:110
int8_t getByteAt(int index) const noexcept
Definition bank.h:114
int getIntAt(int index) const noexcept
Definition bank.h:107
structure(int size)
Definition bank.h:74
void setDataSize(int size)
Definition bank.cpp:80
void putDoubleAt(int index, double value)
Definition bank.h:145
virtual void notify()
Definition bank.h:155
void putFloatAt(int index, float value)
Definition bank.h:141
int getHeaderSize() const noexcept
Definition bank.h:86
void init(const char *buffer, int size)
Definition bank.cpp:114
double getDoubleAt(int index) const noexcept
Definition bank.h:120
std::string getStringAt(int index)
Definition bank.cpp:125
void setHeaderSize(int size)
Definition bank.cpp:89
const char * getAddress()
Definition bank.cpp:140
HIPO namespace is used for the classes that read/write files and records.
Definition bank.cpp:45
@ kLong
Definition dictionary.h:41
@ kInt
Definition dictionary.h:38
@ kFloat
Definition dictionary.h:39
@ kShort
Definition dictionary.h:37
@ kByte
Definition dictionary.h:36
@ kDouble
Definition dictionary.h:40
constexpr uint32_t STRUCT_FORMAT_BYTE
Definition constants.h:130
banklist::size_type getBanklistIndex(banklist &banks, std::string const &bankName) noexcept(false)
Definition bank.cpp:585
constexpr int STRUCT_FORMAT_SHIFT
Definition constants.h:129
std::vector< bank > banklist
Definition bank.h:678
constexpr uint32_t STRUCT_SIZE_MASK
Definition constants.h:127