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