API Documentation
Loading...
Searching...
No Matches
DXFValueManager.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: CAD
28File: DXFValueManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
34#include "Base/Headers/String.h"
36#include "Base/Headers/Set.h"
37namespace NDEVR
38{
39 class Scanner;
40 class BinaryFile;
42 {
43 public:
45 // ----------------------------------------------------------------------------
46 // Sets the value of a given DXF index.
47 // See the member variables for values accepted by this class
48 // returns false if this class is unable to store the value and true if the
49 // value was successfully stored. Overrides old value, if it exists.
50 // ----------------------------------------------------------------------------
51 bool setValue(uint04 location, const String& value);
52 bool setValue(uint04 location, Scanner& scan);
53 bool setValue(uint04 location, BinaryFile& file);
54 bool appendValue(uint04 location, const String& value);
55
56 template <uint01 t_index>
57 [[nodiscard]] Vector<1, fltp08> getVector1(const fltp08& bad_value) const
58 {
60 }
61
62 template <uint01 t_index>
63 [[nodiscard]] Vector<2, fltp08> getVector2(const fltp08& bad_value) const
64 {
66 }
67
68 template <uint01 t_index>
69 [[nodiscard]] Vector<3, fltp08> getVector3(const fltp08& bad_value) const
70 {
72 }
74 {
75 return m_use_active_value_set;
76 }
77 void setUseActiveValueSet(bool use_active_value_set)
78 {
79 m_use_active_value_set = use_active_value_set;
80 }
82 {
83 return m_active_value_set;
84 }
85
86 template<uint04 t_value, class t_type>
87 bool setValue(const t_type& value)
88 {
89 if (m_use_active_value_set)
90 m_active_value_set.insert(t_value);
91 static_assert(
92 (t_value < 10) || (t_value >= 10 && t_value < 60) || (t_value >= 60 && t_value < 80)
93 || (t_value >= 90 && t_value < 100) || (t_value == 100) || (t_value == 102)
94 || (t_value == 105) || (t_value >= 110 && t_value < 150) || (t_value >= 160 && t_value < 170)
95 || (t_value >= 170 && t_value < 176) || (t_value == 210) || (t_value == 220) || (t_value == 230)
96 || (t_value >= 280 && t_value < 290) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
97 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value >= 370 && t_value < 380)
98 || (t_value == 420) || (t_value == 999) || (t_value >= 1000 && t_value < 1010)
99 || (t_value >= 1010 && t_value < 1060) || (t_value >= 1060 && t_value < 1070) || (t_value == 1071)
100 , "Unknown Value Type");
101 //0-9 String (255 characters maximum; less for Unicode strings)
102 if (t_value < 5)
103 value_0[t_value] = String(value);
104 else if (t_value == 5)
105 value_5 = cast<uint04>(value);
106 else if (t_value >= 6 && t_value < 10)
107 value_6[t_value - 6] = String(value);
108 //10-59 Double precision 3D point
109 else if (t_value >= 10 && t_value < 60)
110 value_10[cast<uint01>(t_value - 10)] = cast<fltp08>(value);
111 //60-79 16-bit integer value
112 else if (t_value >= 60 && t_value < 80)
113 value_60[cast<uint01>(t_value - 60)] = cast<sint02>(value);
114 //90-99 32-bit integer value
115 else if (t_value >= 90 && t_value < 100)
116 value_90[cast<uint01>(t_value - 90)] = cast<sint04>(value);
117 //100 String (255 characters maximum; less for Unicode strings)
118 else if (t_value == 100)
119 value_100 = String(value);
120 //102 String (255 characters maximum; less for Unicode strings)
121 else if (t_value == 102)
122 value_102 = String(value);
123 //105 String representing hexadecimal (hex) handle value
124 else if (t_value == 105)
125 value_105 = String(value);
126 //140-147 Double precision scalar floating-point value
127 else if (t_value >= 110 && t_value < 150)
128 value_110[cast<uint01>(t_value - 110)] = cast<fltp08>(value);
129 else if (t_value >= 160 && t_value < 170)
130 value_160[cast<uint01>(t_value - 160)] = cast<sint08>(value);
131 //170-175 16-bit integer value
132 else if (t_value >= 170 && t_value < 180)
133 value_170[cast<uint01>(t_value - 170)] = cast<sint02>(value);
134 //Extrusion direction (fixed)
135 else if (t_value == 210)
136 value_210 = cast<fltp08>(value);
137 else if (t_value == 220)
138 value_220 = cast<fltp08>(value);
139 else if (t_value == 230)
140 value_230 = cast<fltp08>(value);
141 //280-289 8-bit integer value
142 else if (t_value >= 280 && t_value < 290)
143 value_280[cast<uint01>(t_value - 280)] = cast<sint02>(value);
144 else if (t_value >= 290 && t_value < 300)
145 value_290[cast<uint01>(t_value - 290)] = cast<uint01>(value);
146 //300-309 Arbitrary text string
147 else if (t_value >= 300 && t_value < 310)
148 value_300[t_value - 300] = String(value);
149 //310-319 String representing hex value of binary chunk
150 else if (t_value >= 310 && t_value < 320)
151 value_310[t_value - 310] = String(value);
152 //320-329 String representing hex handle value
153 else if (t_value >= 320 && t_value < 330)
154 value_320[t_value - 320] = String(value);
155 //330-369 String representing hex object IDs
156 else if (t_value >= 330 && t_value < 370)
157 value_330[t_value - 330] = cast<uint04>(value);
158 else if (t_value >= 370 && t_value < 380)
159 value_370[cast<uint01>(t_value - 370)] = cast<sint02>(value);
160 else if (t_value >= 420 && t_value < 430)
161 value_420[t_value - 420] = cast<sint04>(value);
162 //999 Comment (string)
163 else if (t_value == 999)
164 value_999 = String(value);
165 //1000-1009 String (255 characters maximum; less for Unicode strings)
166 else if (t_value >= 1000 && t_value < 1010)
167 value_1000[t_value - 1000] = String(value);
168 //1010-1059 float value
169 else if (t_value >= 1010 && t_value < 1060)
170 value_1010[cast<uint01>(t_value - 1010)] = cast<fltp04>(value);
171 //1060-1070 16-bit integer value
172 else if (t_value >= 1060 && t_value < 1070)
173 value_1060[cast<uint01>(t_value - 1060)] = cast<sint02>(value);
174 //1071 32-bit integer value
175 else if (t_value == 1071)
176 value_1071 = cast<sint04>(value);
177 else
178 return false;
179 return true;
180 }
181 template<uint04 t_value, class t_type>
182 bool appendValue(const t_type& value)
183 {
184 if (m_use_active_value_set)
185 m_active_value_set.insert(t_value);
186 static_assert(
187 (t_value < 10) || (t_value == 100) || (t_value == 102)
188 || (t_value == 105) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
189 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value == 999)
190 || (t_value >= 1000 && t_value < 1010)
191 , "Unknown Value Type");
192 //0-9 String (255 characters maximum; less for Unicode strings)
193 if (t_value < 5)
194 value_0[t_value] += String(value);
195 else if (t_value >= 6 && t_value < 10)
196 value_6[t_value - 6] += String(value);
197 else if (t_value == 100)
198 value_100 += String(value);
199 //102 String (255 characters maximum; less for Unicode strings)
200 else if (t_value == 102)
201 value_102 += String(value);
202 //105 String representing hexadecimal (hex) handle value
203 else if (t_value == 105)
204 value_105 += String(value);
205 else if (t_value >= 300 && t_value < 310)
206 value_300[t_value - 300] += String(value);
207 //310-319 String representing hex value of binary chunk
208 else if (t_value >= 310 && t_value < 320)
209 value_310[t_value - 310] += String(value);
210 //320-329 String representing hex handle value
211 else if (t_value >= 320 && t_value < 330)
212 value_320[t_value - 320] += String(value);
213 //330-369 String representing hex object IDs
214 else if (t_value == 999)
215 value_999 += String(value);
216 //1000-1009 String (255 characters maximum; less for Unicode strings)
217 else if (t_value >= 1000 && t_value < 1010)
218 value_1000[t_value - 1000] += String(value);
219 else
220 return false;
221 return true;
222 }
223 // ----------------------------------------------------------------------------
224 // Sets the value of a given DXF index.
225 // See the member variables for values accepted by this class
226 // ----------------------------------------------------------------------------
227 template<uint04 t_value, class t_type>
228 [[nodiscard]] t_type getValue(const t_type& default_value) const
229 {
230 static_assert(
231 (t_value < 10) || (t_value >= 10 && t_value < 60) || (t_value >= 60 && t_value < 80)
232 || (t_value >= 90 && t_value < 100) || (t_value == 100) || (t_value == 102)
233 || (t_value == 105) || (t_value >= 110 && t_value < 150) || (t_value >= 160 && t_value < 170)
234 || (t_value >= 170 && t_value < 176) || (t_value == 210) || (t_value == 220) || (t_value == 230)
235 || (t_value >= 280 && t_value < 290) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
236 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value >= 370 && t_value < 380)
237 || (t_value == 420) || (t_value == 999) || (t_value >= 1000 && t_value < 1010)
238 || (t_value >= 1010 && t_value < 1060) || (t_value >= 1060 && t_value < 1070) || (t_value == 1071)
239 , "Unknown Value Type");
240 if (!hasValue<t_value>())
241 return default_value;
242#if _MSC_VER
243#pragma warning (disable: 4800) //forcing value to bool (Performance warning)
244#pragma warning (disable: 26454)
245#endif
246 //0-9 String (255 characters maximum; less for Unicode strings)
247 if (t_value < 5)
248 return value_0[t_value].getAs<t_type>();
249 if (t_value == 5)
250 return cast<t_type>(value_5);
251 if (t_value >= 6 && t_value < 10)
252 return value_6[t_value - 6].getAs<t_type>();
253 //10-59 Double precision 3D point
254 if (t_value >= 10 && t_value < 60)
255 return cast<t_type>(value_10[cast<uint01>(t_value - 10)]);
256 //60-79 16-bit integer value
257 if (t_value >= 60 && t_value < 80)
258 return cast<t_type>(value_60[cast<uint01>(t_value - 60)]);
259 //90-99 32-bit integer value
260 if (t_value >= 90 && t_value < 100)
261 return cast<t_type>(value_90[cast<uint01>(t_value - 90)]);
262 //100 String (255 characters maximum; less for Unicode strings)
263 if (t_value == 100)
264 return value_100.getAs<t_type>();
265 //102 String (255 characters maximum; less for Unicode strings)
266 if (t_value == 102)
267 return value_102.getAs<t_type>();
268 //105 String representing hexadecimal (hex) handle value
269 if (t_value == 105)
270 return value_105.getAs<t_type>();
271 //140-147 Double precision scalar floating-point value
272 if (t_value >= 110 && t_value < 150)
273 return cast<t_type>(value_110[cast<uint01>(t_value - 110)]);
274 if (t_value >= 160 && t_value < 170)
275 return cast<t_type>(value_160[cast<uint01>(t_value - 160)]);
276 //170-175 16-bit integer value
277 if (t_value >= 170 && t_value < 180)
278 return cast<t_type>(value_170[cast<uint01>(t_value - 170)]);
279 //Extrusion direction (fixed)
280 if (t_value == 210)
281 return cast<t_type>(value_210);
282 if (t_value == 220)
283 return cast<t_type>(value_220);
284 if (t_value == 230)
285 return cast<t_type>(value_230);
286 //280-289 8-bit integer value
287 if (t_value >= 280 && t_value < 290)
288 return cast<t_type>(value_280[cast<uint01>(t_value - 280)]);
289 if (t_value >= 290 && t_value < 300)
290 return cast<t_type>(value_290[cast<uint01>(t_value - 290)]);
291 //300-309 Arbitrary text string
292 if (t_value >= 300 && t_value < 310)
293 return value_300[t_value - 300].getAs<t_type>();
294 //310-319 String representing hex value of binary chunk
295 if (t_value >= 310 && t_value < 320)
296 return value_310[t_value - 310].getAs<t_type>();
297 //320-329 String representing hex handle value
298 if (t_value >= 320 && t_value < 330)
299 return value_320[t_value - 320].getAs<t_type>();
300
301 //330-369 String representing hex object IDs
302 if (t_value >= 330 && t_value < 370)
303 return cast<t_type>(value_330[cast<uint01>(t_value - 330)]);
304 if (t_value >= 370 && t_value < 380)
305 return cast<t_type>(value_370[cast<uint01>(t_value - 370)]);
306 if (t_value >= 420 && t_value < 430)
307 return cast<t_type>(value_420[cast<uint01>(t_value - 420)]);
308 //999 Comment (string)
309 if (t_value == 999)
310 return value_999.getAs<t_type>();
311 //1000-1009 String (255 characters maximum; less for Unicode strings
312 if (t_value >= 1000 && t_value < 1010)
313 return value_1000[t_value - 1000].getAs<t_type>();
314 //1010-1059 Floating-point value
315 if (t_value >= 1010 && t_value < 1060)
316 return cast<t_type>(value_1010[cast<uint01>(t_value - 1010)]);
317 //1060-1070 16-bit integer value
318 if (t_value >= 1060 && t_value < 1070)
319 return cast<t_type>(value_1060[cast<uint01>(t_value - 1060)]);
320 //1071 32-bit integer value
321 if (t_value == 1071)
322 return cast<t_type>(value_1071);
323 lib_assert(false, "Unknown Index Value");
324 return default_value;
325#if _MSC_VER
326#pragma warning (default: 4800) //forcing value to bool (Performance warning)
327#pragma warning (default: 26454)
328#endif
329 }
330 // ----------------------------------------------------------------------------
331 // Checks whether or not this value has been set by the file or in preperation
332 // for writing to the file.
333 // See the member variables for values accepted by this class
334 // ----------------------------------------------------------------------------
335 template <uint04 t_value>
336 [[nodiscard]] bool hasValue() const
337 {
338 static_assert(
339 (t_value < 10) || (t_value >= 10 && t_value < 60) || (t_value >= 60 && t_value < 80)
340 || (t_value >= 90 && t_value < 100) || (t_value == 100) || (t_value == 102)
341 || (t_value == 105) || (t_value >= 110 && t_value < 150) || (t_value >= 160 && t_value < 170)
342 || (t_value >= 170 && t_value < 176) || (t_value == 210) || (t_value == 220) || (t_value == 230)
343 || (t_value >= 280 && t_value < 290) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
344 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value >= 370 && t_value < 380)
345 || (t_value == 420) || (t_value == 999) || (t_value >= 1000 && t_value < 1010)
346 || (t_value >= 1010 && t_value < 1060) || (t_value >= 1060 && t_value < 1070) || (t_value == 1071)
347 , "Unknown Value Type");
348 //0-9 String (255 characters maximum; less for Unicode strings)
349 if (t_value < 5)
350 return value_0[t_value].size() != 0;
351 if (t_value == 5)
352 return !IsInvalid(value_5);
353 if (t_value >= 6 && t_value < 10)
354 return value_6[t_value - 6].size() != 0;
355 //10-59 Double precision 3D point
356 if (t_value >= 10 && t_value < 60)
357 return !IsInvalid(value_10[cast<uint01>(t_value - 10)]);
358 //60-79 16-bit integer value
359 if (t_value >= 60 && t_value < 80)
360 return !IsInvalid(value_60[cast<uint01>(t_value - 60)]);
361 //90-99 32-bit integer value
362 if (t_value >= 90 && t_value < 100)
363 return !IsInvalid(value_90[cast<uint01>(t_value - 90)]);
364 //100 String (255 characters maximum; less for Unicode strings)
365 if (t_value == 100)
366 return value_100.size() != 0;
367 //102 String (255 characters maximum; less for Unicode strings)
368 if (t_value == 102)
369 return value_102.size() != 0;
370 //105 String representing hexadecimal (hex) handle value
371 if (t_value == 105)
372 return value_105.size() != 0;
373 //140-147 Double precision scalar floating-point value
374 if (t_value >= 110 && t_value < 150)
375 return !IsInvalid(value_110[cast<uint01>(t_value - 110)]);
376 if (t_value >= 160 && t_value < 170)
377 return !IsInvalid(value_160[cast<uint01>(t_value - 160)]);
378 //170-175 16-bit integer value
379 if (t_value >= 170 && t_value < 180)
380 return !IsInvalid(value_170[cast<uint01>(t_value - 170)]);
381 //Extrusion direction (fixed)
382 if (t_value == 210)
383 return !IsInvalid(value_210);
384 if (t_value == 220)
385 return !IsInvalid(value_220);
386 if (t_value == 230)
387 return !IsInvalid(value_230);
388 //280-289 8-bit integer value
389 if (t_value >= 280 && t_value < 290)
390 return !IsInvalid(value_280[cast<uint01>(t_value - 280)]);
391 if (t_value >= 290 && t_value < 300)
392 return !IsInvalid(value_290[cast<uint01>(t_value - 290)]);
393 //300-309 Arbitrary text string
394 if (t_value >= 300 && t_value < 310)
395 return value_300[t_value - 300].size() != 0;
396 //310-319 String representing hex value of binary chunk
397 if (t_value >= 310 && t_value < 320)
398 return value_310[t_value - 310].size() != 0;
399 //320-329 String representing hex handle value
400 if (t_value >= 320 && t_value < 330)
401 return value_320[t_value - 320].size() != 0;
402 //330-369 String representing hex object IDs
403 if (t_value >= 330 && t_value < 370)
404 return !IsInvalid(value_330[cast<uint01>(t_value - 330)]);
405 if (t_value >= 370 && t_value < 380)
406 return !IsInvalid(value_370[cast<uint01>(t_value - 370)]);
407 if (t_value == 420)
408 return !IsInvalid(420);
409 //999 Comment (string)
410 if (t_value == 999)
411 return value_999.size() != 0;
412 //1000-1009 String (255 characters maximum; less for Unicode strings
413 if (t_value >= 1000 && t_value < 1010)
414 return value_1000[t_value - 1000].size() != 0;
415 //1010-1059 Floating-point value
416 if (t_value >= 1010 && t_value < 1060)
417 return !IsInvalid(value_1010[cast<uint01>(t_value - 1010)]);
418 //1060-1070 16-bit integer value
419 if (t_value >= 1060 && t_value < 1070)
420 return !IsInvalid(value_1060[cast<uint01>(t_value - 1060)]);
421 //1071 32-bit integer value
422 if (t_value == 1071)
423 return !IsInvalid(value_1071);
424 lib_assert(false, "Unknown Index Value");
425 return false;
426 }
427
428
429 template <uint01 t_index, uint01 t_dims, class t_type>
431 {
432 static_assert(t_index < 10, "Bad Vector Index");
433 if (t_dims > 0)
434 setValue<t_index + 10>(value[0]);
435 if (t_dims > 1)
436 setValue<t_index + 20>(value[1]);
437 if (t_dims > 2)
438 setValue<t_index + 30>(value[2]);
439 if (t_dims > 3)
440 setValue<t_index + 40>(value[3]);
441 if (t_dims > 4)
442 setValue<t_index + 50>(value[4]);
443 if (t_dims > 5)
444 setValue<t_index + 60>(value[5]);
445 }
446
448
449
450 // NOTE: The below functions
451 // should only be used if
452 // the desired value is
453 // unknown at compile time
454 //-------------------------
455 // ----------------------------------------------------------------------------
456 // NOTE: This function should only be used if the desired value is unknown
457 // at compile time
458 // Returns the value of a given DXF index.
459 // See the member variables for values accepted by this class
460 // ----------------------------------------------------------------------------
461 template <class t_type>
462 [[nodiscard]] t_type getValue(uint04 value, const t_type& default_value) const
463 {
464 if (!hasValue(value))
465 return default_value;
466 //0-9 String (255 characters maximum; less for Unicode strings)
467 if (value < 5)
468 return value_0[value].getAs<t_type>();
469 if (value == 5)
470 return cast<t_type>(value_5);
471 if (value >= 6 && value < 10)
472 return value_6[value - 6].getAs<t_type>();
473 //10-59 Double precision 3D point
474 if (value >= 10 && value < 60)
475 return cast<t_type>(value_10[value - 10]);
476 //60-79 16-bit integer value
477 if (value >= 60 && value < 80)
478 return cast<t_type>(value_60[value - 60]);
479 //90-99 32-bit integer value
480 if (value >= 90 && value < 100)
481 return cast<t_type>(value_90[value - 90]);
482 //100 String (255 characters maximum; less for Unicode strings)
483 if (value == 100)
484 return value_100.getAs<t_type>();
485 //102 String (255 characters maximum; less for Unicode strings)
486 if (value == 102)
487 return value_102.getAs<t_type>();
488 //105 String representing hexadecimal (hex) handle value
489 if (value == 105)
490 return value_105.getAs<t_type>();
491 //140-147 Double precision scalar floating-point value
492 if (value >= 110 && value < 150)
493 return cast<t_type>(value_110[value - 110]);
494 if (value >= 160 && value < 170)
495 return cast<t_type>(value_160[value - 160]);
496 //170-175 16-bit integer value
497 if (value >= 170 && value < 180)
498 return cast<t_type>(value_170[value - 170]);
499 if (value == 210)
500 return cast<t_type>(value_210);
501 if (value == 220)
502 return cast<t_type>(value_220);
503 if (value == 230)
504 return cast<t_type>(value_230);
505 //280-289 8-bit integer value
506 if (value >= 280 && value < 290)
507 return cast<t_type>(value_280[value - 280]);
508 if (value >= 290 && value < 300)
509 return cast<t_type>(value_290[value - 290]);
510 //300-309 Arbitrary text string
511 if (value >= 300 && value < 310)
512 return value_300[value - 300].getAs<t_type>();
513 //310-319 String representing hex value of binary chunk
514 if (value >= 310 && value < 320)
515 return value_310[value - 310].getAs<t_type>();
516 //320-329 String representing hex handle value
517 if (value >= 320 && value < 330)
518 return value_320[value - 320].getAs<t_type>();
519 //330-369 String representing hex object IDs
520 if (value >= 330 && value < 370)
521 return cast<t_type>(value_330[value - 330]);
522 if (value >= 370 && value < 390)
523 return cast<t_type>(value_370[value - 370]);
524 if (value >= 390 && value < 400)
525 return value_390[value - 390].getAs<t_type>();
526 if (value >= 420 && value < 430)
527 return cast<t_type>(value_420[value - 420]);
528 //999 Comment (string)
529 if (value == 999)
530 return value_999.getAs<t_type>();
531 //1000-1009 String (255 characters maximum; less for Unicode strings
532 if (value >= 1000 && value < 1010)
533 return value_1000[value - 1000].getAs<t_type>();
534 //1010-1059 Floating-point value
535 if (value >= 1010 && value < 1060)
536 return cast<t_type>(value_1010[value - 1010]);
537 //1060-1070 16-bit integer value
538 if (value >= 1060 && value < 1070)
539 return cast<t_type>(value_1060[value - 1060]);
540 //1071 32-bit integer value
541 if (value == 1071)
542 return cast<t_type>(value_1071);
543 lib_assert(false, "Unknown Index Value");
544 return default_value;
545 }
546
547 void appendValue(String& s, uint04 value) const
548 {
549 //0-9 String (255 characters maximum; less for Unicode strings)
550 if (value < 5)
551 s.append(value_0[value]);
552 else if(value == 5)
553 s += String::toHex(value_5);
554 else if(value >= 6 && value < 10)
555 s.append(value_6[value - 6]);
556 //10-59 Double precision 3D point
557 else if (value >= 10 && value < 60)
558 NumberWriter::writeFloat(s, value_10[value - 10]);
559 //60-79 16-bit integer value
560 else if (value >= 60 && value < 80)
561 NumberWriter::writeInt(s, value_60[value - 60]);
562 //90-99 32-bit integer value
563 else if (value >= 90 && value < 100)
564 NumberWriter::writeInt(s, value_90[value - 90]);
565 //100 String (255 characters maximum; less for Unicode strings)
566 else if (value == 100)
567 s.append(value_100);
568 //102 String (255 characters maximum; less for Unicode strings)
569 else if (value == 102)
570 s.append(value_102);
571 //105 String representing hexadecimal (hex) handle value
572 else if (value == 105)
573 s.append(value_105);
574 //140-147 Double precision scalar floating-point value
575 else if (value >= 110 && value < 150)
576 NumberWriter::writeFloat(s, value_110[value - 110]);
577 else if (value >= 160 && value < 170)
578 NumberWriter::writeInt(s, value_160[value - 160]);
579 //170-175 16-bit integer value
580 else if (value >= 170 && value < 180)
581 NumberWriter::writeInt(s, value_170[value - 170]);
582 else if (value == 210)
583 NumberWriter::writeFloat(s, value_210);
584 else if (value == 220)
585 NumberWriter::writeFloat(s, value_220);
586 else if (value == 230)
587 NumberWriter::writeFloat(s, value_230);
588 //280-289 8-bit integer value
589 else if (value >= 280 && value < 290)
590 NumberWriter::writeInt(s, value_280[value - 280]);
591 else if (value >= 290 && value < 300)
592 NumberWriter::writeInt(s, value_290[value - 290]);
593 //300-309 Arbitrary text string
594 else if (value >= 300 && value < 310)
595 s.append(value_300[value - 300]);
596 //310-319 String representing hex value of binary chunk
597 else if (value >= 310 && value < 320)
598 s.append(value_310[value - 310]);
599 //320-329 String representing hex handle value
600 else if (value >= 320 && value < 330)
601 s.append(value_320[value - 320]);
602 //330-369 String representing hex object IDs
603 else if (value >= 330 && value < 370)
604 s += String::toHex(value_330[value - 330]);
605 else if (value >= 370 && value < 390)
606 NumberWriter::writeInt(s, value_370[value - 370]);
607 else if (value >= 390 && value < 400)
608 s.addAll(value_390[value - 390]);
609 else if (value >= 420 && value < 430)
610 NumberWriter::writeInt(s, value_420[value - 420]);
611 //999 Comment (string)
612 else if (value == 999)
613 s.append(value_999);
614 //1000-1009 String (255 characters maximum; less for Unicode strings
615 else if (value >= 1000 && value < 1010)
616 s.append(value_1000[value - 1000]);
617 //1010-1059 Floating-point value
618 else if (value >= 1010 && value < 1060)
619 NumberWriter::writeFloat(s, value_1010[value - 1010]);
620 //1060-1070 16-bit integer value
621 else if (value >= 1060 && value < 1070)
622 NumberWriter::writeInt(s, value_1060[value - 1060]);
623 //1071 32-bit integer value
624 else if (value == 1071)
625 NumberWriter::writeInt(s, value_1071);
626 else
627 lib_assert(false, "Unknown Index Value");
628 }
629 // ----------------------------------------------------------------------------
630 // NOTE: This function should only be used if the desired value is unknown
631 // at compile time
632 // Checks whether or not this value has been set by the file or in preperation
633 // for writing to the file.
634 // See the member variables for values accepted by this class
635 // ----------------------------------------------------------------------------
636 bool hasValue(uint04 value) const;
637 private:
638 //0-9 String (255 characters maximum; less for Unicode strings)
639 String value_0[5];
641 String value_6[4];
642 //10-59 Double precision 3D point
644 //60-79 16-bit integer value
646 //90-99 32-bit integer value
648 //100 String (255 characters maximum; less for Unicode strings)
649 String value_100;
650 //102 String (255 characters maximum; less for Unicode strings)
651 String value_102;
652 //String representing hexadecimal (hex) handle value
653 String value_105;
654 //
655 Vector<40, fltp08> value_110;//110-150
657 //170-175 16-bit integer value
659 //Extrusion direction (fixed)
663
664 //280-289 8-bit integer value
667 //300-309 Arbitrary text string
668 String value_300[10];
669 //310-319 String representing hex value of binary chunk
670 String value_310[10];
671 //320-329 String representing hex handle value
672 String value_320[10];
673 //330-369 String representing hex object IDs
674 Vector<40, uint04> value_330;
675 //Lineweight enum value (AcDb::LineWeight). Stored and moved around as a short.
676 //Custom non-entity objects may use the full range, but entity classes only use 371-379 DXF group codes in their representation,
677 //because AutoCAD and AutoLISP both always assume a 370 group code is the entity's lineweight.
678 //This allows 370 to behave like other "common" entity fields.
680 //0-9 String (255 characters maximum; less for Unicode strings)
681
682 //String representing hex handle value
683 String value_390[10];
684 Vector<10, sint04> value_420;
685 //999 Comment (string)
686 String value_999;
687 //1000-1009 String (255 characters maximum; less for Unicode strings)
688 String value_1000[10];
689 //1010-1059 Floating-point value
691 //1060-1070 16-bit integer value
693
694 //1071 32-bit integer value
696
697 bool m_use_active_value_set = false;
698 Set<uint04> m_active_value_set;
699 };
700}
701
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:68
Logic for reading or writing to a binary file including logic for.
Definition BinaryFile.h:59
constexpr t_index_type size() const
Definition Buffer.hpp:1374
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:276
Definition DXFValueManager.h:42
bool usingActiveValueSet() const
Definition DXFValueManager.h:73
const Set< uint04 > & getValuesSet() const
Definition DXFValueManager.h:81
bool appendValue(const t_type &value)
Definition DXFValueManager.h:182
Vector< 2, fltp08 > getVector2(const fltp08 &bad_value) const
Definition DXFValueManager.h:63
bool hasValue(uint04 value) const
Vector< 1, fltp08 > getVector1(const fltp08 &bad_value) const
Definition DXFValueManager.h:57
bool setValue(const t_type &value)
Definition DXFValueManager.h:87
t_type getValue(uint04 value, const t_type &default_value) const
Definition DXFValueManager.h:462
void setUseActiveValueSet(bool use_active_value_set)
Definition DXFValueManager.h:77
bool hasValue() const
Definition DXFValueManager.h:336
bool appendValue(uint04 location, const String &value)
Vector< 3, fltp08 > getVector3(const fltp08 &bad_value) const
Definition DXFValueManager.h:69
bool setValue(uint04 location, BinaryFile &file)
t_type getValue(const t_type &default_value) const
Definition DXFValueManager.h:228
void appendValue(String &s, uint04 value) const
Definition DXFValueManager.h:547
bool setValue(uint04 location, Scanner &scan)
bool setValue(uint04 location, const String &value)
void setVector(const Vector< t_dims, t_type > &value)
Definition DXFValueManager.h:430
DXFValueManager()
Definition DXFValueManager.h:44
static void writeFloat(String &string, fltp08 value, flt_to_string mode=DTOSTR_NORMAL, uint01 precision=10)
Definition NumberWriter.h:350
static constexpr void writeInt(String &string, t_type initial_value)
Definition NumberWriter.h:276
Contains methods for easily reading objects in an ascii stream.
Definition Scanner.h:45
Container that stores unique elements in no particular order, and which allow for fast retrieval.
Definition Model.h:51
The core String class for the software.
Definition String.h:47
NDEVR_BASE_API String & append(const String &string)
t_type getAs() const
Definition String.h:341
static NDEVR_BASE_API String toHex(uint01 value)
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Definition ACIColor.h:37
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:62
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:177
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:94
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:379
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved.
Definition BaseValues.hpp:230