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

Commitcc7200f

Browse files
Trying to teach GalleyVector to return vector of values.
1 parent14b2e7a commitcc7200f

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

‎blobstamper/galley.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ GalleyVector::minSize()
3434
std::vector<std::string>
3535
GalleyVector::ExtractStr(Blob &blob)
3636
{
37-
std::vector<std::string> res;
3837
std::vector<Blob> blobs =extract_internal(blob);
39-
for(Blob blob : blobs)
38+
std::vector<std::string>res(blobs.size());
39+
40+
for(int i =0; i<blobs.size(); i++)
4041
{
41-
std::string str= blob.ShiftSingleStampStr(stamp);
42-
res.push_back(str);
42+
res[i] = blobs[i].ShiftSingleStampStr(stamp);
4343
}
4444
return res;
4545
}
4646

4747
std::vector<std::vector<char>>
4848
GalleyVector::ExtractBin(Blob &blob)
4949
{
50-
std::vector<std::vector<char>> res;
5150
std::vector<Blob> blobs =extract_internal(blob);
52-
for(Blob blob : blobs)
51+
std::vector<std::vector<char>>res(blobs.size());
52+
53+
for(int i =0; i<blobs.size(); i++)
5354
{
54-
std::vector<char> data = blob.ShiftSingleStampBin(stamp);
55-
res.push_back(data);
55+
res[i] = blobs[i].ShiftSingleStampBin(stamp);
5656
}
5757
return res;
5858
}

‎blobstamper/galley.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,29 @@ class GalleyVector : public GalleyBase
3636
intmaxSize()override {return -1;};/* Sereies always takes as much data as it can take*/
3737
};
3838

39+
template<classT,classStampT>classGalleyVectorV:publicGalleyVector
40+
{
41+
StampT& v_stamp;
42+
public:
43+
GalleyVectorV(StampT stamp_arg): GalleyVector(stamp_arg), v_stamp(stamp_arg) {};
44+
std::vector<T>ExtractValues(Blob &blob);
45+
};
46+
47+
48+
template<classT,classStampT> std::vector<T>
49+
GalleyVectorV<T, StampT>::ExtractValues(Blob &blob)
50+
{
51+
std::vector<Blob> blobs =extract_internal(blob);
52+
std::vector<T>res(blobs.size());
53+
54+
for(int i=0; i<blobs.size(); i++)
55+
{
56+
res[i] = v_stamp.ExtractValue(blobs[i]);
57+
}
58+
return res;
59+
}
60+
61+
3962
classGalleySet :publicGalleyBase
4063
{
4164
protected:

‎blobstamper/stamp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class StampBase
2121
virtual std::stringExtractStr(Blob &blob) {printf ("Not implemented");exit(1);}
2222
};
2323

24-
2524
classStampFixed :publicStampBase
2625
{
2726
protected:

‎t/300-galley.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ char longer_sample[]="z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRS
1919
int
2020
main()
2121
{
22-
TEST_START(67);
22+
TEST_START(68);
2323
/* Test Galley Sereies with fixed size stampp*/
2424
{/* 1..4*/
2525
std::string expected1 ="12";
@@ -89,8 +89,18 @@ main()
8989
is(res.size(),3,"GalleyVector, fixed size binary stamp: result has 3 elements");
9090
}
9191

92+
{/* 14*/
93+
94+
signedint sample[] = {1, -2, -30,40, -55,6};
95+
StampArithm<signedint> stamp;
96+
GalleyVectorV<signedint, StampArithm<signedint>>galley(stamp);
97+
Blobblob((char*)sample,sizeof(sample));
98+
std::vector<signedint> res = galley.ExtractValues(blob);
99+
ok(!memcmp((void*) &sample, (void *) &res[0],sizeof(sample)),"GalleyVectorV returns ok");
100+
}
101+
92102
/* Test Galley Sereies with variated size stamp*/
93-
{/*14 ..18*/
103+
{/*15 ..19*/
94104
/* This is not the best test, as we do not predict behavior by setting forged sample values,
95105
but at least here we check that it work the same way it worked before. May be this test should be improved later*/
96106

@@ -118,7 +128,7 @@ main()
118128
}
119129

120130
/* Test GalleySet with fixed size stamps*/
121-
{/*19 ..22*/
131+
{/*20 ..23*/
122132

123133
char sample[]="z1234567*89abcde&fghijklm";
124134

@@ -152,7 +162,7 @@ main()
152162
}
153163

154164
/* Test Galley Set with variated size stamps*/
155-
{/*25 ..30*/
165+
{/*26 ..31*/
156166

157167
char sample[]="z1234567*89abcde&fghijklm";
158168

@@ -186,7 +196,7 @@ main()
186196
}
187197

188198
/* Test Galley Set with unbounded size stamps*/
189-
{/*31 ..36*/
199+
{/*32 ..37*/
190200

191201
char sample[]="z1234567*89abcde&fghijklm";
192202

@@ -219,7 +229,7 @@ main()
219229
}
220230

221231
/* Test Galley Set with mixed stam types*/
222-
{/*37 ..46*/
232+
{/*38 ..47*/
223233

224234
char sample[]="z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRSTUVWXYZ!";
225235

@@ -277,7 +287,7 @@ main()
277287
}
278288

279289
/* Test Galley Set, single unbounded stamp will use all data with no oracle to predict it*/
280-
{/*47 ..53*/
290+
{/*48 ..54*/
281291

282292
char sample[]="z1234567*89abcde&fghijklmnopqrstuvwxyzAB%CDEFGHIJKLMNOPQRSTUVWXYZ!";
283293

@@ -319,7 +329,7 @@ main()
319329
}
320330

321331
/* Test Galley Set, when there are only minimal amound of data available*/
322-
{/*54 ..63*/
332+
{/*55 ..64*/
323333

324334
char sample[] ="oo""oo""oo""oo""oo""z1""23""45""67""89""ab";
325335

@@ -376,7 +386,7 @@ main()
376386
}
377387

378388
/* Test Galley Set, when there are not enought data*/
379-
{/*64 ..67*/
389+
{/*65 ..68*/
380390

381391
char sample[] ="oo""oo""oo""oo""oo""z1""23""45""67""89""a";
382392

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp