17 #if !defined(ON_ARCHIVE_INC_)
18 #define ON_ARCHIVE_INC_
34 static FILE* Open(
const wchar_t* filename,
const wchar_t* mode );
47 static FILE* Open(
const char* filename,
const char* mode );
60 static int Close( FILE* fp );
72 static ON__INT64 CurrentPosition( FILE* fp );
82 static bool SeekFromCurrentPosition( FILE* fp, ON__INT64 offset );
92 static bool SeekFromStart( FILE* fp, ON__INT64 offset );
102 static bool SeekFromEnd( FILE* fp, ON__INT64 offset );
116 static bool Seek( FILE* fp, ON__INT64 offset,
int orgin );
131 static ON__UINT64 Read( FILE* fp, ON__UINT64 count,
void* buffer );
146 static ON__UINT64 Write( FILE* fp, ON__UINT64 count,
const void* buffer );
157 static bool Flush( FILE* fp );
179 static bool GetFileInformation(
181 ON__UINT64* file_size,
182 ON__UINT64* file_create_time,
183 ON__UINT64* file_last_modified_time
238 const wchar_t* FirstFile(
239 const wchar_t* directory_name,
240 const wchar_t* file_name_filter
243 const wchar_t* FirstFile(
244 const char* directory_name,
245 const char* file_name_filter
254 const wchar_t* NextFile();
256 const wchar_t* CurrentFileName()
const;
258 ON__UINT64 CurrentFileSize()
const;
264 bool CurrentFileIsDirectory()
const;
272 bool CurrentFileIsHidden()
const;
274 bool GetCurrentFullPathFileName(
ON_wString& filename )
const;
280 ON__UINT64 CurrentFileCreateTime()
const;
286 ON__UINT64 CurrentFileLastModifiedTime()
const;
292 ON__UINT64 CurrentFileLastAccessTime()
const;
298 ON__UINT64 Count()
const;
305 #if defined(ON_COMPILER_MSC)
306 ON__UINT32 m_file_attributes_mask;
308 WIN32_FIND_DATA m_fd;
313 struct dirent m_dirent;
314 char m_dirent_name_buffer[NAME_MAX+1];
317 wchar_t m_current_name[1024];
318 ON__UINT64 m_current_file_attributes;
319 ON__UINT64 m_current_file_size;
320 ON__UINT64 m_current_file_create_time;
321 ON__UINT64 m_current_last_modified_time;
322 ON__UINT64 m_current_last_access_time;
332 typedef void (*ON_Buffer_ErrorHandler)(
class ON_Buffer*);
357 void EmergencyDestroy();
378 ON__UINT64 Size()
const;
386 ON__UINT32 CRC32( ON__UINT32 current_remainder )
const;
398 ON__UINT64 CurrentPosition()
const;
409 ON__UINT64 Write( ON__UINT64 size,
const void* buffer );
430 ON__UINT64 Read( ON__UINT64 size,
void* buffer );
434 seek_from_beginning_of_file = 0,
435 seek_from_current_position = 1,
436 seek_from_end_of_file = 2
475 bool SeekFromStart( ON__INT64 offset );
490 bool SeekFromCurrentPosition( ON__INT64 offset );
505 bool SeekFromEnd( ON__INT64 offset );
518 bool ChangeSize( ON__UINT64 buffer_size );
537 bool IsValid(
const ON_TextLog* text_log )
const;
545 ON__UINT32 LastError()
const;
547 void ClearLastError();
549 ON_Buffer_ErrorHandler ErrorHandler()
const;
551 void SetErrorHandler(ON_Buffer_ErrorHandler error_handler);
593 bool Compress(
ON_Buffer& compressed_buffer )
const;
621 bool Uncompress(
ON_Buffer& uncompressed_buffer )
const;
625 ON__UINT64 m_buffer_size;
626 ON__UINT64 m_current_position;
628 struct ON_BUFFER_SEGMENT* m_first_segment;
629 struct ON_BUFFER_SEGMENT* m_last_segment;
630 struct ON_BUFFER_SEGMENT* m_current_segment;
631 bool SetCurrentSegment(
bool);
634 ON_MEMORY_POOL* m_heap;
635 ON_Buffer_ErrorHandler m_error_handler;
637 ON__UINT32 m_last_error;
638 unsigned char m_reserved[12];
656 class ON_ObjectAttributes;
683 ON__UINT64
Length()
const;
700 bool ON_IsLongChunkTypecode(ON__UINT32 typecode);
702 bool ON_IsShortChunkTypecode(ON__UINT32 typecode);
704 #if defined(ON_DLL_TEMPLATE)
708 #pragma warning( push )
709 #pragma warning( disable : 4231 )
712 #pragma warning( pop )
738 std::size_t CurrentPosition(
741 bool SeekFromCurrentPosition(
749 bool AtEnd()
const = 0;
751 bool BigSeekFromStart( ON__UINT64 offset );
752 bool BigSeekForward( ON__UINT64 offset );
753 bool BigSeekBackward( ON__UINT64 offset );
754 bool BigSeekFromCurrentPosition( ON__INT64 offset );
766 bool ToggleByteOrder(
774 const char* TypecodeName(
unsigned int tcode );
777 char* ON_TypecodeParse(
unsigned int tcode,
char* typecode_name, std::size_t max_length );
779 bool ReadMode()
const;
780 bool WriteMode()
const;
788 ON::endian Endian()
const;
790 int BadCRCCount()
const;
792 bool ReadByte( std::size_t,
void* );
794 bool WriteByte( std::size_t,
const void* );
806 ON__UINT64 ReadBuffer( ON__UINT64 sizeof_buffer,
void* buffer );
820 bool EnableCRCCalculation(
bool bEnable );
847 bool ReadCompressedBufferSize( std::size_t* sizeof__outbuffer );
870 bool ReadCompressedBuffer(
871 std::size_t sizeof__outbuffer,
885 bool WriteCompressedBuffer(
886 std::size_t sizeof__inbuffer,
890 bool ReadBool(
bool* );
970 bool ReadBigSize( std::size_t* );
972 bool ReadBigTime( time_t* );
1034 bool ReadTime(
struct tm& );
1048 ON_DEPRECATED
bool ReadStringSize(
1049 std::size_t* str_array_count
1061 bool ReadStringUTF8ElementCount(
1062 std::size_t* string_utf8_element_count
1074 bool ReadStringUTF16ElementCount(
1075 std::size_t* string_utf16_element_count
1093 std::size_t str_array_count,
1111 std::size_t str_array_count,
1112 unsigned char* str_array
1129 std::size_t str_array_count,
1130 unsigned short* str_array
1137 bool ReadComponentIndex( ON_COMPONENT_INDEX& );
1173 bool WriteBool(
bool );
1181 const unsigned char*
1196 const unsigned short*
1241 const unsigned long*
1253 bool WriteBigSize( std::size_t );
1255 bool WriteBigTime( time_t );
1300 bool WriteLine(
const ON_Line&);
1302 bool WriteArc(
const ON_Arc&);
1308 bool WriteUuid(
const ON_UUID& );
1316 bool WriteTime(
const struct tm& );
1359 const unsigned char* sUTF8
1381 const unsigned short* sUTF16
1384 bool WriteString(
const ON_String& sUTF8 );
1388 bool WriteComponentIndex(
const ON_COMPONENT_INDEX& );
1424 bool WriteArray(
int count,
const class ON_Layer* );
1425 bool WriteArray(
int count,
const class ON_Layer*
const* );
1479 bool EnableSave3dmRenderMeshes( ON_BOOL32 =
true );
1480 bool Save3dmRenderMeshes()
const;
1482 bool EnableSave3dmAnalysisMeshes( ON_BOOL32 =
true );
1483 bool Save3dmAnalysisMeshes()
const;
1485 bool EnableSaveUserData( ON_BOOL32 =
true );
1486 bool SaveUserData()
const;
1496 static int CurrentArchiveVersion();
1521 bool Write3dmStartSection(
1523 const char* sStartSectionComment
1533 bool Read3dmStartSection(
1541 bool Write3dmProperties(
1544 bool Read3dmProperties(
1551 bool Write3dmSettings(
1554 bool Read3dmSettings(
1561 bool BeginWrite3dmBitmapTable();
1562 bool Write3dmBitmap(
const ON_Bitmap& );
1563 bool EndWrite3dmBitmapTable();
1565 bool BeginRead3dmBitmapTable();
1570 bool EndRead3dmBitmapTable();
1575 bool BeginWrite3dmTextureMappingTable();
1577 bool EndWrite3dmTextureMappingTable();
1579 bool BeginRead3dmTextureMappingTable();
1580 int Read3dmTextureMapping(
1583 bool EndRead3dmTextureMappingTable();
1588 bool BeginWrite3dmMaterialTable();
1590 bool EndWrite3dmMaterialTable();
1592 bool BeginRead3dmMaterialTable();
1593 int Read3dmMaterial(
1596 bool EndRead3dmMaterialTable();
1601 bool BeginWrite3dmLinetypeTable();
1603 bool EndWrite3dmLinetypeTable();
1605 bool BeginRead3dmLinetypeTable();
1607 bool EndRead3dmLinetypeTable();
1612 bool BeginWrite3dmLayerTable();
1613 bool Write3dmLayer(
const ON_Layer& );
1614 bool EndWrite3dmLayerTable();
1616 bool BeginRead3dmLayerTable();
1620 bool EndRead3dmLayerTable();
1625 bool BeginWrite3dmGroupTable();
1626 bool Write3dmGroup(
const ON_Group& );
1627 bool EndWrite3dmGroupTable();
1629 bool BeginRead3dmGroupTable();
1670 bool EndRead3dmGroupTable();
1676 bool BeginWrite3dmFontTable();
1677 bool Write3dmFont(
const ON_Font& );
1678 bool EndWrite3dmFontTable();
1680 bool BeginRead3dmFontTable();
1721 bool EndRead3dmFontTable();
1727 bool BeginWrite3dmDimStyleTable();
1729 bool EndWrite3dmDimStyleTable();
1731 bool BeginRead3dmDimStyleTable();
1769 int Read3dmDimStyle(
1773 bool EndRead3dmDimStyleTable();
1779 bool BeginWrite3dmLightTable();
1780 bool Write3dmLight(
const ON_Light&,
1783 bool EndWrite3dmLightTable();
1785 bool BeginRead3dmLightTable();
1793 bool EndRead3dmLightTable();
1799 bool BeginWrite3dmHatchPatternTable();
1801 bool EndWrite3dmHatchPatternTable();
1803 bool BeginRead3dmHatchPatternTable();
1805 bool EndRead3dmHatchPatternTable();
1810 bool BeginWrite3dmInstanceDefinitionTable();
1812 bool EndWrite3dmInstanceDefinitionTable();
1814 bool BeginRead3dmInstanceDefinitionTable();
1850 int Read3dmInstanceDefinition(
1854 bool EndRead3dmInstanceDefinitionTable();
1859 bool BeginWrite3dmObjectTable();
1860 bool Write3dmObject(
1864 bool EndWrite3dmObjectTable();
1866 bool BeginRead3dmObjectTable();
1876 bool EndRead3dmObjectTable();
1881 bool BeginWrite3dmHistoryRecordTable();
1882 bool Write3dmHistoryRecord(
1885 bool EndWrite3dmHistoryRecordTable();
1887 bool BeginRead3dmHistoryRecordTable();
1895 int Read3dmHistoryRecord(
1898 bool EndRead3dmHistoryRecordTable();
1934 bool BeginWrite3dmUserTable(
1937 int goo_3dm_version,
1938 int goo_opennurbs_version
1941 bool EndWrite3dmUserTable();
1964 bool Write3dmAnonymousUserTableRecord(
1966 int goo_3dm_version,
1967 int goo_opennurbs_version,
1972 ON_DEPRECATED
bool BeginWrite3dmUserTable(
const ON_UUID& );
1975 ON_DEPRECATED
bool Write3dmAnonymousUserTable(
const ON_3dmGoo& );
1994 bool BeginRead3dmUserTable(
1996 bool* bLastSavedAsGoo,
1997 int* archive_3dm_version,
1998 int* archive_opennurbs_version
2009 bool Read3dmAnonymousUserTable(
2010 int archive_3dm_version,
2011 int archive_opennurbs_version,
2015 bool EndRead3dmUserTable();
2018 ON_DEPRECATED
bool BeginRead3dmUserTable(
2023 ON_DEPRECATED
bool Read3dmAnonymousUserTable(
ON_3dmGoo& );
2041 bool Write3dmEndMark();
2056 bool Read3dmEndMark(
2080 bool BeginWrite3dmChunk(
2085 bool BeginWrite3dmBigChunk(
2086 ON__UINT32 typecode,
2103 bool BeginWrite3dmChunk(
2111 bool EndWrite3dmChunk();
2116 ON_DEPRECATED
bool BeginRead3dmChunk(
2123 bool BeginRead3dmBigChunk(
2140 bool BeginRead3dmChunk(
2141 unsigned int expected_tcode,
2155 bool EndRead3dmChunk();
2156 bool EndRead3dmChunk(
bool bSupressPartiallyReadChunkWarning);
2184 bool BeginWriteDictionary(
2186 unsigned int version,
2187 const wchar_t* dictionary_name
2205 bool EndWriteDictionary();
2223 bool BeginWriteDictionaryEntry(
2225 const wchar_t* entry_name
2227 bool EndWriteDictionaryEntry();
2229 bool BeginReadDictionary(
2231 unsigned int* version,
2234 bool EndReadDictionary();
2248 int BeginReadDictionaryEntry(
2252 bool EndReadDictionaryEntry();
2257 ON_DEPRECATED
bool PeekAt3dmChunkType(
2262 bool PeekAt3dmBigChunkType(
2263 ON__UINT32* typecode,
2264 ON__INT64* big_value
2267 bool Seek3dmChunkFromStart(
2275 bool Seek3dmChunkFromCurrentPosition(
2290 bool Write3dmChunkVersion(
2294 bool Read3dmChunkVersion(
2309 bool WriteObjectUserData(
const ON_Object&
object );
2321 bool ReadObjectUserData(
ON_Object&
object );
2339 int Archive3dmVersion()
const;
2361 int ArchiveOpenNURBSVersion()
const;
2379 std::size_t ArchiveStartOffset()
const;
2383 no_active_table = 0,
2429 bool FindTableInDamagedArchive(
2430 unsigned int tcode_table,
2431 unsigned int tcode_record,
2454 int recursion_depth = 0
2466 std::size_t Read( std::size_t,
void* ) = 0;
2475 std::size_t Write( std::size_t,
const void* ) = 0;
2506 bool SetArchive3dmVersion(
int);
2510 bool WriteInt8( std::size_t,
const ON__INT8* );
2511 bool ReadInt8( std::size_t, ON__INT8* );
2514 bool WriteInt16( std::size_t,
const ON__INT16* );
2515 bool ReadInt16( std::size_t, ON__INT16* );
2518 bool WriteInt32( std::size_t,
const ON__INT32* );
2519 bool ReadInt32( std::size_t, ON__INT32* );
2522 bool WriteInt64( std::size_t,
const ON__INT64* );
2523 bool ReadInt64( std::size_t, ON__INT64* );
2525 bool BeginWrite3dmTable(
2528 bool EndWrite3dmTable(
2531 bool BeginRead3dmTable(
2534 bool EndRead3dmTable(
2547 int Read3dmV1Object(
2557 bool Read3dmV1AttributesOrMaterial(
2562 class ON__3dmV1_XDATA* = 0
2565 int Read3dmV1LayerIndex(
const char* )
const;
2580 ON::archive_mode Mode()
const;
2581 void UpdateCRC( std::size_t,
const void* );
2585 int m_3dm_v1_layer_index;
2586 int m_3dm_v1_material_index;
2606 unsigned int m_error_message_mask;
2608 unsigned int ErrorMessageMask()
const;
2620 bool MaskReadError( ON__UINT64 sizeof_request, ON__UINT64 sizeof_read )
const;
2635 int m_3dm_opennurbs_version;
2641 std::size_t m_3dm_start_section_offset;
2643 table_type m_active_table;
2645 table_type TableTypeFromTypecode(
unsigned int );
2650 bool PushBigChunk( ON__UINT32 typecode, ON__INT64 value );
2652 bool WriteChunkTypecode( ON__UINT32 );
2653 bool ReadChunkTypecode( ON__UINT32* );
2654 bool WriteChunkValue( ON__UINT32 typecode, ON__INT64 );
2655 bool WriteChunkLength( ON__UINT64 );
2656 bool ReadChunkValue( ON__UINT32 typecode, ON__INT64* value64 );
2657 bool FindMisplacedTable(
2658 ON__UINT64 filelength,
2659 const ON__UINT32 table_tocde,
2660 const ON__UINT32 table_record_record,
2662 const ON__UINT64 min_length_data
2665 bool ReadObjectUserDataAnonymousChunk(
2666 const ON__UINT64 length_TCODE_ANONYMOUS_CHUNK,
2667 const int archive_3dm_version,
2668 const int archive_opennurbs_version,
2672 std::size_t SizeofChunkLength()
const;
2675 bool WriteEOFSizeOfFile( ON__UINT64 );
2676 bool ReadEOFSizeOfFile( ON__UINT64* );
2680 int m_bad_CRC_count;
2690 sizeof_x_buffer = 16384
2692 unsigned char buffer[sizeof_x_buffer];
2697 std::size_t WriteDeflate(
2705 bool CompressionInit();
2706 void CompressionEnd();
2711 ON::endian m_endian;
2713 ON::archive_mode m_mode;
2716 bool m_bSaveUserData;
2717 bool m_bSavePreviewImage;
2718 bool m_bEmbedTextureBitmaps;
2719 bool m_bSaveRenderMeshes;
2720 bool m_bSaveAnalysisMeshes;
2727 struct ON__3dmV1LayerIndex* m_V1_layer_list;
2776 std::size_t CurrentPosition()
const;
2777 bool SeekFromCurrentPosition(
int);
2778 bool SeekFromStart(std::size_t);
2782 bool SeekFromEnd(
int );
2792 void EnableMemoryBuffer(
2797 std::size_t Read( std::size_t,
void* );
2798 std::size_t Write( std::size_t,
const void* );
2811 std::size_t m_memory_buffer_capacity;
2812 std::size_t m_memory_buffer_size;
2813 std::size_t m_memory_buffer_ptr;
2814 unsigned char* m_memory_buffer;
2860 std::size_t CurrentPosition()
const;
2861 bool SeekFromCurrentPosition(
int);
2862 bool SeekFromStart(std::size_t);
2865 bool SeekFromEnd( ON__INT64 );
2868 std::size_t Read( std::size_t,
void* );
2869 std::size_t Write( std::size_t,
const void* );
2907 std::size_t sizeof_buffer,
2910 int archive_3dm_version,
2911 int archive_opennurbs_version
2920 std::size_t SizeOfBuffer()
const;
2926 const void* Buffer()
const;
2929 std::size_t CurrentPosition()
const;
2930 bool SeekFromCurrentPosition(
int);
2931 bool SeekFromStart(std::size_t);
2936 std::size_t Read( std::size_t,
void* );
2937 std::size_t Write( std::size_t,
const void* );
2942 const unsigned char* m_buffer;
2943 std::size_t m_sizeof_buffer;
2944 std::size_t m_buffer_position;
2945 ON__INT_PTR m_reserved1;
2946 ON__INT_PTR m_reserved2;
2947 ON__INT_PTR m_reserved3;
2948 ON__INT_PTR m_reserved4;
2979 std::size_t initial_sizeof_buffer,
2980 std::size_t max_sizeof_buffer,
2981 int archive_3dm_version,
2982 int archive_opennurbs_version
2991 std::size_t SizeOfArchive()
const;
2997 std::size_t SizeOfBuffer()
const;
3008 const void* Buffer()
const;
3017 void* HarvestBuffer();
3020 std::size_t CurrentPosition()
const;
3021 bool SeekFromCurrentPosition(
int);
3022 bool SeekFromStart(std::size_t);
3027 std::size_t Read( std::size_t,
void* );
3028 std::size_t Write( std::size_t,
const void* );
3032 void AllocBuffer(std::size_t);
3034 unsigned char* m_buffer;
3035 std::size_t m_sizeof_buffer;
3036 const std::size_t m_max_sizeof_buffer;
3037 std::size_t m_sizeof_archive;
3038 std::size_t m_buffer_position;
3039 ON__INT_PTR m_reserved1;
3040 ON__INT_PTR m_reserved2;
3041 ON__INT_PTR m_reserved3;
3042 ON__INT_PTR m_reserved4;
3081 bool ON_WriteOneObjectArchive(
ON__UINT64 Length() const
virtual int LoadUserDataApplication(ON_UUID)