Skip to content

Commit c52e036

Browse files
Some examples added
1 parent 2d3bd10 commit c52e036

File tree

5 files changed

+280
-0
lines changed

5 files changed

+280
-0
lines changed

examples/example02.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
int main()
10+
{
11+
char data[] = "abcdefjhi";
12+
Blob blob(data, strlen(data));
13+
StampArithm<short int> stamp;
14+
15+
std::string s = stamp.ExtractStr(blob);
16+
std::vector<char> vec= stamp.ExtractBin(blob);
17+
short int i = stamp.ExtractValue(blob);
18+
19+
sized_ptr<short int> spi = stamp.ExtractPValue(blob);
20+
short int *pi = spi;
21+
22+
std::cout << "String value: '" << s <<"'\n";
23+
std::cout << "Bin value: '" << vec[0] <<"', '" << vec[1] <<"'\n";
24+
std::cout << "Value: " << i <<"\n";
25+
std::cout << "PValue: " << *pi <<"\n";
26+
}

examples/example03.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
class StampPoint3D: public StampBaseStr
10+
{
11+
protected:
12+
StampArithm<short int> stampX, stampY, stampZ;
13+
public:
14+
virtual int minSize() override;
15+
virtual int maxSize() override;
16+
virtual std::string ExtractStr(Blob &blob) override;
17+
};
18+
19+
int StampPoint3D::minSize()
20+
{
21+
return stampX.minSize() + stampY.minSize() + stampZ.minSize();
22+
}
23+
24+
int StampPoint3D::maxSize()
25+
{
26+
return stampX.maxSize() + stampY.maxSize() + stampZ.maxSize();
27+
}
28+
29+
std::string StampPoint3D::ExtractStr(Blob &blob)
30+
{
31+
std::string X,Y,Z;
32+
X = stampX.ExtractStr(blob);
33+
Y = stampY.ExtractStr(blob);
34+
Z = stampZ.ExtractStr(blob);
35+
return "(" + X + ", " + Y + ", " + Z + ")";
36+
}
37+
38+
39+
int main()
40+
{
41+
char data[] = "abcdef";
42+
Blob blob(data, strlen(data));
43+
StampPoint3D stamp;
44+
45+
std::string s = stamp.ExtractStr(blob);
46+
47+
std::cout << "String value: '" << s <<"'\n";
48+
}

examples/example04.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
typedef struct Point3D
10+
{
11+
short int X;
12+
short int Y;
13+
short int Z;
14+
} Point3D;
15+
16+
class StampPoint3D: public StampBaseStr, public StampBaseV<Point3D>
17+
{
18+
protected:
19+
StampArithm<short int> stampX, stampY, stampZ;
20+
public:
21+
virtual int minSize() override;
22+
virtual int maxSize() override;
23+
virtual std::string ExtractStr(Blob &blob) override;
24+
virtual Point3D ExtractValue(Blob &blob) override;
25+
};
26+
27+
int StampPoint3D::minSize()
28+
{
29+
return stampX.minSize() + stampY.minSize() + stampZ.minSize();
30+
}
31+
32+
int StampPoint3D::maxSize()
33+
{
34+
return stampX.maxSize() + stampY.maxSize() + stampZ.maxSize();
35+
}
36+
37+
std::string StampPoint3D::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+
Point3D StampPoint3D::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+
int main()
56+
{
57+
char data[] = "abcdef" "abcdef";
58+
Blob blob(data, strlen(data));
59+
StampPoint3D stamp;
60+
61+
std::string s = stamp.ExtractStr(blob);
62+
Point3D p = stamp.ExtractValue(blob);
63+
64+
std::cout << "String value: '" << s <<"'\n";
65+
std::cout << "Point3D value: (" << p.X << ", " << p.Y << ", " << p.Z << ")\n";
66+
}

examples/example05.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
typedef struct Point3D
10+
{
11+
short int X;
12+
short int Y;
13+
short int Z;
14+
} Point3D;
15+
16+
class StampPoint3D: public StampBaseStr, public StampBaseV<Point3D>
17+
{
18+
protected:
19+
StampArithm<short int> stampX, stampY, stampZ;
20+
public:
21+
virtual int minSize() override;
22+
virtual int maxSize() override;
23+
virtual std::string ExtractStr(Blob &blob) override;
24+
virtual Point3D ExtractValue(Blob &blob) override;
25+
};
26+
27+
int StampPoint3D::minSize()
28+
{
29+
return stampX.minSize() + stampY.minSize() + stampZ.minSize();
30+
}
31+
32+
int StampPoint3D::maxSize()
33+
{
34+
return stampX.maxSize() + stampY.maxSize() + stampZ.maxSize();
35+
}
36+
37+
std::string StampPoint3D::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+
Point3D StampPoint3D::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+
int main()
56+
{
57+
char data[] = "abcdef" "abcdef" "ABCDEF" "012345";
58+
Blob blob(data, strlen(data));
59+
StampPoint3D stamp;
60+
61+
GalleyVectorStr galley(stamp);
62+
63+
std::vector<std::string> res = galley.ExtractStrVector(blob);
64+
65+
for(std::string s : res)
66+
std::cout << "'" << s <<"'\n";
67+
}

examples/example06.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
#include<string>
5+
#include<iostream>
6+
7+
#include<blobstamper/blobstamper.h>
8+
9+
typedef struct Point3D
10+
{
11+
short int X;
12+
short int Y;
13+
short int Z;
14+
} Point3D;
15+
16+
class StampPoint3D: public StampBaseStr, public StampBaseV<Point3D>
17+
{
18+
protected:
19+
StampArithm<short int> stampX, stampY, stampZ;
20+
public:
21+
virtual int minSize() override;
22+
virtual int maxSize() override;
23+
virtual std::string ExtractStr(Blob &blob) override;
24+
virtual Point3D ExtractValue(Blob &blob) override;
25+
};
26+
27+
int StampPoint3D::minSize()
28+
{
29+
return stampX.minSize() + stampY.minSize() + stampZ.minSize();
30+
}
31+
32+
int StampPoint3D::maxSize()
33+
{
34+
return stampX.maxSize() + stampY.maxSize() + stampZ.maxSize();
35+
}
36+
37+
std::string StampPoint3D::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+
Point3D StampPoint3D::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+
int main()
56+
{
57+
char data[] = "abcdef" "abcdef" "ABCDEF" "012345";
58+
Blob blob(data, strlen(data));
59+
StampPoint3D stamp;
60+
61+
GalleyVectorV<Point3D> galley(stamp);
62+
std::vector<Point3D> res = galley.ExtractValuesVector(blob);
63+
64+
Point3D *p = &res[0];
65+
int p_size = res.size();
66+
67+
for(int i=0; i<p_size; i++)
68+
{
69+
std::cout << "(" << p[i].X << ", " << p[i].Y << ", " << p[i].Z << ")\n";
70+
}
71+
72+
73+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy