Skip to content

Commit 0e32185

Browse files
Move arithmetics types stamps to a single template. Will call this template StampArythm for now
1 parent 6f12166 commit 0e32185

15 files changed

+61
-263
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ endif
99
BLOB_STAMPER_OBJ = blobstamper/blob.o \
1010
blobstamper/helpers.o \
1111
blobstamper/stamp.o \
12-
blobstamper/stamp_atomic.o \
12+
blobstamper/stamp_arithm.o \
1313
blobstamper/stamp_dict.o \
1414
blobstamper/galley.o \
1515
blobstamper/dict.o \

blobstamper/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ALL_OBJS = blob.o \
33
helpers.o \
44
stamp.o \
5-
stamp_atomic.o \
5+
stamp_arithm.o \
66
stamp_dict.o \
77
galley.o \
88
dict.o \

blobstamper/blobstamper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#include "blob.h"
33
#include "stamp.h"
4-
#include "stamp_atomic.h"
4+
#include "stamp_arithm.h"
55
#include "stamp_dict.h"
66
#include "dict.h"
77
#include "galley.h"

blobstamper/galley.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "blob.h"
77
#include "stamp.h"
8-
#include "stamp_atomic.h"
8+
#include "stamp_arithm.h"
99
#include "galley.h"
1010

1111

blobstamper/galley.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
#include <vector>
88
#include <functional> // for std::reference_wrapper
99

10-
11-
#define ORACLE_STAMP StampBinInt16
1210
#define ORACLE_TYPE unsigned short int
11+
#define ORACLE_STAMP StampArithm<ORACLE_TYPE>
1312
#define ORACLE_SIZE sizeof(ORACLE_TYPE)
1413
#define ORACLE_MAX USHRT_MAX
1514

blobstamper/helpers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef HELPERS_H
2+
#define HELPERS_H
13

24
void hexdump(void *pAddressIn, long lSize);
35

@@ -74,3 +76,4 @@ max precision
7476
"%.999g", __val);
7577
}
7678

79+
#endif /*HELPERS_H*/

blobstamper/stamp_arithm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "blob.h"
2+
#include "stamp.h"
3+
#include "stamp_arithm.h"
4+

blobstamper/stamp_arithm.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef STAMP_ATOMIC_H
2+
#define STAMP_ATOMIC_H
3+
4+
#include <string>
5+
#include "helpers.h"
6+
7+
template<class T> class StampArithm: public StampFixed
8+
{
9+
public:
10+
StampArithm() { size = sizeof(T);};
11+
std::string ExtractStr(Blob &blob) override;
12+
};
13+
14+
template<class T> std::string
15+
StampArithm<T>::ExtractStr(Blob &blob)
16+
{
17+
std::string res;
18+
T *pT = (T *)this->ExtractBin(blob);
19+
if (! pT)
20+
return "";
21+
res = to_string_precise(*pT);
22+
free(pT);
23+
return res;
24+
}
25+
26+
#endif /* STAMP_ATOMIC_H */

blobstamper/stamp_atomic.cpp

Lines changed: 0 additions & 137 deletions
This file was deleted.

blobstamper/stamp_atomic.h

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)