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

Commit731abc4

Browse files
Properly implement GalleyVector's ExtractValues
1 parentcc7200f commit731abc4

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

‎blobstamper/blob.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ class Blob
2929

3030
std::vector<char>ShiftSingleStampBin(StampBase &stmp);
3131
std::stringShiftSingleStampStr(StampBase &stmp);
32+
};
3233

34+
classOutOfData/*An exeption. Experemental for now*/
35+
{
3336

3437
};
3538

36-
classOutOfData/*An exeption. Experemental for now*/
39+
classNotImplemented/*An exeption*/
3740
{
3841

3942
};

‎blobstamper/galley.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ 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
39+
template<classT>classGalleyVectorV:publicGalleyVector
4040
{
41-
StampT& v_stamp;
41+
StampBaseT<T>& v_stamp;
4242
public:
43-
GalleyVectorV(StampT stamp_arg): GalleyVector(stamp_arg), v_stamp(stamp_arg) {};
43+
GalleyVectorV(StampBaseT<T> & stamp_arg): GalleyVector(stamp_arg), v_stamp(stamp_arg) {};
4444
std::vector<T>ExtractValues(Blob &blob);
4545
};
4646

4747

48-
template<classT,classStampT> std::vector<T>
49-
GalleyVectorV<T, StampT>::ExtractValues(Blob &blob)
48+
template<classT> std::vector<T>
49+
GalleyVectorV<T>::ExtractValues(Blob &blob)
5050
{
5151
std::vector<Blob> blobs =extract_internal(blob);
5252
std::vector<T>res(blobs.size());

‎blobstamper/stamp.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ class StampBase
1717
boolisVariated() {return !isFixedSize() && !isUnbounded();}
1818
boolisUnbounded() {returnmaxSize() == -1;}
1919

20-
virtual std::vector<char>ExtractBin(Blob &blob) {printf ("Not implemented");exit(1);}
21-
virtual std::stringExtractStr(Blob &blob) {printf ("Not implemented");exit(1);}
20+
virtual std::vector<char>ExtractBin(Blob &blob) {throwNotImplemented();};
21+
virtual std::stringExtractStr(Blob &blob) {throwNotImplemented();};
2222
};
2323

24-
classStampFixed :publicStampBase
24+
25+
template<classT>classStampBaseT:publicvirtual StampBase
26+
{
27+
public:
28+
virtual TExtractValue(Blob &blob) = 0;/* Shoud be defined by derived classes*/
29+
};
30+
31+
classStampFixed :publicvirtual StampBase
2532
{
2633
protected:
2734
int size;
@@ -32,7 +39,7 @@ class StampFixed : public StampBase
3239
std::vector<char>ExtractBin(Blob &blob)override;
3340
};
3441

35-
classStampVariated :publicStampBase
42+
classStampVariated :publicvirtualStampBase
3643
{
3744
protected:
3845
int min_size;
@@ -42,7 +49,7 @@ class StampVariated : public StampBase
4249
virtualintmaxSize()override {return max_size;}
4350
};
4451

45-
classStampUnbounded :publicStampBase
52+
classStampUnbounded :publicvirtualStampBase
4653
{
4754
protected:
4855
int min_size;

‎blobstamper/stamp_arithm.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
#include<string>
55
#include"helpers.h"
6+
#include"stamp.h"
67

7-
template<classT>classStampArithm:publicStampFixed
8+
template<classT>classStampArithm:publicStampFixed,publicStampBaseT<T>
89
{
910
public:
1011
StampArithm() { size =sizeof(T);};
11-
std::stringExtractStr(Blob &blob)override;
12-
TExtractValue(Blob &blob);
12+
virtualstd::stringExtractStr(Blob &blob)override;
13+
virtualTExtractValue(Blob &blob)override;
1314
};
1415

1516
template<classT> std::string
@@ -30,10 +31,6 @@ template<class T> T
3031
StampArithm<T>::ExtractValue(Blob &blob)
3132
{
3233
std::vector<char> v =ExtractBin(blob);
33-
if (v.size() ==0)
34-
{
35-
/* FIXME exeption should be here*/
36-
}
3734
T *pT = (T *) &v[0];
3835
return *pT;
3936
}

‎t/300-galley.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ main()
9393

9494
signedint sample[] = {1, -2, -30,40, -55,6};
9595
StampArithm<signedint> stamp;
96-
GalleyVectorV<signedint, StampArithm<signedint>>galley(stamp);
96+
GalleyVectorV<signedint>galley(stamp);
9797
Blobblob((char*)sample,sizeof(sample));
9898
std::vector<signedint> res = galley.ExtractValues(blob);
9999
ok(!memcmp((void*) &sample, (void *) &res[0],sizeof(sample)),"GalleyVectorV returns ok");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp