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

Commite13d50f

Browse files
Some more examples. And now you can inherit galley asif it is a stamp. And make a stamp out of it
1 parentc52e036 commite13d50f

File tree

5 files changed

+236
-10
lines changed

5 files changed

+236
-10
lines changed

‎blobstamper/galley.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@
2929
#defineORACLE_SIZEsizeof(ORACLE_TYPE)
3030
#defineORACLE_MAX std::numeric_limits<ORACLE_TYPE>::max()
3131

32-
classGalleyBase
32+
classGalleyBase:publicvirtual StampBase
33+
/* Galley is a kind of stamp, somwhere deep inside.*/
34+
/* You can inherit it, and make a stamp out of it*/
3335
{
34-
public:
35-
virtualintminSize() = 0;
36-
virtualintmaxSize() = 0;
37-
boolisFixedSize() {returnminSize() ==maxSize();}
38-
boolisUnbounded() {returnmaxSize() == -1;}
39-
4036
};
4137

4238
classGalleyVectorBase :publicGalleyBase

‎examples/example06.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,4 @@ int main()
6868
{
6969
std::cout <<"(" << p[i].X <<"," << p[i].Y <<"," << p[i].Z <<")\n";
7070
}
71-
72-
7371
}

‎examples/example07.cpp

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
typedefstructPoint3D
10+
{
11+
shortint X;
12+
shortint Y;
13+
shortint Z;
14+
} Point3D;
15+
16+
classStampPoint3D:publicStampBaseStr,publicStampBaseV<Point3D>
17+
{
18+
protected:
19+
StampArithm<shortint> stampX, stampY, stampZ;
20+
public:
21+
virtualintminSize()override;
22+
virtualintmaxSize()override;
23+
virtual std::stringExtractStr(Blob &blob)override;
24+
virtual Point3DExtractValue(Blob &blob)override;
25+
};
26+
27+
intStampPoint3D::minSize()
28+
{
29+
return stampX.minSize() + stampY.minSize() + stampZ.minSize();
30+
}
31+
32+
intStampPoint3D::maxSize()
33+
{
34+
return stampX.maxSize() + stampY.maxSize() + stampZ.maxSize();
35+
}
36+
37+
std::stringStampPoint3D::ExtractStr(Blob &blob)
38+
{
39+
std::string X,Y,Z;
40+
X = stampX.ExtractStr(blob);
41+
Y = stampY.ExtractStr(blob);
42+
Z = stampZ.ExtractStr(blob);
43+
return"(" + X +"," + Y +"," + Z +")";
44+
}
45+
46+
Point3DStampPoint3D::ExtractValue(Blob &blob)
47+
{
48+
Point3D res;
49+
res.X = stampX.ExtractValue(blob);
50+
res.Y = stampY.ExtractValue(blob);
51+
res.Z = stampZ.ExtractValue(blob);
52+
return res;
53+
}
54+
55+
56+
classStampPolyLine3D:publicGalleyVectorStr,publicStampBaseStr
57+
{
58+
protected:
59+
StampPoint3D * item_stamp_p;
60+
public:
61+
StampPolyLine3D(): GalleyVectorStr(*(item_stamp_p =new StampPoint3D())) {};
62+
~StampPolyLine3D() {delete item_stamp_p;};
63+
64+
virtual std::stringExtractStr(Blob &blob)override;
65+
};
66+
67+
68+
std::stringStampPolyLine3D::ExtractStr(Blob &blob)
69+
{
70+
std::vector<std::string> data =ExtractStrVector(blob);
71+
std::string res ="";
72+
73+
for(std::string s : data)
74+
{
75+
if (!res.empty())
76+
{
77+
res+=",";
78+
}
79+
res+= s;
80+
}
81+
res ="(" + res +")";
82+
return res;
83+
}
84+
85+
intmain()
86+
{
87+
char data[] ="abcdef""abcdef""ABCDEF""012345";
88+
Blobblob(data,strlen(data));
89+
StampPolyLine3D stamp;
90+
91+
std::string s = stamp.ExtractStr(blob);
92+
std::cout << s <<"\n";
93+
}

‎examples/example08.cpp

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
typedefstructPoint3D
10+
{
11+
shortint X;
12+
shortint Y;
13+
shortint Z;
14+
} Point3D;
15+
16+
classStampPoint3D:publicStampBaseStr,publicStampBaseV<Point3D>
17+
{
18+
protected:
19+
StampArithm<shortint> stampX, stampY, stampZ;
20+
public:
21+
virtualintminSize()override;
22+
virtualintmaxSize()override;
23+
virtual std::stringExtractStr(Blob &blob)override;
24+
virtual Point3DExtractValue(Blob &blob)override;
25+
};
26+
27+
intStampPoint3D::minSize()
28+
{
29+
return stampX.minSize() + stampY.minSize() + stampZ.minSize();
30+
}
31+
32+
intStampPoint3D::maxSize()
33+
{
34+
return stampX.maxSize() + stampY.maxSize() + stampZ.maxSize();
35+
}
36+
37+
std::stringStampPoint3D::ExtractStr(Blob &blob)
38+
{
39+
std::string X,Y,Z;
40+
X = stampX.ExtractStr(blob);
41+
Y = stampY.ExtractStr(blob);
42+
Z = stampZ.ExtractStr(blob);
43+
return"(" + X +"," + Y +"," + Z +")";
44+
}
45+
46+
Point3DStampPoint3D::ExtractValue(Blob &blob)
47+
{
48+
Point3D res;
49+
res.X = stampX.ExtractValue(blob);
50+
res.Y = stampY.ExtractValue(blob);
51+
res.Z = stampZ.ExtractValue(blob);
52+
return res;
53+
}
54+
55+
56+
classStampPolyLine3D:publicGalleyVectorStr,publicStampBaseStr
57+
{
58+
protected:
59+
StampPoint3D * item_stamp_p;
60+
public:
61+
StampPolyLine3D(): GalleyVectorStr(*(item_stamp_p =new StampPoint3D())) {};
62+
~StampPolyLine3D() {delete item_stamp_p;};
63+
64+
virtual std::stringExtractStr(Blob &blob)override;
65+
};
66+
67+
classStampStrEnumerator:publicGalleyVectorStr,publicStampBaseStr
68+
{
69+
protected:
70+
StampBaseStr & stamp_str;
71+
const std::string separator;
72+
const std::string left_bracket;
73+
const std::string right_bracket;
74+
public:
75+
StampStrEnumerator(StampBaseStr &arg_stamp,
76+
const std::string arg_sep,
77+
const std::string arg_l,
78+
const std::string arg_r
79+
):
80+
stamp_str(arg_stamp),
81+
separator(arg_sep),
82+
left_bracket(arg_l),
83+
right_bracket(arg_r),
84+
GalleyVectorStr(arg_stamp) {};
85+
86+
virtual std::stringExtractStr(Blob &blob)override;
87+
88+
};
89+
90+
91+
std::stringStampStrEnumerator::ExtractStr(Blob &blob)
92+
{
93+
std::vector<std::string> data =ExtractStrVector(blob);
94+
std::string res ="";
95+
96+
for(std::string s : data)
97+
{
98+
if (!res.empty())
99+
{
100+
res+= separator;
101+
}
102+
res+= s;
103+
}
104+
res = left_bracket + res + right_bracket;
105+
return res;
106+
}
107+
108+
109+
110+
std::stringStampPolyLine3D::ExtractStr(Blob &blob)
111+
{
112+
std::vector<std::string> data =ExtractStrVector(blob);
113+
std::string res ="";
114+
115+
for(std::string s : data)
116+
{
117+
if (!res.empty())
118+
{
119+
res+=",";
120+
}
121+
res+= s;
122+
}
123+
res ="(" + res +")";
124+
return res;
125+
}
126+
127+
intmain()
128+
{
129+
char data[] ="abcdef""abcdef""ABCDEF""012345";
130+
Blobblob(data,strlen(data));
131+
StampPoint3D stamp;
132+
133+
StampStrEnumeratorstamp_e(stamp," -","[","]");
134+
135+
136+
std::string s = stamp_e.ExtractStr(blob);
137+
std::cout << s <<"\n";
138+
}

‎test_with_sanitizers.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export LDFLAGS="-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=u
88

99
make clean
1010
make
11-
maketest
11+
maketest
12+
make examples

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp