This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
opennurbs_archive.h
5758 lines (5039 loc) · 179 KB
/
opennurbs_archive.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
//
// Copyright (c) 1993-2016 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
*/
#if !defined(ON_ARCHIVE_INC_)
#define ON_ARCHIVE_INC_
/////////////////////////////////////////////////////////////////////
//
// ON_Buffer
//
typedef void (*ON_Buffer_ErrorHandler)(class ON_Buffer*);
class ON_CLASS ON_Buffer
{
public:
ON_Buffer();
~ON_Buffer();
ON_Buffer(const ON_Buffer& src);
ON_Buffer& operator=(const ON_Buffer& src);
/*
Description:
Compare contents of buffers.
Paramters:
a - [in]
b - [in]
Returns:
-1: a < b
0: a == b
1: a > b
*/
static int Compare( const ON_Buffer& a, const ON_Buffer& b );
void Destroy();
void EmergencyDestroy();
/*
Returns:
True if Size() == CurrentPosition().
Remarks:
It is possible to seek beyond the end of the buffer.
In this case, the current position will be past the end
of the buffer and AtEnd() will return false.
*/
bool AtEnd() const;
/*
Returns:
Number of bytes currently in the buffer.
Remarks:
It is possible to seek beyond the end of the buffer.
In this case, the current position will be past the end
of the buffer and CurrentPosition() will be greater than
Size().
*/
ON__UINT64 Size() const;
/*
Returns:
32-bit CRC of the buffer contents.
Remarks:
*/
ON__UINT32 CRC32( ON__UINT32 current_remainder ) const;
/*
Returns:
Current position in the buffer.
Remarks:
It is possible to seek beyond the end of the buffer.
In this case, the current position will be past the end
of the buffer and CurrentPosition() will be greater than
Size().
*/
ON__UINT64 CurrentPosition() const;
/*
Parameters:
size - [in]
number of bytes to write.
buffer - [in]
values to write.
Returns:
Number of bytes written buffer.
*/
ON__UINT64 Write( ON__UINT64 size, const void* buffer );
/*
Parameters:
size - [in]
number of bytes to read.
buffer - [out]
read values are returned in buffer.
Returns:
Number of bytes read into buffer. For example,
if CurrentPosition() <= Size() and
size > (Size() - CurrentPosition()) and
buffer is not null, then the value
(Size() - CurrentPosition()) is returned.
Remarks:
If the size parameter is zero, then nothing is done.
When CurrentPosition() <= Size(), attempts to read more
than (Size() - CurrentPosition()) bytes do not generate
an error. When CurrentPosition() > Size(), any attempt
to read generates an error.
*/
ON__UINT64 Read( ON__UINT64 size, void* buffer );
enum
{
seek_from_beginning_of_file = 0,
seek_from_current_position = 1,
seek_from_end_of_file = 2
};
/*
Parameters:
offset - [in]
number of bytes to seek from origin
origin - [in]
initial position.
0 (SEEK_SET) Seek from beginning of file.
1 (SEEK_CUR) Seek from current position.
2 (SEEK_END) Seek from end of file.
Returns:
True if successful.
False if the seek would result in a file position
before the beginning of the file. If false is
returned, the current position is not changed.
Remarks:
Seeking beyond the end of the buffer is succeeds.
Seeking before the beginning of the buffer fails.
*/
bool Seek(
ON__INT64 offset,
int origin
);
/*
Parameters:
offset - [in] (>= 0)
number of bytes to seek from the start of the buffer.
Returns:
True if successful.
False if the seek would result in a file position
before the beginning of the file. If false is
returned, the current position is not changed.
Remarks:
Seeking beyond the end of the buffer is succeeds.
Seeking before the beginning of the buffer fails.
*/
bool SeekFromStart( ON__INT64 offset );
/*
Parameters:
offset - [in]
number of bytes to seek from the current position.
Returns:
True if successful.
False if the seek would result in a file position
before the beginning of the file. If false is
returned, the current position is not changed.
Remarks:
Seeking beyond the end of the buffer is succeeds.
Seeking before the beginning of the buffer fails.
*/
bool SeekFromCurrentPosition( ON__INT64 offset );
/*
Parameters:
offset - [in]
number of bytes to seek from the end fo the buffer.
Returns:
True if successful.
False if the seek would result in a file position
before the beginning of the file. If false is
returned, the current position is not changed.
Remarks:
Seeking beyond the end of the buffer is succeeds.
Seeking before the beginning of the buffer fails.
*/
bool SeekFromEnd( ON__INT64 offset );
/*
Parameters:
buffer_size - [in]
new size of buffer.
Returns:
True if successful.
Remarks:
The current position is not changed and may be beyond the
end of the file. Use Seek to set the current position after
calling ChangeSize().
*/
bool ChangeSize( ON__UINT64 buffer_size );
/*
Description:
Return unused memory to heap.
Remarks:
Call this function after creating an ON_Buffer that will persist for
and extended amount of time. There are never more than 16 pages of
unsued memory (16*4096 bytes on most computers) in an ON_Buffer.
Compact() can be called at any time, but calling Compact() the then
writing at the end of the buffer is not an efficient use of time
or memory.
*/
bool Compact();
/*
Returns
True if the ON_Buffer is valid.
*/
bool IsValid( const ON_TextLog* text_log ) const;
/*
Returns:
Value that identifies most recent error.
0: no error
1: attempt to seek to a negative position
*/
ON__UINT32 LastError() const;
void ClearLastError();
ON_Buffer_ErrorHandler ErrorHandler() const;
void SetErrorHandler(ON_Buffer_ErrorHandler error_handler);
/*
Description:
Use WriteToBinaryArchive() to save an entire ON_Buffer inside
a binary archive. Use ReadFromBinaryArchive() to retrieve
the ON_Buffer from the ON_BinaryArchive.
*/
bool WriteToBinaryArchive( ON_BinaryArchive& ) const;
/*
Description:
Use ReadFromBinaryArchive() to retrieve an entire ON_Buffer
that was written using WriteToBinaryArchive().
*/
bool ReadFromBinaryArchive( ON_BinaryArchive& );
/*
Description:
Compress this buffer
Parameters:
compressed_buffer - [out]
(The reference can be *this)
Example:
// compress a buffer in place
ON_Buffer buffer;
buffer = ...;
if ( !buffer.Compress(buffer) )
{
// compression failed
}
else
{
// buffer is now compressed
}
Returns:
True if successful. False if failed.
*/
bool Compress( ON_Buffer& compressed_buffer ) const;
/*
Description:
Uncompress this buffer which must have been compressed using
ON_Buffer::Compress().
Parameters:
uncompressed_buffer - [out]
(The reference can be *this)
Example:
// silly example that compresses and then uncompresses a buffer in place
// to show how to call the functions.
ON_Buffer buffer;
buffer = ...; // buffer is in it uncompressed form
if ( buffer.Compress(buffer) )
{
// buffer is now compressed
if ( buffer.Uncompress(buffer) )
{
// buffer is uncompressed again.
}
}
Returns:
True if successful. False if failed.
*/
bool Uncompress( ON_Buffer& uncompressed_buffer ) const;
private:
ON__UINT64 m_buffer_size; // total number of bytes in the buffer
ON__UINT64 m_current_position;
struct ON_BUFFER_SEGMENT* m_first_segment;
struct ON_BUFFER_SEGMENT* m_last_segment;
struct ON_BUFFER_SEGMENT* m_current_segment;
bool SetCurrentSegment(bool);
void Copy( const ON_Buffer& );
ON_Buffer_ErrorHandler m_error_handler;
ON__UINT32 m_last_error;
unsigned char m_reserved[12];
};
/////////////////////////////////////////////////////////////////////
//
// ON_BinaryArchive
// virtual class for CPU independent serialization
//
// ON_BinaryFile
// simple class for CPU independent binary file I/O
// includes optional CRC support
//
struct ON_3DM_CHUNK
{
size_t m_offset; // In read or write_using_fseek mode, this is the
// file position of first byte after chunk's length.
// In write_using_buffer mode, this of the m_buffer[]
// position of first byte after chunk's length.
unsigned int m_typecode;
int m_value;
int m_do_length; // true if chunk is a long chunk with length
ON__UINT16 m_do_crc16; // 16 bit CRC using CCITT polynomial
ON__UINT16 m_crc16;
ON__UINT32 m_do_crc32; // 32 bit CRC
ON__UINT32 m_crc32;
};
class ON_CLASS ON_3DM_BIG_CHUNK
{
public:
ON_3DM_BIG_CHUNK() = default;
~ON_3DM_BIG_CHUNK() = default;
ON_3DM_BIG_CHUNK(const ON_3DM_BIG_CHUNK&) = default;
ON_3DM_BIG_CHUNK& operator=(const ON_3DM_BIG_CHUNK&) = default;
public:
ON__UINT64 m_start_offset=0; // When reading or writing 3dm archives, this is the
// archive offset (file position) of first byte of
// chunk information conent.
ON__UINT64 m_end_offset=0; // When writing 3dm archives, this is the archive
// offset (file position) of the byte immediately after
// the farthest successful write.
// When reading 3dm archives, this the archive offset
// of the first byte after the chunk's information content.
// When reading, a 16 bit or 32 bit CRC can follow the chunk
// information content.
// During ordinary reading and writing, valid seek target
// positions satisfy
// m_start_offset <= seek target pos <= m_end_offset.
/*
Returns:
Number of bytes in the chunk, including bytes used to store CRC values.
0 for short chunks.
0 for chunks currently being written.
Remarks:
For chunks being read,
m_start_offset + Length() = m_end_offset + SizeofCRC().
*/
ON__UINT64 Length() const;
/*
Parameters:
current_position - [in]
Value of ON_BinaryArchive.CurrentPosition()
Returns:
Number of bytes that can be read when ON_BinaryArchive ReadMode() is true.
*/
ON__UINT64 LengthRemaining(
ON__UINT64 current_position
) const;
/*
Returns:
0: no CRC
4: 32 bit CRC (4 bytes)
2: 16 bit CRC (2 bytes)
*/
ON__UINT64 SizeofCRC() const;
ON__INT64 m_big_value=0;
ON__UINT32 m_typecode=0;
ON__UINT8 m_bLongChunk=0; // true if chunk is a long chunk and m_big_value is a length.
private:
ON__UINT8 m_reserved1=0;
ON__UINT8 m_reserved2=0;
ON__UINT8 m_reserved3=0;
public:
// CRC settings
ON__UINT8 m_do_crc16=0; // true (1) if we are calculating 16 bit CRC
ON__UINT8 m_do_crc32=0; // true (1) if we are calculating 32 bit CRC
ON__UINT16 m_crc16=0; // current 16 bit CRC value
ON__UINT32 m_crc32=0; // current 32 bit CRC value
};
bool ON_IsLongChunkTypecode(ON__UINT32 typecode);
bool ON_IsShortChunkTypecode(ON__UINT32 typecode);
#if defined(ON_DLL_TEMPLATE)
ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3DM_CHUNK>;
ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_3DM_BIG_CHUNK>;
#endif
// Used int ON_3dmProperties::Read() to set ON_BinaryArchive.m_3dm_opennurbs_version
// Do not call directly.
void ON_SetBinaryArchiveOpenNURBSVersion(ON_BinaryArchive&,unsigned int);
class ON_CLASS ON_UserDataItemFilter
{
public:
ON_UserDataItemFilter();
ON_UserDataItemFilter(
ON_UUID application_id,
bool bSerialize
);
ON_UserDataItemFilter(
ON_UUID application_id,
ON_UUID item_id,
bool bSerialize
);
static int Compare(
const class ON_UserDataItemFilter*,
const class ON_UserDataItemFilter*
);
// The application id can be the id for a plug-in, Rhino or opennurbs
ON_UUID m_application_id;
// The item id for object user data is the value of ON_UserData.m_userdata_uuid.
// The item id for user table is the application id.
// A nil item id indicates the setting is applied to all object user data
// and user table information for the specified application.
ON_UUID m_item_id;
// If application id and item id match and m_bSerializeEnabled,
// does not match, then the ON_UserDataItemFilter with the
// largest value of m_precedence is used.
unsigned int m_precedence;
// bSerializationEnabled is true if reading and writing are permitted.
// bSerializationEnabled is false if reading and writing are prevented.
bool m_bSerialize;
};
#if defined(ON_DLL_TEMPLATE)
ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_UserDataItemFilter>;
#endif
class ON_CLASS ON_ComponentManifest
{
public:
// The default constructor would work prfectly,
// except there is a bug in Apple's CLANG that
// requires either an explicitly implemented constructor
// or an explicitly implemented copy constructor together
// with a hack to initialize the static ON_ComponentManifest::Empty.
// Apple CLANG BUG // ON_ComponentManifest() = default;
ON_ComponentManifest() ON_NOEXCEPT;
~ON_ComponentManifest();
static const ON_ComponentManifest Empty;
void Reset();
enum : int
{
UnsetComponentIndex = ON_UNSET_INT_INDEX
};
private:
ON_ComponentManifest(const ON_ComponentManifest&) = delete;
ON_ComponentManifest& operator=(const ON_ComponentManifest&) = delete;
public:
/*
Total number of items in the manifest, including items referencing system components and deleted items.
*/
unsigned int ItemCount() const;
/*
Parameters:
component_type - [in]
If component_type is ON_ModelComponent::Type::Unset or ON_ModelComponent::Type::Mixed,
then the every explict component type is counted.
Returns:
Total number of model components of the specified type in this manifest.
Remarks:
The count includes active, deleted, and system components.
*/
unsigned int TotalComponentCount(
ON_ModelComponent::Type component_type
) const;
/*
Parameters:
component_type - [in]
If component_type is ON_ModelComponent::Type::Unset or ON_ModelComponent::Type::Mixed,
then the every explict component type is counted.
Returns:
Number of model components of the specified type in this manifest.
Remarks:
The count includes active and deleted components.
The count does not include system components (those added by calling AddSystemComponentToManifest()).
*/
unsigned int ActiveAndDeletedComponentCount(
ON_ModelComponent::Type component_type
) const;
/*
Parameters:
component_type - [in]
If component_type is ON_ModelComponent::Type::Unset or ON_ModelComponent::Type::Mixed,
then the every explict component type is counted.
Returns:
Number of active model components of the specified type in this manifest.
Remarks:
The count does not include deleted components (IsDeleted() = true).
The count does not include system components (those added by calling AddSystemComponentToManifest()).
*/
unsigned int ActiveComponentCount(
ON_ModelComponent::Type component_type
) const;
/*
Parameters:
component_type - [in]
If component_type is ON_ModelComponent::Type::Unset or ON_ModelComponent::Type::Mixed,
then the every explict component type is counted.
Returns:
Number of model components of the specified type in this manifest that have IsDeleted() = true.
Remarks:
System components cannot be deleted.
*/
unsigned int DeletedComponentCount(
ON_ModelComponent::Type component_type
) const;
unsigned int SystemComponentCount(
ON_ModelComponent::Type component_type
) const;
/*
Parameters:
component_type - [in]
Returns:
If the component type is indexed, then all current manifest indices
for the component_type are >= 0 and < ComponentIndexLimit().
Otherwise 0 is returned.
*/
int ComponentIndexLimit(
ON_ModelComponent::Type component_type
) const;
/*
Description:
Add a component to this manifest.
If the id is not set or not unique, the component will not be added.
If a unique name is required and the name is not set or not unique,
the component will not be added.
Parameters:
component - [in]
If you want to update the component id, index and name values to
match the ones assigned in the manifest, then call
component.SetIdentification(manifest_item),
where manifest_item is the information returned by this function.
bResolveIdAndNameCollisions - [in]
If false, then the component parameter id must not be used in the
manifest and, when required, the name must be set and unique.
If true and a new id or name is required, one will be assigned.
Note that the component parameter is const and its id and name
are not modified.
assigned_name - [out]
If not null, the assigned name is returned here.
Returns:
If an item is added to this manifest, then the assigned
identification information is returned.
Otherwise ON_ComponentManifestItem::Unset is returned.
Note the manifest index is generally different from component.Index().
Remarks:
Use
*/
const class ON_ComponentManifestItem& AddComponentToManifest(
const class ON_ModelComponent& component,
bool bResolveIdAndNameCollisions,
ON_wString* assigned_name
);
const class ON_ComponentManifestItem& AddSystemComponentToManifest(
const class ON_ModelComponent& component
);
/*
Description:
Add a component to this manifest.
Parameters:
component_type - [in]
Type of component.
component_serial_number - [in]
0 or the component's unique runtime serial number (ON_ModelComponent::RuntimeSerialNumber()).
component_id - [in]
component_name_hash - [in]
If the the component type requires a unique name and the name
is not valid or in use, the component will not be added.
Returns:
If an item is added to this manifest, then the identification
information is returned.
Otherwise ON_ComponentManifestItem::Unset is returned.
Note:
The manifest index is assigned to components that require an index.
*/
const class ON_ComponentManifestItem& AddComponentToManifest(
ON_ModelComponent::Type component_type,
ON__UINT64 component_serial_number,
ON_UUID component_id,
const ON_NameHash& component_name_hash
);
/*
Description:
Add a component to this manifest.
If the id is not set or in use, then a new one will be assigned.
If the component type requires a unique name and the name is not set or in use,
then a new one will be assigned.
Parameters:
component_type - [in]
Type of component.
component_serial_number - [in]
0 or the component's unique runtime serial number (ON_ModelComponent::RuntimeSerialNumber()).
component_id - [in]
If the id is nil or in use, a new id will be assigned.
component_name_hash - [in]
If the the component type requires a unique name and the name
is not valid or in use, the component will not be added.
original_name - [in/out]
If a new name needs to be assigned, the input value will be used
as a candidate and then as the root. Passing in the current name
is a good choice. The output value is the final assigned name.
Returns:
If an item is added to this manifest, then the identification
information is returned.
Otherwise ON_ComponentManifestItem::Unset is returned.
*/
const class ON_ComponentManifestItem& AddComponentToManifest(
ON_ModelComponent::Type component_type,
ON__UINT64 component_serial_number,
ON_UUID component_parent_id,
ON_UUID component_id,
const ON_NameHash& component_name_hash,
const wchar_t* candidate_name,
ON_wString& assigned_name
);
const class ON_ComponentManifestItem& AddComponentToManifest(
ON_ModelComponent::Type component_type,
ON__UINT64 component_serial_number,
ON_UUID component_parent_id,
ON_UUID component_id,
const wchar_t* original_name,
ON_wString& assigned_name
);
/*
Description:
Modify a manifest items's component name
Parameters:
item_id - [in]
Identifies the manifest item to modify.
component_parent_id - [in]
ON_ModelComponent.ParentId() value.
When ON_ModelComponent::UniqueNameIncludesParent(component_type) is true,
it is critical that component_parent_id be set correctly.
name - [in]
new name
Returns:
True if name was modified.
*/
const class ON_ComponentManifestItem& ChangeComponentName(
ON_UUID item_id,
ON_ModelComponent::Type component_type,
ON_UUID component_parent_id,
const wchar_t* component_name
);
/*
Description:
Modify a manifest items's component name
Parameters:
component - [in]
The component that is in the manifest with the new name set.
Returns:
True if name was modified.
*/
const class ON_ComponentManifestItem& ChangeComponentName(
const class ON_ModelComponent& component
);
/*
Description:
A function for expert users to directly set the
component's name hash. Generally, it is better
to use the ChangeComponentName() functions.
Parameters:
item_id - [in]
Identifies the manifest item to modify.
component_name_hash - [in]
new name hash
*/
const class ON_ComponentManifestItem& ChangeComponentNameHash(
ON_UUID item_id,
const ON_NameHash& component_name_hash
);
/*
Description:
Modify a manifest items's component m_component_runtime_serial_number,
m_original_index, m_original_id, and m_name_hash values.
Parameters:
manifest_id - [in]
identifies the manifest item to modify
component_runtime_serial_number - [in]
*/
const class ON_ComponentManifestItem& ChangeComponentRuntimeSerialNumber(
ON_UUID item_id,
ON__UINT64 component_runtime_serial_number
);
/*
Description:
Set a component's status to deleted.
*/
const class ON_ComponentManifestItem& DeleteComponent(
ON_UUID item_id
);
const class ON_ComponentManifestItem& DeleteComponent(
ON__UINT64 component_runtime_serial_number
);
/*
Description:
Undelete a previously deleted component.
*/
const class ON_ComponentManifestItem& UndeleteComponent(
ON_UUID item_id,
ON_UUID parent_id,
const wchar_t* candidate_name,
ON_wString& assigned_name
);
/*
Description:
Undelete a previously deleted component with the same id and
change the serial number to new_component_runtime_serial_number.
Remarks:
Often when an object is modified, the original and new
object have the same id but different serial numbers. The original is
deleted. When the item is undeleted for the object, the runtime
serial number needs to be udated.
*/
const class ON_ComponentManifestItem& UndeleteComponentAndChangeRuntimeSerialNumber(
ON_UUID item_id,
ON_UUID parent_id,
ON__UINT64 new_component_runtime_serial_number,
const wchar_t* candidate_name,
ON_wString& assigned_name
);
bool RemoveComponent(
const ON_ModelComponent& component
);
bool RemoveComponent(
ON__UINT64 component_runtime_serial_number
);
bool RemoveComponent(
ON_UUID item_id
);
bool RemoveIndexedComponent(
ON_ModelComponent::Type component_type,
int item_index
);
bool RemoveAllComponents(
ON_ModelComponent::Type component_type,
bool bResetManifestIndex
);
/*
Description:
Get a name that is currently not used in this manifest as either a component
or manifest name.
Parameters:
component_type - [in]
ON_ModelComponent::ComponentTypeIsValidAndNotMixed(component_type) must be true.
component_parent_id - [in]
If ON_ModelComponent::UniqueNameIncludesParent(component_type) is true and
candidate_name is not empty, then the component parent id must be accurate.
This is the case for ON_Layer names.
Otherwise, you may pass ON_nil_uuid.
candidate_name - [in]
If candidate_name is a valid and not it use,
then unused_component_name = candidate_name.
If ON_ModelComponent::UniqueNameIncludesParent(component_type) is true and
candidate_name is not empty, then component_parent_id must be accurate.
This is the case for ON_Layer names.
base_name - [in]
If base_name is empty or not valid,
then ON_ModelComponent::ComponentTypeToString(component_type) is used as base_name
suffix_separator - [in]
empty or the string to place between base_name and the suffix when searching for an
unsued name.
suffix0 - [in]
If a suffix needs to be appended, the search for a
unused name begins with the suffix values suffix0+1.
suffix_value - [out]
If nullptr != suffix_value, the value used to generate the
unique name suffix is returned.
Returns:
An component name that is not used in this manifest.
Remarks:
If candidate_name could not be used, then it has the form
base_name + suffix_separator + X, where X is an integer > suffix0.
*/
const ON_wString UnusedName(
ON_ModelComponent::Type component_type,
ON_UUID component_parent_id,
const wchar_t* candidate_name,
const wchar_t* base_name,
const wchar_t* suffix_separator,
unsigned int suffix0,
unsigned int* suffix_value
) const;
/*
Description:
Get a name that is currently not used in this manifest as either a component
or manifest name.
Parameters:
model_component - [in]
The component type, id, parent id, and candidate name parameters for the
more complicated version of UnusedName() are taken from this parameter.
Returns:
An component name that is not used in this manifest.
Remarks:
If candidate_name could not be used, then it has the form
base_name + suffix_separator + X, where X is an integer > suffix0.
*/
const ON_wString UnusedName(
const ON_ModelComponent& model_component
) const;
/*
Parameters:
component_type - [in]
ON_ModelComponent::ComponentTypeIsValidAndNotMixed(component_type)
must be true or false will be returned.
candidate_name_hash - [in]
candidate_name_hash.IsValidAndNotEmpty()
must be true or false will be returned.
Returns:
True if the candidate_name_hash a hash of a valid, non-empty name and the
name is currently not used as either a component or manifest name value.
*/
bool NameIsAvailable(
ON_ModelComponent::Type component_type,
const ON_NameHash& candidate_name_hash
) const;
/*
Description:
Get an id that is not currently used in this manifest
Parameters:
component_type - [in]
ON_ModelComponent::ComponentTypeIsValidAndNotMixed(component_type) must be true.
candidate_id
If candidate_id is valid component id and not in use,
then its value is returned.
Returns:
An id that is valid and currently not used in this ON_Manifest as
either a component or a manifest id value.
Remarks:
If candidate_id cannot be used, then ON_CreateId() is used to create a new id.
*/
ON_UUID UnusedId(
ON_UUID candidate_id
) const;
/*
Returns:
True if the id is valid and currently not used in this ON_Manifest as
either a component or a manifest id value.
*/
bool IdIsAvailable(
ON_UUID id
) const;
//////////////////////////////////////////////////////////////////
//
// Query tools to get item identificaion information
//
//
const class ON_ComponentManifestItem& ItemFromId(
ON_UUID item_id
) const;
const class ON_ComponentManifestItem& ItemFromComponentRuntimeSerialNumber(
ON__UINT64 component_runtime_serial_number
) const;
/*
Description:
Returns the item if it has the required component type and id.
Remarks:
Every item has a unique manifest id. The component_type
parameter is provided if an additional check needs to be
made on component type.
*/
const class ON_ComponentManifestItem& ItemFromId(
ON_ModelComponent::Type component_type,
ON_UUID item_id
) const;
/*
Parameters:
component_type - [in]
component_name_hash - [in]
The value of ON_ModelComponent::UniqueNameIgnoresCase(component_type) must be used
when creating the name hash (group names are case sensitive).
If ON_ModelComponent::UniqueNameIncludesParent(component_type) is true,
then the parent_id must be used to calculate the name hash
(layer names require parent ids).
*/
const class ON_ComponentManifestItem& ItemFromName(
const class ON_ModelComponent* model_component
) const;
const class ON_ComponentManifestItem& ItemFromName(
ON_ModelComponent::Type component_type,
ON_UUID parent_id,
const wchar_t* name
) const;
/*
Parameters:
component_type - [in]
component_name_hash - [in]
The value of ON_ModelComponent::UniqueNameIgnoresCase(component_type) must be used
when creating the name hash (group names are case sensitive).
If ON_ModelComponent::UniqueNameIncludesParent(component_type) is true,
then the parent_id must be used to calculate the name hash
(layer names require parent ids).
*/
const class ON_ComponentManifestItem& ItemFromNameHash(
ON_ModelComponent::Type component_type,