Tue, 07 May 2013 23:37:46 +0300
Removed the message log. I'll find a better way to convey messages at some point..
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
18 | |
0 | 19 | #include <stdio.h> |
20 | #include <stdlib.h> | |
21 | #include <string.h> | |
22 | #include <stdarg.h> | |
23 | #include <assert.h> | |
24 | // #include <initializer_list> | |
25 | #include "str.h" | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
26 | #include "common.h" |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
27 | #include "misc.h" |
0 | 28 | |
29 | #define ITERATE_STRING(u) \ | |
30 | for (unsigned int u = 0; u < strlen (text); u++) | |
31 | ||
32 | // ============================================================================ | |
33 | // vdynformat: Try to write to a formatted string with size bytes first, if | |
34 | // that fails, double the size and keep recursing until it works. | |
35 | char* vdynformat (const char* csFormat, va_list vArgs, long lSize) { | |
36 | char* buffer = new char[lSize]; | |
37 | int r = vsnprintf (buffer, lSize - 1, csFormat, vArgs); | |
38 | if (r > (signed)(lSize - 1) || r < 0) { | |
39 | delete[] buffer; | |
40 | buffer = vdynformat (csFormat, vArgs, lSize * 2); | |
41 | } | |
42 | return buffer; | |
43 | } | |
44 | ||
45 | // ============================================================================ | |
46 | str::str () { | |
47 | text = new char[1]; | |
48 | clear(); | |
49 | alloclen = strlen (text); | |
50 | } | |
51 | ||
52 | str::str (const char* c) { | |
53 | text = new char[1]; | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
54 | text[0] = '\0'; |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
55 | curs = alloclen = 0; |
0 | 56 | append (c); |
57 | } | |
58 | ||
59 | str::str (char c) { | |
60 | text = new char[1]; | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
61 | text[0] = '\0'; |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
62 | curs = alloclen = 0; |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
63 | append (c); |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
64 | } |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
65 | |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
66 | str::str (QString c) { |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
67 | text = new char[1]; |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
68 | text[0] = '\0'; |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
69 | curs = alloclen = 0; |
0 | 70 | append (c); |
71 | } | |
72 | ||
73 | str::~str () { | |
74 | // delete[] text; | |
75 | } | |
76 | ||
77 | // ============================================================================ | |
78 | void str::clear () { | |
79 | delete[] text; | |
80 | text = new char[1]; | |
81 | text[0] = '\0'; | |
82 | curs = 0; | |
83 | alloclen = 0; | |
84 | } | |
85 | ||
86 | // ============================================================================ | |
87 | void str::resize (unsigned int len) { | |
88 | unsigned int oldlen = strlen (text); | |
89 | char* oldtext = new char[oldlen]; | |
90 | strncpy (oldtext, text, oldlen); | |
91 | ||
92 | delete[] text; | |
93 | text = new char[len+1]; | |
94 | for (unsigned int u = 0; u < len+1; u++) | |
95 | text[u] = 0; | |
96 | strncpy (text, oldtext, len); | |
97 | delete[] oldtext; | |
98 | ||
99 | alloclen = len; | |
100 | } | |
101 | ||
102 | // ============================================================================ | |
103 | void str::dump () { | |
104 | for (unsigned int u = 0; u <= alloclen; u++) | |
105 | printf ("\t%u. %u (%c)\n", u, text[u], text[u]); | |
106 | } | |
107 | ||
108 | // ============================================================================ | |
109 | // Adds a new character at the end of the string. | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
110 | void str::append (const char c) { |
0 | 111 | // Out of space, thus resize |
112 | if (curs == alloclen) | |
113 | resize (alloclen + 1); | |
114 | text[curs] = c; | |
115 | curs++; | |
116 | } | |
117 | ||
118 | void str::append (const char* c) { | |
119 | resize (alloclen + strlen (c)); | |
120 | ||
121 | for (unsigned int u = 0; u < strlen (c); u++) { | |
122 | if (c[u] != 0) | |
123 | append (c[u]); | |
124 | } | |
125 | } | |
126 | ||
127 | void str::append (str c) { | |
128 | append (c.chars()); | |
129 | } | |
130 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
131 | void str::append (QString c) { |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
132 | append (c.toUtf8 ().constData ()); |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
133 | } |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
134 | |
0 | 135 | // ============================================================================ |
136 | void str::appendformat (const char* c, ...) { | |
137 | va_list v; | |
138 | ||
139 | va_start (v, c); | |
140 | char* buf = vdynformat (c, v, 256); | |
141 | va_end (v); | |
142 | ||
143 | append (buf); | |
144 | delete[] buf; | |
145 | } | |
146 | ||
147 | void str::format (const char* fmt, ...) { | |
148 | clear (); | |
149 | ||
150 | va_list v; | |
151 | ||
152 | va_start (v, fmt); | |
153 | char* buf = vdynformat (fmt, v, 256); | |
154 | va_end (v); | |
155 | ||
156 | append (buf); | |
157 | delete[] buf; | |
158 | } | |
159 | ||
160 | // ============================================================================ | |
161 | char* str::chars () { | |
162 | return text; | |
163 | } | |
164 | ||
165 | // ============================================================================ | |
166 | int str::first (const char* c, unsigned int a) { | |
167 | unsigned int r = 0; | |
168 | unsigned int index = 0; | |
169 | for (; a < alloclen; a++) { | |
170 | if (text[a] == c[r]) { | |
171 | if (r == 0) | |
172 | index = a; | |
173 | ||
174 | r++; | |
175 | if (r == strlen (c)) | |
176 | return index; | |
177 | } else { | |
178 | if (r != 0) { | |
179 | // If the string sequence broke at this point, we need to | |
180 | // check this character again, for a new sequence just | |
181 | // might start right here. | |
182 | a--; | |
183 | } | |
184 | ||
185 | r = 0; | |
186 | } | |
187 | } | |
188 | ||
189 | return -1; | |
190 | } | |
191 | ||
192 | // ============================================================================ | |
193 | int str::last (const char* c, int a) { | |
194 | if (a == -1) | |
195 | a = len(); | |
196 | ||
197 | int max = strlen (c)-1; | |
198 | ||
199 | int r = max; | |
200 | for (; a >= 0; a--) { | |
201 | if (text[a] == c[r]) { | |
202 | r--; | |
203 | if (r == -1) | |
204 | return a; | |
205 | } else { | |
206 | if (r != max) | |
207 | a++; | |
208 | ||
209 | r = max; | |
210 | } | |
211 | } | |
212 | ||
213 | return -1; | |
214 | } | |
215 | ||
216 | // ============================================================================ | |
217 | str str::substr (unsigned int a, unsigned int b) { | |
218 | if (a > len()) a = len(); | |
219 | if (b > len()) b = len(); | |
220 | ||
221 | if (b == a) | |
222 | return ""; | |
223 | ||
224 | if (b < a) { | |
225 | printf ("str::substring:: indices %u and %u given, should be the other way around, swapping..\n", a, b); | |
226 | ||
227 | // Swap the variables | |
228 | unsigned int c = a; | |
229 | a = b; | |
230 | b = c; | |
231 | } | |
232 | ||
233 | char* s = new char[b - a + 1]; | |
234 | strncpy (s, text + a, b - a); | |
235 | s[b - a] = '\0'; | |
236 | ||
237 | str other = s; | |
238 | delete[] s; | |
239 | return other; | |
240 | } | |
241 | ||
242 | // ============================================================================ | |
243 | void str::remove (unsigned int idx, unsigned int dellen) { | |
244 | str s1 = substr (0, idx); | |
245 | str s2 = substr (idx + dellen, -1); | |
246 | ||
247 | clear(); | |
248 | ||
249 | append (s1); | |
250 | append (s2); | |
251 | } | |
252 | ||
253 | // ============================================================================ | |
254 | str str::trim (int dellen) { | |
255 | if (dellen > 0) | |
256 | return substr (0, len() - dellen); | |
257 | return substr (-dellen, len()); | |
258 | } | |
259 | ||
260 | // ============================================================================ | |
261 | void str::replace (const char* o, const char* n, unsigned int a) { | |
262 | for (int idx; (idx = first (o, a)) != -1;) { | |
263 | str s1 = substr (0, idx); | |
264 | str s2 = substr (idx + strlen (o), len()); | |
265 | ||
266 | clear(); | |
267 | ||
268 | append (s1); | |
269 | append (n); | |
270 | append (s2); | |
271 | } | |
272 | } | |
273 | ||
274 | // ============================================================================ | |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
275 | str str::strip (char c) { |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
276 | return strip ({c}); |
0 | 277 | } |
278 | ||
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
279 | str str::strip (std::initializer_list<char> unwanted) { |
0 | 280 | str cache = text; |
281 | uint oldlen = len(); | |
282 | ||
283 | char* buf = new char[oldlen]; | |
284 | char* bufptr = buf; | |
285 | for (uint i = 0; i < oldlen; i++) { | |
286 | bool valid = true; | |
287 | for (const char* j = unwanted.begin(); j < unwanted.end() && valid; j++) | |
288 | if (text[i] == *j) | |
289 | valid = false; | |
290 | ||
291 | if (valid) | |
292 | *bufptr++ = text[i]; | |
293 | } | |
294 | ||
295 | *bufptr = '\0'; | |
296 | assert (bufptr <= buf + oldlen); | |
297 | ||
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
298 | str zResult = buf; |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
299 | delete[] buf; |
0 | 300 | |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
301 | return zResult; |
0 | 302 | } |
303 | ||
304 | void str::insert (char* c, unsigned int pos) { | |
305 | str s1 = substr (0, pos); | |
306 | str s2 = substr (pos, len()); | |
307 | ||
308 | clear(); | |
309 | append (s1); | |
310 | append (c); | |
311 | append (s2); | |
312 | } | |
313 | ||
314 | str str::reverse () { | |
315 | char* buf = new char[len() + 1]; | |
316 | ||
317 | for (uint i = 0; i < len(); i++) | |
318 | buf[i] = text[len() - i - 1]; | |
319 | buf[len()] = '\0'; | |
320 | ||
321 | str other = buf; | |
322 | delete[] buf; | |
323 | return other; | |
324 | } | |
325 | ||
326 | str str::repeat (int n) { | |
327 | assert (n >= 0); | |
328 | ||
329 | str other; | |
330 | for (int i = 0; i < n; i++) | |
331 | other += text; | |
332 | return other; | |
333 | } | |
334 | ||
335 | // ============================================================================ | |
336 | bool str::isnumber () { | |
337 | ITERATE_STRING (u) { | |
338 | // Minus sign as the first character is allowed for negatives | |
339 | if (!u && text[u] == '-') | |
340 | continue; | |
341 | ||
342 | if (text[u] < '0' || text[u] > '9') | |
343 | return false; | |
344 | } | |
345 | return true; | |
346 | } | |
347 | ||
348 | // ============================================================================ | |
349 | bool str::isword () { | |
350 | ITERATE_STRING (u) { | |
351 | // lowercase letters | |
352 | if (text[u] >= 'a' || text[u] <= 'z') | |
353 | continue; | |
354 | ||
355 | // uppercase letters | |
356 | if (text[u] >= 'A' || text[u] <= 'Z') | |
357 | continue; | |
358 | ||
359 | return false; | |
360 | } | |
361 | return true; | |
362 | } | |
363 | ||
364 | int str::instanceof (const char* c, uint n) { | |
365 | unsigned int r = 0; | |
366 | unsigned int index = 0; | |
367 | unsigned int x = 0; | |
368 | for (uint a = 0; a < alloclen; a++) { | |
369 | if (text[a] == c[r]) { | |
370 | if (r == 0) | |
371 | index = a; | |
372 | ||
373 | r++; | |
374 | if (r == strlen (c)) { | |
375 | if (x++ == n) | |
376 | return index; | |
377 | r = 0; | |
378 | } | |
379 | } else { | |
380 | if (r != 0) | |
381 | a--; | |
382 | r = 0; | |
383 | } | |
384 | } | |
385 | ||
386 | return -1; | |
387 | } | |
388 | ||
389 | // ============================================================================ | |
390 | int str::compare (const char* c) { | |
391 | return strcmp (text, c); | |
392 | } | |
393 | ||
394 | int str::compare (str c) { | |
395 | return compare (c.chars()); | |
396 | } | |
397 | ||
398 | int str::icompare (const char* c) { | |
399 | return icompare (str ((char*)c)); | |
400 | } | |
401 | ||
402 | int str::icompare (str b) { | |
403 | return strcmp (tolower().chars(), b.tolower().chars()); | |
404 | } | |
405 | ||
406 | // ============================================================================ | |
407 | str str::tolower () { | |
408 | str n = text; | |
409 | ||
410 | for (uint u = 0; u < len(); u++) { | |
411 | if (n[u] >= 'A' && n[u] < 'Z') | |
412 | n.text[u] += ('a' - 'A'); | |
413 | } | |
414 | ||
415 | return n; | |
416 | } | |
417 | ||
418 | // ============================================================================ | |
419 | str str::toupper () { | |
420 | str n = text; | |
421 | ||
422 | for (uint u = 0; u < len(); u++) { | |
423 | if (n[u] >= 'a' && n[u] < 'z') | |
424 | n.text[u] -= ('a' - 'A'); | |
425 | } | |
426 | ||
427 | return n; | |
428 | } | |
429 | ||
430 | // ============================================================================ | |
431 | unsigned str::count (char c) { | |
432 | unsigned n = 0; | |
433 | ITERATE_STRING (u) | |
434 | if (text[u] == c) | |
435 | n++; | |
436 | return n; | |
437 | } | |
438 | ||
439 | unsigned str::count (char* c) { | |
440 | unsigned int r = 0; | |
441 | unsigned int tmp = 0; | |
442 | ITERATE_STRING (u) { | |
443 | if (text[u] == c[r]) { | |
444 | r++; | |
445 | if (r == strlen (c)) { | |
446 | r = 0; | |
447 | tmp++; | |
448 | } | |
449 | } else { | |
450 | if (r != 0) | |
451 | u--; | |
452 | r = 0; | |
453 | } | |
454 | } | |
455 | ||
456 | return tmp; | |
457 | } | |
458 | ||
459 | // ============================================================================ | |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
460 | std::vector<str> str::split (str del, bool bNoBlanks) { |
0 | 461 | std::vector<str> res; |
462 | unsigned int a = 0; | |
463 | ||
464 | // Find all separators and store the text left to them. | |
465 | while (1) { | |
466 | int b = first (del, a); | |
467 | ||
468 | if (b == -1) | |
469 | break; | |
470 | ||
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
471 | if (!bNoBlanks || (b - a)) |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
472 | res.push_back (substr (a, b)); |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
473 | |
0 | 474 | a = b + strlen (del); |
475 | } | |
476 | ||
477 | // Add the string at the right of the last separator | |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
478 | if (!bNoBlanks || (len () - a)) |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
479 | res.push_back (substr (a, len ())); |
0 | 480 | return res; |
481 | } | |
482 | ||
483 | std::vector<str> str::operator/ (str splitstring) {return split(splitstring);} | |
484 | std::vector<str> str::operator/ (char* splitstring) {return split(splitstring);} | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
485 | std::vector<str> str::operator/ (const char* splitstring) {return split(splitstring);} |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
486 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
487 | str& str::operator+= (vertex vrt) { |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
488 | appendformat ("%s", vrt.stringRep (false).chars()); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
489 | return *this; |
116 | 490 | } |
491 | ||
161 | 492 | str fmt (const char* fmt, ...) { |
116 | 493 | va_list va; |
494 | char* buf; | |
495 | ||
496 | va_start (va, fmt); | |
497 | buf = vdynformat (fmt, va, 256); | |
498 | va_end (va); | |
499 | ||
500 | str val = buf; | |
501 | delete[] buf; | |
502 | return val; | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
503 | } |