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

Commitec37149

Browse files
Move shifting pg-point into Stamp concept
1 parent14637b7 commitec37149

File tree

3 files changed

+50
-65
lines changed

3 files changed

+50
-65
lines changed

‎libblobstamper.cpp‎

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -117,75 +117,14 @@ Blob::ShiftSingleStampStr(StampGeneric& stmp)
117117
return stmp.ExtractStr(*this);
118118
}
119119

120-
121-
std::string
122-
wflShiftDouble(Blob &blob)
123-
{
124-
int ret;
125-
double * d;
126-
char * resc;
127-
std::string res;
128-
129-
130-
Blob b2 = blob.ShiftBytes(sizeof(double));
131-
if (b2.isEmpty())return"";
132-
133-
d = (double *)( (char*)b2.data + b2.begin);
134-
135-
int size_s =snprintf(nullptr,0,"%.999g", *d) +1;
136-
if (size_s <=0)
137-
{
138-
printf("ai-ai-ai\n");
139-
return"";
140-
}
141-
142-
resc =(char *)malloc(size_s);
143-
if (! resc)
144-
{
145-
printf("oh-oh-oh\n");
146-
return"";
147-
}
148-
149-
ret =snprintf(resc,size_s,"%.999g", *d);
150-
if (ret <=0)
151-
{
152-
printf("oi-oi-oi\n");
153-
free(resc);
154-
return"";
155-
}
156-
res = resc;
157-
free(resc);
158-
return res;
159-
}
160-
161-
std::string
162-
wflShiftPgPoint(Blob &blob)
163-
{
164-
std::string res ="";
165-
std::string x, y;
166-
167-
StampStrDouble stamp;
168-
169-
x = blob.ShiftSingleStampStr(stamp);
170-
if (x.empty())return"";
171-
172-
y = blob.ShiftSingleStampStr(stamp);
173-
if (y.empty())return"";
174-
175-
res = (std::string)"(" + x +"," + y +")";
176-
return res;
177-
}
178-
179-
180120
std::string
181121
wflShiftPgPath(Blob &blob)
182122
{
183123
std::string res ="";
184-
std::string point;
185-
124+
StampStrPgPoint stamp_pg_point;
186125
while (1)
187126
{
188-
point =wflShiftPgPoint(blob);
127+
std::stringpoint = blob.ShiftSingleStampStr(stamp_pg_point);
189128
if (point.empty())
190129
break;
191130
if (!res.empty()) res = res +",";
@@ -197,6 +136,7 @@ wflShiftPgPath(Blob &blob)
197136
return res;
198137
}
199138

139+
/*************************************************************************************/
200140

201141
StampBinDouble::StampBinDouble()
202142
{
@@ -216,6 +156,8 @@ StampBinDouble::Extract(Blob &blob)
216156
return res;
217157
}
218158

159+
/* ----*/
160+
219161
std::string
220162
StampStrDouble::ExtractStr(Blob &blob)
221163
{
@@ -250,4 +192,29 @@ StampStrDouble::ExtractStr(Blob &blob)
250192
free(pd);
251193
return res;
252194
}
195+
/* ----*/
196+
197+
StampStrPgPoint::StampStrPgPoint()
198+
{
199+
min_size = stamp_double.minSize() *2;
200+
max_size = stamp_double.maxSize() *2;
201+
is_fixed_size =true;
202+
}
203+
204+
205+
std::string
206+
StampStrPgPoint::ExtractStr(Blob &blob)
207+
{
208+
std::string res ="";
209+
std::string x, y;
210+
211+
x = blob.ShiftSingleStampStr(stamp_double);
212+
if (x.empty())return"";
213+
214+
y = blob.ShiftSingleStampStr(stamp_double);
215+
if (y.empty())return"";
216+
217+
res = (std::string)"(" + x +"," + y +")";
218+
return res;
219+
}
253220

‎libblobstamper.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ class StampStrDouble: public StampBinDouble
5858

5959
};
6060

61+
62+
classStampStrPgPoint:publicStampGeneric
63+
{
64+
protected:
65+
StampStrDouble stamp_double;
66+
public:
67+
StampStrPgPoint();
68+
std::stringExtractStr(Blob &blob)override;
69+
};
70+
6171
BlobwflShiftN(Blob &blob,size_t n);
6272
std::stringwflShiftDouble(Blob &blob);
6373
std::stringwflShiftPgPoint(Blob &blob);

‎test_libblobstamper.cpp‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ main(void)
4141

4242
StampStrDouble stmp_str_double;
4343

44-
std::string str =stmp_str_double.ExtractStr(bl);
44+
std::string str =bl.ShiftSingleStampStr(stmp_str_double);
4545

4646
printf("-------- %s\n", str.c_str());
4747

48-
str =wflShiftPgPoint(bl);
48+
StampStrPgPoint stmp_pg_point;
49+
50+
str = bl.ShiftSingleStampStr(stmp_pg_point);
51+
52+
printf("======= %s\n", str.c_str());
53+
54+
str =wflShiftPgPath(bl);
4955

5056
printf("++++++++ %s\n", str.c_str());
5157

58+
59+
5260
return0;
5361
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp