QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_zlib.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(OPENNURBS_ZLIB_INC_)
17#define OPENNURBS_ZLIB_INC_
18
19// If you are using opennurbs as a statically linked library, then
20// you may make calls to the same zlib that opennurbs uses. This
21// zlib is compiled with z_ symbol projectection. All the necessary
22// header files are included by opennurbs.h.
23//
24// If you are using opennurbs as a DLL or writing a Rhino plug-in
25// and you want to use the same zlib that opennurbs uses, then
26// compile opennurbs_zlib_memory.cpp into your application
27// and statically link with the zlib library. All the necessary
28// header files are included by opennurbs.h.
29
30
31#if !defined(Z_PREFIX)
32/* decorates zlib functions with a "z_" prefix to prevent symbol collision. */
33#define Z_PREFIX
34#endif
35
36#if !defined(MY_ZCALLOC)
37/* have zlib use oncalloc() and onfree() for memory managment*/
38//#define MY_ZCALLOC
39#endif
40
41extern "C" {
42#include "./zlib/zlib.h"
43}
44
46voidpf zcalloc (voidpf, unsigned, unsigned);
47void zcfree (voidpf, voidpf);
49
51{
52public:
56 ON_CompressedBuffer& operator=(const ON_CompressedBuffer& src);
57
58 /*
59 Description:
60 Compress inbuffer.
61 Parameters:
62 sizeof__inbuffer - [in]
63 Number of bytes in inbuffer.
64 inbuffer - [in]
65 Uncompressed information.
66 sizeof_element - [out]
67 This parameter only matters if the buffer will be compressed,
68 and decompressed on CPUs with different endianness. If this
69 is the case, then the types in the buffer need to have the
70 same size (2,4, or 8).
71 Returns:
72 True if inbuffer is successfully compressed.
73 */
74 bool Compress(
75 size_t sizeof__inbuffer, // sizeof uncompressed input data
76 const void* inbuffer, // uncompressed input data
77 int sizeof_element
78 );
79
80 /*
81 Returns:
82 Number of bytes in the uncompressed information.
83 */
85
86 /*
87 Description:
88 Uncompress the contents of this ON_CompressedBuffer.
89 Parameters:
90 outbuffer - [in/out]
91 This buffer must have at least SizeOfUncompressedBuffer() bytes.
92 If the function returns true, then the uncopressed information
93 is stored in this buffer.
94 bFailedCRC - [out]
95 If not null, then this boolean is set to true if the CRC
96 of the uncompressed information has changed.
97 Returns:
98 True if uncompressed information is returned in outbuffer.
99 */
100 bool Uncompress( // read and uncompress
101 void* outbuffer, // uncompressed output data returned here
102 int* bFailedCRC
103 ) const;
104
105 /*
106 Description:
107 Destroy the current informtion in the ON_CompressedBuffer
108 so the class can be reused.
109 */
110 void Destroy();
111
112 bool Write( ON_BinaryArchive& binary_archive ) const;
113 bool Read( ON_BinaryArchive& binary_archive );
114
116 //
117 // Implementation
118 //
119 bool CompressionInit( struct ON_CompressedBufferHelper* ) const;
120 bool CompressionEnd( struct ON_CompressedBufferHelper* ) const;
121 size_t DeflateHelper( // returns number of bytes written
123 size_t sizeof___inbuffer, // sizeof uncompressed input data ( > 0 )
124 const void* in___buffer // uncompressed input data ( != NULL )
125 );
126 bool InflateHelper(
128 size_t sizeof___outbuffer, // sizeof uncompressed data
129 void* out___buffer // buffer for uncompressed data
130 ) const;
131 bool WriteChar(
132 size_t count,
133 const void* buffer
134 );
135
140 int m_method; // 0 = copied, 1 = compressed
144};
145
146#endif
Definition opennurbs_archive.h:152
Definition opennurbs_zlib.h:51
ON__UINT32 m_crc_uncompressed
Definition opennurbs_zlib.h:138
size_t m_sizeof_uncompressed
Definition opennurbs_zlib.h:136
int m_sizeof_element
Definition opennurbs_zlib.h:141
int m_method
Definition opennurbs_zlib.h:140
ON__UINT32 m_crc_compressed
Definition opennurbs_zlib.h:139
size_t m_sizeof_compressed
Definition opennurbs_zlib.h:137
size_t m_buffer_compressed_capacity
Definition opennurbs_zlib.h:142
void * m_buffer_compressed
Definition opennurbs_zlib.h:143
size_t SizeOfUncompressedBuffer() const
#define ON_BEGIN_EXTERNC
Definition opennurbs_defines.h:40
#define ON_CLASS
Definition opennurbs_defines.h:91
#define ON_END_EXTERNC
Definition opennurbs_defines.h:41
unsigned int ON__UINT32
Definition opennurbs_system.h:326
ON_BEGIN_EXTERNC voidpf zcalloc(voidpf, unsigned, unsigned)
Definition opennurbs_zlib_memory.cpp:30
void zcfree(voidpf, voidpf)
Definition opennurbs_zlib_memory.cpp:35
Definition opennurbs_zlib.cpp:637
Byte FAR * voidpf
Definition zconf.h:315