@@ -46,46 +46,40 @@ Blob::Dump()
46
46
hexdump (data + begin, length);
47
47
}
48
48
49
+
49
50
std::shared_ptr<Blob>
50
- Blob::ShiftBytes (size_t n )
51
+ Blob::Chop (size_t chop_size )
51
52
{
52
- if (this ->Size () <n )
53
+ if (this ->Size () <chop_size )
53
54
{
54
55
throw OutOfData ();
55
56
}
56
57
57
- std::shared_ptr<Blob> new_blob = std::make_shared<Blob>(this ->data , size);
58
-
59
- new_blob->begin = begin;/* FIXME this should go private once*/
60
- new_blob->end = begin + n -1 ;
61
-
62
- begin += n;
58
+ std::shared_ptr<Blob> new_blob = std::make_shared<Blob>(this ->data + begin, chop_size);
59
+ begin += chop_size;
63
60
64
61
return new_blob;
65
62
}
66
63
67
- std::vector< char >
68
- Blob::ChopBlank (StampBase &stamp )
64
+ std::shared_ptr<Blob >
65
+ Blob::Chop ( size_t min_size, size_t max_size )
69
66
{
70
- if (stamp. minSize () > this ->Size ())
67
+ if (this ->Size () < min_size )
71
68
{
72
69
throw OutOfData ();
73
70
}
74
- size_t res_size;
75
- if (stamp.isUnbounded ())
76
- {
77
- res_size =this ->Size ();
78
- }else
79
- {
80
- res_size = stamp.maxSize ();
81
- if (res_size >this ->Size ())
82
- res_size =this ->Size ();
83
- }
84
- std::vector<char >res ((char *)this ->data +this ->begin , (char *)this ->data +this ->begin + res_size);
85
- this ->begin += res_size;
86
- return res;
71
+ if (this ->Size () >= max_size)
72
+ return this ->Chop (max_size);
73
+
74
+ return this ->Chop (this ->Size ());
87
75
}
88
76
77
+ std::vector<char >
78
+ Blob::AsByteVector ()
79
+ {
80
+ std::vector<char >res (data + begin, data + begin + size);
81
+ return res;
82
+ }
89
83
90
84
size_t
91
85
Blob::Size ()