Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf7987e

Browse files
Add all kinds of integer stamps (8, 16, 32 and 64 bit, binary && string, signed and unsigned)
1 parentf7d4fdf commitdf7987e

File tree

6 files changed

+307
-31
lines changed

6 files changed

+307
-31
lines changed

‎blobstamper/blobstamper.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
#include"stamp.h"
44
#include"stamp_atomic.h"
55
#include"stamp_pg_type_geo.h"
6-
6+
#include"dict.h"
77

‎blobstamper/stamp.cpp‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,37 @@
22
#include<string>
33
#include<list>
44

5+
#include<string.h>
6+
57
#include"blob.h"
68
#include"stamp.h"
79

10+
811
/*************************************************************************************/
912

13+
void *
14+
StampGeneric::Extract(Blob &blob)
15+
{
16+
if (!is_fixed_size)
17+
{
18+
fprintf(stderr,"Something is really wrong. Default extract method does not support dynamic stamp size\n");
19+
returnNULL;
20+
}
21+
Blob blob2 = blob.ShiftBytes(min_size);
22+
23+
if (blob2.isEmpty())/* original blob does not have enought data*/
24+
returnNULL;
25+
void *res =malloc(min_size);
26+
if(! res)
27+
{
28+
fprintf(stderr,"Out of memory\n");
29+
returnNULL;
30+
}
31+
memcpy(res, blob2.data + blob2.begin, min_size);
32+
return res;
33+
}
34+
35+
1036
std::list<std::string>StampList::ExtractStrList(Blob &blob)
1137
{
1238
std::list<std::string> res;

‎blobstamper/stamp.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class StampGeneric
1616
intminSize() {return min_size;}
1717
intmaxSize() {return max_size;}
1818

19-
virtualvoid *Extract(Blob &blob) {printf ("1111111\n");returnNULL;}
19+
virtualvoid *Extract(Blob &blob);
2020
virtual std::stringExtractStr(Blob &blob) {printf ("22222\n");return"";}
2121

2222
};

‎blobstamper/stamp_atomic.cpp‎

Lines changed: 118 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,135 @@
1-
2-
#include<string.h>
3-
41
#include"blob.h"
52
#include"stamp.h"
63
#include"stamp_atomic.h"
74

8-
StampBinDouble::StampBinDouble() : StampGeneric()
5+
6+
StampBinChar::StampBinChar() : StampGeneric()
97
{
10-
min_size =sizeof(double);
11-
max_size =sizeof(double);
8+
min_size =sizeof(char);
9+
max_size =sizeof(char);
1210
is_fixed_size =true;
1311
}
1412

15-
void *
16-
StampBinDouble::Extract(Blob &blob)
13+
14+
std::string
15+
StampStrUInt8::ExtractStr(Blob &blob)
1716
{
18-
Blob blob2 = blob.ShiftBytes(min_size);
19-
if (blob2.isEmpty())
20-
returnNULL;
21-
void *res =malloc(min_size);
22-
memcpy(res, blob2.data + blob2.begin, min_size);
17+
std::string res;
18+
char *pc = (char *)this->Extract(blob);
19+
if (! pc)
20+
return"";
21+
res =std::to_string((int) *pc);
22+
free(pc);
23+
return res;
24+
}
25+
/* ----*/
26+
27+
StampBinInt16::StampBinInt16() : StampGeneric()
28+
{
29+
min_size =sizeof(shortint);
30+
max_size =sizeof(shortint);
31+
is_fixed_size =true;
32+
}
33+
34+
std::string
35+
StampStrUInt16::ExtractStr(Blob &blob)
36+
{
37+
std::string res;
38+
unsignedshortint *pi = (unsignedshortint *)this->Extract(blob);
39+
if (! pi)
40+
return"";
41+
res =std::to_string(*pi);
42+
free(pi);
43+
return res;
44+
}
45+
46+
std::string
47+
StampStrSInt16::ExtractStr(Blob &blob)
48+
{
49+
std::string res;
50+
signedshortint *pi = (signedshortint *)this->Extract(blob);
51+
if (! pi)
52+
return"";
53+
res =std::to_string(*pi);
54+
free(pi);
2355
return res;
2456
}
2557

2658
/* ----*/
2759

60+
StampBinInt32::StampBinInt32() : StampGeneric()
61+
{
62+
min_size =sizeof(int);
63+
max_size =sizeof(int);
64+
is_fixed_size =true;
65+
}
66+
67+
std::string
68+
StampStrUInt32::ExtractStr(Blob &blob)
69+
{
70+
std::string res;
71+
unsignedint *pi = (unsignedint *)this->Extract(blob);
72+
if (! pi)
73+
return"";
74+
res =std::to_string(*pi);
75+
free(pi);
76+
return res;
77+
}
78+
79+
std::string
80+
StampStrSInt32::ExtractStr(Blob &blob)
81+
{
82+
std::string res;
83+
signedint *pi = (signedint *)this->Extract(blob);
84+
if (! pi)
85+
return"";
86+
res =std::to_string(*pi);
87+
free(pi);
88+
return res;
89+
}
90+
91+
/* ----*/
92+
93+
StampBinInt64::StampBinInt64() : StampGeneric()
94+
{
95+
min_size =sizeof(longlong);
96+
max_size =sizeof(longlong);
97+
is_fixed_size =true;
98+
}
99+
100+
std::string
101+
StampStrUInt64::ExtractStr(Blob &blob)
102+
{
103+
std::string res;
104+
unsignedlonglong *pi = (unsignedlonglong *)this->Extract(blob);
105+
if (! pi)
106+
return"";
107+
res =std::to_string(*pi);
108+
free(pi);
109+
return res;
110+
}
111+
112+
std::string
113+
StampStrSInt64::ExtractStr(Blob &blob)
114+
{
115+
std::string res;
116+
signedlonglong *pi = (signedlonglong *)this->Extract(blob);
117+
if (! pi)
118+
return"";
119+
res =std::to_string(*pi);
120+
free(pi);
121+
return res;
122+
}
123+
124+
/* ----*/
125+
126+
StampBinDouble::StampBinDouble() : StampGeneric()
127+
{
128+
min_size =sizeof(double);
129+
max_size =sizeof(double);
130+
is_fixed_size =true;
131+
}
132+
28133
std::string
29134
StampStrDouble::ExtractStr(Blob &blob)
30135
{

‎blobstamper/stamp_atomic.h‎

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,93 @@
33

44
#include<string>
55

6+
7+
classStampBinChar:publicStampGeneric
8+
{
9+
public:
10+
StampBinChar();
11+
};
12+
13+
classStampStrUInt8:publicStampBinChar
14+
{
15+
public:
16+
std::stringExtractStr(Blob &blob)override;
17+
};
18+
19+
/* ---*/
20+
21+
classStampBinInt16:publicStampGeneric
22+
{
23+
public:
24+
StampBinInt16();
25+
};
26+
27+
classStampStrUInt16:publicStampBinInt16
28+
{
29+
public:
30+
std::stringExtractStr(Blob &blob)override;
31+
};
32+
33+
classStampStrSInt16:publicStampBinInt16
34+
{
35+
public:
36+
std::stringExtractStr(Blob &blob)override;
37+
};
38+
39+
40+
/* ---*/
41+
42+
classStampBinInt32:publicStampGeneric
43+
{
44+
public:
45+
StampBinInt32();
46+
};
47+
48+
classStampStrUInt32:publicStampBinInt32
49+
{
50+
public:
51+
std::stringExtractStr(Blob &blob)override;
52+
};
53+
54+
classStampStrSInt32:publicStampBinInt32
55+
{
56+
public:
57+
std::stringExtractStr(Blob &blob)override;
58+
};
59+
60+
/* ---*/
61+
62+
classStampBinInt64:publicStampGeneric
63+
{
64+
public:
65+
StampBinInt64();
66+
};
67+
68+
classStampStrUInt64:publicStampBinInt64
69+
{
70+
public:
71+
std::stringExtractStr(Blob &blob)override;
72+
};
73+
74+
classStampStrSInt64:publicStampBinInt64
75+
{
76+
public:
77+
std::stringExtractStr(Blob &blob)override;
78+
};
79+
80+
/* ---*/
81+
82+
683
classStampBinDouble:publicStampGeneric
784
{
885
public:
986
StampBinDouble();
10-
void *Extract(Blob &blob)override;
1187
};
1288

1389

1490
classStampStrDouble:publicStampBinDouble
1591
{
1692
public:
17-
StampStrDouble() : StampBinDouble() {}
1893
std::stringExtractStr(Blob &blob)override;
1994
};
2095

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp