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;
41 /**--------------------------------------------------------------------------------------------------
42 \brief DXF streams store data in a large numbered index structure. This class optimally stores this
43 data so that it can be used to created entities at the right time.
44 **/
46 {
47 public:
49 // ----------------------------------------------------------------------------
50 // Sets the value of a given DXF index.
51 // See the member variables for values accepted by this class
52 // returns false if this class is unable to store the value and true if the
53 // value was successfully stored. Overrides old value, if it exists.
54 // ----------------------------------------------------------------------------
55 bool setValue(uint04 location, const String& value);
56 bool setValue(uint04 location, Scanner& scan);
57 bool setValue(uint04 location, BinaryFile& file);
58 bool appendValue(uint04 location, const String& value);
59
60 template <uint01 t_index>
61 [[nodiscard]] Vector<1, fltp08> getVector1(const fltp08& bad_value) const
62 {
64 }
65
66 template <uint01 t_index>
67 [[nodiscard]] Vector<2, fltp08> getVector2(const fltp08& bad_value) const
68 {
70 }
71
72 template <uint01 t_index>
73 [[nodiscard]] Vector<3, fltp08> getVector3(const fltp08& bad_value) const
74 {
76 }
78 {
79 return m_use_active_value_set;
80 }
81 void setUseActiveValueSet(bool use_active_value_set)
82 {
83 m_use_active_value_set = use_active_value_set;
84 }
86 {
87 return m_active_value_set;
88 }
89
90 template<uint04 t_value, class t_type>
91 bool setValue(const t_type& value)
92 {
93 if (m_use_active_value_set)
94 m_active_value_set.insert(t_value);
95 static_assert(
96 (t_value < 10) || (t_value >= 10 && t_value < 60) || (t_value >= 60 && t_value < 80)
97 || (t_value >= 90 && t_value < 100) || (t_value == 100) || (t_value == 102)
98 || (t_value == 105) || (t_value >= 110 && t_value < 150) || (t_value >= 160 && t_value < 170)
99 || (t_value >= 170 && t_value < 176) || (t_value == 210) || (t_value == 220) || (t_value == 230)
100 || (t_value >= 280 && t_value < 290) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
101 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value >= 370 && t_value < 380)
102 || (t_value == 420) || (t_value == 999) || (t_value >= 1000 && t_value < 1010)
103 || (t_value >= 1010 && t_value < 1060) || (t_value >= 1060 && t_value < 1070) || (t_value == 1071)
104 , "Unknown Value Type");
105 //0-9 String (255 characters maximum; less for Unicode strings)
106 if (t_value < 5)
107 value_0[t_value] = String(value);
108 else if (t_value == 5)
109 value_5 = cast<uint04>(value);
110 else if (t_value >= 6 && t_value < 10)
111 value_6[t_value - 6] = String(value);
112 //10-59 Double precision 3D point
113 else if (t_value >= 10 && t_value < 60)
114 value_10[cast<uint01>(t_value - 10)] = cast<fltp08>(value);
115 //60-79 16-bit integer value
116 else if (t_value >= 60 && t_value < 80)
117 value_60[cast<uint01>(t_value - 60)] = cast<sint02>(value);
118 //90-99 32-bit integer value
119 else if (t_value >= 90 && t_value < 100)
120 value_90[cast<uint01>(t_value - 90)] = cast<sint04>(value);
121 //100 String (255 characters maximum; less for Unicode strings)
122 else if (t_value == 100)
123 value_100 = String(value);
124 //102 String (255 characters maximum; less for Unicode strings)
125 else if (t_value == 102)
126 value_102 = String(value);
127 //105 String representing hexadecimal (hex) handle value
128 else if (t_value == 105)
129 value_105 = String(value);
130 //140-147 Double precision scalar floating-point value
131 else if (t_value >= 110 && t_value < 150)
132 value_110[cast<uint01>(t_value - 110)] = cast<fltp08>(value);
133 else if (t_value >= 160 && t_value < 170)
134 value_160[cast<uint01>(t_value - 160)] = cast<sint08>(value);
135 //170-175 16-bit integer value
136 else if (t_value >= 170 && t_value < 180)
137 value_170[cast<uint01>(t_value - 170)] = cast<sint02>(value);
138 //Extrusion direction (fixed)
139 else if (t_value == 210)
140 value_210 = cast<fltp08>(value);
141 else if (t_value == 220)
142 value_220 = cast<fltp08>(value);
143 else if (t_value == 230)
144 value_230 = cast<fltp08>(value);
145 //280-289 8-bit integer value
146 else if (t_value >= 280 && t_value < 290)
147 value_280[cast<uint01>(t_value - 280)] = cast<sint02>(value);
148 else if (t_value >= 290 && t_value < 300)
149 value_290[cast<uint01>(t_value - 290)] = cast<uint01>(value);
150 //300-309 Arbitrary text string
151 else if (t_value >= 300 && t_value < 310)
152 value_300[t_value - 300] = String(value);
153 //310-319 String representing hex value of binary chunk
154 else if (t_value >= 310 && t_value < 320)
155 value_310[t_value - 310] = String(value);
156 //320-329 String representing hex handle value
157 else if (t_value >= 320 && t_value < 330)
158 value_320[t_value - 320] = String(value);
159 //330-369 String representing hex object IDs
160 else if (t_value >= 330 && t_value < 370)
161 value_330[t_value - 330] = cast<uint04>(value);
162 else if (t_value >= 370 && t_value < 380)
163 value_370[cast<uint01>(t_value - 370)] = cast<sint02>(value);
164 else if (t_value >= 420 && t_value < 430)
165 value_420[t_value - 420] = cast<sint04>(value);
166 //999 Comment (string)
167 else if (t_value == 999)
168 value_999 = String(value);
169 //1000-1009 String (255 characters maximum; less for Unicode strings)
170 else if (t_value >= 1000 && t_value < 1010)
171 value_1000[t_value - 1000] = String(value);
172 //1010-1059 float value
173 else if (t_value >= 1010 && t_value < 1060)
174 value_1010[cast<uint01>(t_value - 1010)] = cast<fltp04>(value);
175 //1060-1070 16-bit integer value
176 else if (t_value >= 1060 && t_value < 1070)
177 value_1060[cast<uint01>(t_value - 1060)] = cast<sint02>(value);
178 //1071 32-bit integer value
179 else if (t_value == 1071)
180 value_1071 = cast<sint04>(value);
181 else
182 return false;
183 return true;
184 }
185 template<uint04 t_value, class t_type>
186 bool appendValue(const t_type& value)
187 {
188 if (m_use_active_value_set)
189 m_active_value_set.insert(t_value);
190 static_assert(
191 (t_value < 10) || (t_value == 100) || (t_value == 102)
192 || (t_value == 105) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
193 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value == 999)
194 || (t_value >= 1000 && t_value < 1010)
195 , "Unknown Value Type");
196 //0-9 String (255 characters maximum; less for Unicode strings)
197 if (t_value < 5)
198 value_0[t_value] += String(value);
199 else if (t_value >= 6 && t_value < 10)
200 value_6[t_value - 6] += String(value);
201 else if (t_value == 100)
202 value_100 += String(value);
203 //102 String (255 characters maximum; less for Unicode strings)
204 else if (t_value == 102)
205 value_102 += String(value);
206 //105 String representing hexadecimal (hex) handle value
207 else if (t_value == 105)
208 value_105 += String(value);
209 else if (t_value >= 300 && t_value < 310)
210 value_300[t_value - 300] += String(value);
211 //310-319 String representing hex value of binary chunk
212 else if (t_value >= 310 && t_value < 320)
213 value_310[t_value - 310] += String(value);
214 //320-329 String representing hex handle value
215 else if (t_value >= 320 && t_value < 330)
216 value_320[t_value - 320] += String(value);
217 //330-369 String representing hex object IDs
218 else if (t_value == 999)
219 value_999 += String(value);
220 //1000-1009 String (255 characters maximum; less for Unicode strings)
221 else if (t_value >= 1000 && t_value < 1010)
222 value_1000[t_value - 1000] += String(value);
223 else
224 return false;
225 return true;
226 }
227 // ----------------------------------------------------------------------------
228 // Sets the value of a given DXF index.
229 // See the member variables for values accepted by this class
230 // ----------------------------------------------------------------------------
231 template<uint04 t_value, class t_type>
232 [[nodiscard]] t_type getValue(const t_type& default_value) const
233 {
234 static_assert(
235 (t_value < 10) || (t_value >= 10 && t_value < 60) || (t_value >= 60 && t_value < 80)
236 || (t_value >= 90 && t_value < 100) || (t_value == 100) || (t_value == 102)
237 || (t_value == 105) || (t_value >= 110 && t_value < 150) || (t_value >= 160 && t_value < 170)
238 || (t_value >= 170 && t_value < 176) || (t_value == 210) || (t_value == 220) || (t_value == 230)
239 || (t_value >= 280 && t_value < 290) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
240 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value >= 370 && t_value < 380)
241 || (t_value == 420) || (t_value == 999) || (t_value >= 1000 && t_value < 1010)
242 || (t_value >= 1010 && t_value < 1060) || (t_value >= 1060 && t_value < 1070) || (t_value == 1071)
243 , "Unknown Value Type");
244 if (!hasValue<t_value>())
245 return default_value;
246#if _MSC_VER
247#pragma warning (disable: 4800) //forcing value to bool (Performance warning)
248#pragma warning (disable: 26454)
249#endif
250 //0-9 String (255 characters maximum; less for Unicode strings)
251 if (t_value < 5)
252 return value_0[t_value].getAs<t_type>();
253 if (t_value == 5)
254 return cast<t_type>(value_5);
255 if (t_value >= 6 && t_value < 10)
256 return value_6[t_value - 6].getAs<t_type>();
257 //10-59 Double precision 3D point
258 if (t_value >= 10 && t_value < 60)
259 return cast<t_type>(value_10[cast<uint01>(t_value - 10)]);
260 //60-79 16-bit integer value
261 if (t_value >= 60 && t_value < 80)
262 return cast<t_type>(value_60[cast<uint01>(t_value - 60)]);
263 //90-99 32-bit integer value
264 if (t_value >= 90 && t_value < 100)
265 return cast<t_type>(value_90[cast<uint01>(t_value - 90)]);
266 //100 String (255 characters maximum; less for Unicode strings)
267 if (t_value == 100)
268 return value_100.getAs<t_type>();
269 //102 String (255 characters maximum; less for Unicode strings)
270 if (t_value == 102)
271 return value_102.getAs<t_type>();
272 //105 String representing hexadecimal (hex) handle value
273 if (t_value == 105)
274 return value_105.getAs<t_type>();
275 //140-147 Double precision scalar floating-point value
276 if (t_value >= 110 && t_value < 150)
277 return cast<t_type>(value_110[cast<uint01>(t_value - 110)]);
278 if (t_value >= 160 && t_value < 170)
279 return cast<t_type>(value_160[cast<uint01>(t_value - 160)]);
280 //170-175 16-bit integer value
281 if (t_value >= 170 && t_value < 180)
282 return cast<t_type>(value_170[cast<uint01>(t_value - 170)]);
283 //Extrusion direction (fixed)
284 if (t_value == 210)
285 return cast<t_type>(value_210);
286 if (t_value == 220)
287 return cast<t_type>(value_220);
288 if (t_value == 230)
289 return cast<t_type>(value_230);
290 //280-289 8-bit integer value
291 if (t_value >= 280 && t_value < 290)
292 return cast<t_type>(value_280[cast<uint01>(t_value - 280)]);
293 if (t_value >= 290 && t_value < 300)
294 return cast<t_type>(value_290[cast<uint01>(t_value - 290)]);
295 //300-309 Arbitrary text string
296 if (t_value >= 300 && t_value < 310)
297 return value_300[t_value - 300].getAs<t_type>();
298 //310-319 String representing hex value of binary chunk
299 if (t_value >= 310 && t_value < 320)
300 return value_310[t_value - 310].getAs<t_type>();
301 //320-329 String representing hex handle value
302 if (t_value >= 320 && t_value < 330)
303 return value_320[t_value - 320].getAs<t_type>();
304
305 //330-369 String representing hex object IDs
306 if (t_value >= 330 && t_value < 370)
307 return cast<t_type>(value_330[cast<uint01>(t_value - 330)]);
308 if (t_value >= 370 && t_value < 380)
309 return cast<t_type>(value_370[cast<uint01>(t_value - 370)]);
310 if (t_value >= 420 && t_value < 430)
311 return cast<t_type>(value_420[cast<uint01>(t_value - 420)]);
312 //999 Comment (string)
313 if (t_value == 999)
314 return value_999.getAs<t_type>();
315 //1000-1009 String (255 characters maximum; less for Unicode strings
316 if (t_value >= 1000 && t_value < 1010)
317 return value_1000[t_value - 1000].getAs<t_type>();
318 //1010-1059 Floating-point value
319 if (t_value >= 1010 && t_value < 1060)
320 return cast<t_type>(value_1010[cast<uint01>(t_value - 1010)]);
321 //1060-1070 16-bit integer value
322 if (t_value >= 1060 && t_value < 1070)
323 return cast<t_type>(value_1060[cast<uint01>(t_value - 1060)]);
324 //1071 32-bit integer value
325 if (t_value == 1071)
326 return cast<t_type>(value_1071);
327 lib_assert(false, "Unknown Index Value");
328 return default_value;
329#if _MSC_VER
330#pragma warning (default: 4800) //forcing value to bool (Performance warning)
331#pragma warning (default: 26454)
332#endif
333 }
334 // ----------------------------------------------------------------------------
335 // Checks whether or not this value has been set by the file or in preperation
336 // for writing to the file.
337 // See the member variables for values accepted by this class
338 // ----------------------------------------------------------------------------
339 template <uint04 t_value>
340 [[nodiscard]] bool hasValue() const
341 {
342 static_assert(
343 (t_value < 10) || (t_value >= 10 && t_value < 60) || (t_value >= 60 && t_value < 80)
344 || (t_value >= 90 && t_value < 100) || (t_value == 100) || (t_value == 102)
345 || (t_value == 105) || (t_value >= 110 && t_value < 150) || (t_value >= 160 && t_value < 170)
346 || (t_value >= 170 && t_value < 176) || (t_value == 210) || (t_value == 220) || (t_value == 230)
347 || (t_value >= 280 && t_value < 290) || (t_value >= 300 && t_value < 310) || (t_value >= 310 && t_value < 320)
348 || (t_value >= 320 && t_value < 330) || (t_value >= 330 && t_value < 370) || (t_value >= 370 && t_value < 380)
349 || (t_value == 420) || (t_value == 999) || (t_value >= 1000 && t_value < 1010)
350 || (t_value >= 1010 && t_value < 1060) || (t_value >= 1060 && t_value < 1070) || (t_value == 1071)
351 , "Unknown Value Type");
352 //0-9 String (255 characters maximum; less for Unicode strings)
353 if (t_value < 5)
354 return value_0[t_value].size() != 0;
355 if (t_value == 5)
356 return !IsInvalid(value_5);
357 if (t_value >= 6 && t_value < 10)
358 return value_6[t_value - 6].size() != 0;
359 //10-59 Double precision 3D point
360 if (t_value >= 10 && t_value < 60)
361 return !IsInvalid(value_10[cast<uint01>(t_value - 10)]);
362 //60-79 16-bit integer value
363 if (t_value >= 60 && t_value < 80)
364 return !IsInvalid(value_60[cast<uint01>(t_value - 60)]);
365 //90-99 32-bit integer value
366 if (t_value >= 90 && t_value < 100)
367 return !IsInvalid(value_90[cast<uint01>(t_value - 90)]);
368 //100 String (255 characters maximum; less for Unicode strings)
369 if (t_value == 100)
370 return value_100.size() != 0;
371 //102 String (255 characters maximum; less for Unicode strings)
372 if (t_value == 102)
373 return value_102.size() != 0;
374 //105 String representing hexadecimal (hex) handle value
375 if (t_value == 105)
376 return value_105.size() != 0;
377 //140-147 Double precision scalar floating-point value
378 if (t_value >= 110 && t_value < 150)
379 return !IsInvalid(value_110[cast<uint01>(t_value - 110)]);
380 if (t_value >= 160 && t_value < 170)
381 return !IsInvalid(value_160[cast<uint01>(t_value - 160)]);
382 //170-175 16-bit integer value
383 if (t_value >= 170 && t_value < 180)
384 return !IsInvalid(value_170[cast<uint01>(t_value - 170)]);
385 //Extrusion direction (fixed)
386 if (t_value == 210)
387 return !IsInvalid(value_210);
388 if (t_value == 220)
389 return !IsInvalid(value_220);
390 if (t_value == 230)
391 return !IsInvalid(value_230);
392 //280-289 8-bit integer value
393 if (t_value >= 280 && t_value < 290)
394 return !IsInvalid(value_280[cast<uint01>(t_value - 280)]);
395 if (t_value >= 290 && t_value < 300)
396 return !IsInvalid(value_290[cast<uint01>(t_value - 290)]);
397 //300-309 Arbitrary text string
398 if (t_value >= 300 && t_value < 310)
399 return value_300[t_value - 300].size() != 0;
400 //310-319 String representing hex value of binary chunk
401 if (t_value >= 310 && t_value < 320)
402 return value_310[t_value - 310].size() != 0;
403 //320-329 String representing hex handle value
404 if (t_value >= 320 && t_value < 330)
405 return value_320[t_value - 320].size() != 0;
406 //330-369 String representing hex object IDs
407 if (t_value >= 330 && t_value < 370)
408 return !IsInvalid(value_330[cast<uint01>(t_value - 330)]);
409 if (t_value >= 370 && t_value < 380)
410 return !IsInvalid(value_370[cast<uint01>(t_value - 370)]);
411 if (t_value == 420)
412 return !IsInvalid(420);
413 //999 Comment (string)
414 if (t_value == 999)
415 return value_999.size() != 0;
416 //1000-1009 String (255 characters maximum; less for Unicode strings
417 if (t_value >= 1000 && t_value < 1010)
418 return value_1000[t_value - 1000].size() != 0;
419 //1010-1059 Floating-point value
420 if (t_value >= 1010 && t_value < 1060)
421 return !IsInvalid(value_1010[cast<uint01>(t_value - 1010)]);
422 //1060-1070 16-bit integer value
423 if (t_value >= 1060 && t_value < 1070)
424 return !IsInvalid(value_1060[cast<uint01>(t_value - 1060)]);
425 //1071 32-bit integer value
426 if (t_value == 1071)
427 return !IsInvalid(value_1071);
428 lib_assert(false, "Unknown Index Value");
429 return false;
430 }
431
432
433 template <uint01 t_index, uint01 t_dims, class t_type>
435 {
436 static_assert(t_index < 10, "Bad Vector Index");
437 if (t_dims > 0)
438 setValue<t_index + 10>(value[0]);
439 if (t_dims > 1)
440 setValue<t_index + 20>(value[1]);
441 if (t_dims > 2)
442 setValue<t_index + 30>(value[2]);
443 if (t_dims > 3)
444 setValue<t_index + 40>(value[3]);
445 if (t_dims > 4)
446 setValue<t_index + 50>(value[4]);
447 if (t_dims > 5)
448 setValue<t_index + 60>(value[5]);
449 }
450
452
453
454 // NOTE: The below functions
455 // should only be used if
456 // the desired value is
457 // unknown at compile time
458 //-------------------------
459 // ----------------------------------------------------------------------------
460 // NOTE: This function should only be used if the desired value is unknown
461 // at compile time
462 // Returns the value of a given DXF index.
463 // See the member variables for values accepted by this class
464 // ----------------------------------------------------------------------------
465 template <class t_type>
466 [[nodiscard]] t_type getValue(uint04 value, const t_type& default_value) const
467 {
468 if (!hasValue(value))
469 return default_value;
470 //0-9 String (255 characters maximum; less for Unicode strings)
471 if (value < 5)
472 return value_0[value].getAs<t_type>();
473 if (value == 5)
474 return cast<t_type>(value_5);
475 if (value >= 6 && value < 10)
476 return value_6[value - 6].getAs<t_type>();
477 //10-59 Double precision 3D point
478 if (value >= 10 && value < 60)
479 return cast<t_type>(value_10[value - 10]);
480 //60-79 16-bit integer value
481 if (value >= 60 && value < 80)
482 return cast<t_type>(value_60[value - 60]);
483 //90-99 32-bit integer value
484 if (value >= 90 && value < 100)
485 return cast<t_type>(value_90[value - 90]);
486 //100 String (255 characters maximum; less for Unicode strings)
487 if (value == 100)
488 return value_100.getAs<t_type>();
489 //102 String (255 characters maximum; less for Unicode strings)
490 if (value == 102)
491 return value_102.getAs<t_type>();
492 //105 String representing hexadecimal (hex) handle value
493 if (value == 105)
494 return value_105.getAs<t_type>();
495 //140-147 Double precision scalar floating-point value
496 if (value >= 110 && value < 150)
497 return cast<t_type>(value_110[value - 110]);
498 if (value >= 160 && value < 170)
499 return cast<t_type>(value_160[value - 160]);
500 //170-175 16-bit integer value
501 if (value >= 170 && value < 180)
502 return cast<t_type>(value_170[value - 170]);
503 if (value == 210)
504 return cast<t_type>(value_210);
505 if (value == 220)
506 return cast<t_type>(value_220);
507 if (value == 230)
508 return cast<t_type>(value_230);
509 //280-289 8-bit integer value
510 if (value >= 280 && value < 290)
511 return cast<t_type>(value_280[value - 280]);
512 if (value >= 290 && value < 300)
513 return cast<t_type>(value_290[value - 290]);
514 //300-309 Arbitrary text string
515 if (value >= 300 && value < 310)
516 return value_300[value - 300].getAs<t_type>();
517 //310-319 String representing hex value of binary chunk
518 if (value >= 310 && value < 320)
519 return value_310[value - 310].getAs<t_type>();
520 //320-329 String representing hex handle value
521 if (value >= 320 && value < 330)
522 return value_320[value - 320].getAs<t_type>();
523 //330-369 String representing hex object IDs
524 if (value >= 330 && value < 370)
525 return cast<t_type>(value_330[value - 330]);
526 if (value >= 370 && value < 390)
527 return cast<t_type>(value_370[value - 370]);
528 if (value >= 390 && value < 400)
529 return value_390[value - 390].getAs<t_type>();
530 if (value >= 420 && value < 430)
531 return cast<t_type>(value_420[value - 420]);
532 //999 Comment (string)
533 if (value == 999)
534 return value_999.getAs<t_type>();
535 //1000-1009 String (255 characters maximum; less for Unicode strings
536 if (value >= 1000 && value < 1010)
537 return value_1000[value - 1000].getAs<t_type>();
538 //1010-1059 Floating-point value
539 if (value >= 1010 && value < 1060)
540 return cast<t_type>(value_1010[value - 1010]);
541 //1060-1070 16-bit integer value
542 if (value >= 1060 && value < 1070)
543 return cast<t_type>(value_1060[value - 1060]);
544 //1071 32-bit integer value
545 if (value == 1071)
546 return cast<t_type>(value_1071);
547 lib_assert(false, "Unknown Index Value");
548 return default_value;
549 }
550
551 void appendValue(String& s, uint04 value) const
552 {
553 //0-9 String (255 characters maximum; less for Unicode strings)
554 if (value < 5)
555 s.append(value_0[value]);
556 else if(value == 5)
557 s += String::ToHex(value_5);
558 else if(value >= 6 && value < 10)
559 s.append(value_6[value - 6]);
560 //10-59 Double precision 3D point
561 else if (value >= 10 && value < 60)
562 NumberWriter::writeFloat(s, value_10[value - 10]);
563 //60-79 16-bit integer value
564 else if (value >= 60 && value < 80)
565 NumberWriter::writeInt(s, value_60[value - 60]);
566 //90-99 32-bit integer value
567 else if (value >= 90 && value < 100)
568 NumberWriter::writeInt(s, value_90[value - 90]);
569 //100 String (255 characters maximum; less for Unicode strings)
570 else if (value == 100)
571 s.append(value_100);
572 //102 String (255 characters maximum; less for Unicode strings)
573 else if (value == 102)
574 s.append(value_102);
575 //105 String representing hexadecimal (hex) handle value
576 else if (value == 105)
577 s.append(value_105);
578 //140-147 Double precision scalar floating-point value
579 else if (value >= 110 && value < 150)
580 NumberWriter::writeFloat(s, value_110[value - 110]);
581 else if (value >= 160 && value < 170)
582 NumberWriter::writeInt(s, value_160[value - 160]);
583 //170-175 16-bit integer value
584 else if (value >= 170 && value < 180)
585 NumberWriter::writeInt(s, value_170[value - 170]);
586 else if (value == 210)
587 NumberWriter::writeFloat(s, value_210);
588 else if (value == 220)
589 NumberWriter::writeFloat(s, value_220);
590 else if (value == 230)
591 NumberWriter::writeFloat(s, value_230);
592 //280-289 8-bit integer value
593 else if (value >= 280 && value < 290)
594 NumberWriter::writeInt(s, value_280[value - 280]);
595 else if (value >= 290 && value < 300)
596 NumberWriter::writeInt(s, value_290[value - 290]);
597 //300-309 Arbitrary text string
598 else if (value >= 300 && value < 310)
599 s.append(value_300[value - 300]);
600 //310-319 String representing hex value of binary chunk
601 else if (value >= 310 && value < 320)
602 s.append(value_310[value - 310]);
603 //320-329 String representing hex handle value
604 else if (value >= 320 && value < 330)
605 s.append(value_320[value - 320]);
606 //330-369 String representing hex object IDs
607 else if (value >= 330 && value < 370)
608 s += String::ToHex(value_330[value - 330]);
609 else if (value >= 370 && value < 390)
610 NumberWriter::writeInt(s, value_370[value - 370]);
611 else if (value >= 390 && value < 400)
612 s.addAll(value_390[value - 390]);
613 else if (value >= 420 && value < 430)
614 NumberWriter::writeInt(s, value_420[value - 420]);
615 //999 Comment (string)
616 else if (value == 999)
617 s.append(value_999);
618 //1000-1009 String (255 characters maximum; less for Unicode strings
619 else if (value >= 1000 && value < 1010)
620 s.append(value_1000[value - 1000]);
621 //1010-1059 Floating-point value
622 else if (value >= 1010 && value < 1060)
623 NumberWriter::writeFloat(s, value_1010[value - 1010]);
624 //1060-1070 16-bit integer value
625 else if (value >= 1060 && value < 1070)
626 NumberWriter::writeInt(s, value_1060[value - 1060]);
627 //1071 32-bit integer value
628 else if (value == 1071)
629 NumberWriter::writeInt(s, value_1071);
630 else
631 lib_assert(false, "Unknown Index Value");
632 }
633 // ----------------------------------------------------------------------------
634 // NOTE: This function should only be used if the desired value is unknown
635 // at compile time
636 // Checks whether or not this value has been set by the file or in preperation
637 // for writing to the file.
638 // See the member variables for values accepted by this class
639 // ----------------------------------------------------------------------------
640 bool hasValue(uint04 value) const;
641 private:
642 //0-9 String (255 characters maximum; less for Unicode strings)
643 String value_0[5];
645 String value_6[4];
646 //10-59 Double precision 3D point
648 //60-79 16-bit integer value
650 //90-99 32-bit integer value
652 //100 String (255 characters maximum; less for Unicode strings)
653 String value_100;
654 //102 String (255 characters maximum; less for Unicode strings)
655 String value_102;
656 //String representing hexadecimal (hex) handle value
657 String value_105;
658 //
659 Vector<40, fltp08> value_110;//110-150
661 //170-175 16-bit integer value
663 //Extrusion direction (fixed)
667
668 //280-289 8-bit integer value
671 //300-309 Arbitrary text string
672 String value_300[10];
673 //310-319 String representing hex value of binary chunk
674 String value_310[10];
675 //320-329 String representing hex handle value
676 String value_320[10];
677 //330-369 String representing hex object IDs
678 Vector<40, uint04> value_330;
679 //Lineweight enum value (AcDb::LineWeight). Stored and moved around as a short.
680 //Custom non-entity objects may use the full range, but entity classes only use 371-379 DXF group codes in their representation,
681 //because AutoCAD and AutoLISP both always assume a 370 group code is the entity's lineweight.
682 //This allows 370 to behave like other "common" entity fields.
684 //0-9 String (255 characters maximum; less for Unicode strings)
685
686 //String representing hex handle value
687 String value_390[10];
688 Vector<10, sint04> value_420;
689 //999 Comment (string)
690 String value_999;
691 //1000-1009 String (255 characters maximum; less for Unicode strings)
692 String value_1000[10];
693 //1010-1059 Floating-point value
695 //1060-1070 16-bit integer value
697
698 //1071 32-bit integer value
700
701 bool m_use_active_value_set = false;
702 Set<uint04> m_active_value_set;
703 };
704}
705
#define lib_assert(expression, message)
Definition LibAssert.h:61
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:823
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:243
DXF streams store data in a large numbered index structure. This class optimally stores this data so ...
Definition DXFValueManager.h:46
bool usingActiveValueSet() const
Definition DXFValueManager.h:77
const Set< uint04 > & getValuesSet() const
Definition DXFValueManager.h:85
bool appendValue(const t_type &value)
Definition DXFValueManager.h:186
Vector< 2, fltp08 > getVector2(const fltp08 &bad_value) const
Definition DXFValueManager.h:67
bool hasValue(uint04 value) const
Vector< 1, fltp08 > getVector1(const fltp08 &bad_value) const
Definition DXFValueManager.h:61
bool setValue(const t_type &value)
Definition DXFValueManager.h:91
t_type getValue(uint04 value, const t_type &default_value) const
Definition DXFValueManager.h:466
void setUseActiveValueSet(bool use_active_value_set)
Definition DXFValueManager.h:81
bool hasValue() const
Definition DXFValueManager.h:340
bool appendValue(uint04 location, const String &value)
Vector< 3, fltp08 > getVector3(const fltp08 &bad_value) const
Definition DXFValueManager.h:73
bool setValue(uint04 location, BinaryFile &file)
t_type getValue(const t_type &default_value) const
Definition DXFValueManager.h:232
void appendValue(String &s, uint04 value) const
Definition DXFValueManager.h:551
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:434
DXFValueManager()
Definition DXFValueManager.h:48
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 or i...
Definition Model.h:51
The core String class for the NDEVR API.
Definition String.h:69
t_type getAs() const
Converts a string into an object. To use this function an object must have overwritten StringStream<t...
Definition String.h:143
static String ToHex(uint01 value)
Converts the memory of the given object into a hexidecimal string.
String & append(const String &string)
Appends a string to the back of this string.
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:64
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:170
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233