1 |
pamela |
1.1 |
#ifndef PBLOCKDESC_H |
2 |
|
|
#define PBLOCKDESC_H |
3 |
|
|
|
4 |
|
|
#include <string> |
5 |
|
|
#include <vector> |
6 |
|
|
|
7 |
|
|
using std::string; |
8 |
|
|
using std::vector; |
9 |
|
|
using std::cout; |
10 |
|
|
using std::endl; |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
// The Block Descriptor. A simple map to store block name, |
14 |
|
|
// total number of bytes and number of variables in the block |
15 |
|
|
|
16 |
|
|
struct pBlockDesc { |
17 |
|
|
pBlockDesc(const string s="", const int &nb=0, const int & nv=0, |
18 |
|
|
const int & nm=0): |
19 |
|
|
name(s), nbyte(nb), nvar(nv), nmult(nm) {}; |
20 |
|
|
string name; |
21 |
|
|
int nbyte; |
22 |
|
|
int nvar; |
23 |
|
|
int nmult; |
24 |
|
|
}; |
25 |
|
|
|
26 |
|
|
typedef vector<pBlockDesc> pBlockMap; |
27 |
|
|
|
28 |
|
|
// Implements a service to return char arrays and poointer to be used to |
29 |
|
|
// store block as read from the hbook file |
30 |
|
|
class pBlockPointer { |
31 |
|
|
|
32 |
|
|
public: |
33 |
|
|
pBlockPointer():_pbuf(0) {}; |
34 |
|
|
|
35 |
|
|
char* BuffAddress(){ return _pbuf;} |
36 |
|
|
char* BuffAddressR(){ return _pbr;} |
37 |
|
|
char* BlockAddress(const std::string& s); |
38 |
|
|
char* BlockAddressR(const std::string& s); |
39 |
|
|
// char* BlockAddress(char *s); |
40 |
|
|
char* CreatePbuf(); |
41 |
|
|
// Returns the number of blocks founds |
42 |
|
|
int Blocks(){return _pblockmap.size();} |
43 |
|
|
int TotBufSize(); |
44 |
|
|
int& CountByte(const std::string& s); |
45 |
|
|
int& CountVar(const std::string& s); |
46 |
|
|
int BlockInd(const std::string& s); |
47 |
|
|
int BlockByte(const std::string& s){ |
48 |
|
|
return (*GetBlockDesc(s)).nbyte;}; |
49 |
|
|
int BlockVar(const std::string& s){ |
50 |
|
|
return (*GetBlockDesc(s)).nvar;} |
51 |
|
|
int BlockMult(const std::string& s){ |
52 |
|
|
return (*GetBlockDesc(s)).nmult;} |
53 |
|
|
int& SetMult(const std::string& s); |
54 |
|
|
|
55 |
|
|
char * BuffReorder(); |
56 |
|
|
pBlockDesc* GetBlockDesc(const std::string& s); |
57 |
|
|
pBlockMap* GetBlockMap(){return &_pblockmap;} |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
void Print(); |
61 |
|
|
|
62 |
|
|
private: |
63 |
|
|
char *_pbuf; |
64 |
|
|
char *_pbr; |
65 |
|
|
pBlockMap _pblockmap; |
66 |
|
|
}; |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
#endif //PBLOCKDESC_H |