HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Compression.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_Compression.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef UT_COMPRESSION_H_
12 #define UT_COMPRESSION_H_
13 
14 #include "UT_String.h"
15 
17 {
21 };
22 
23 #define UT_GZIP_HEADER_MAGIC "\x1f\x8b\x08"
24 
25 #define UT_BLOSC_BLOCKSIZE (1048576)
26 #define UT_BLOSC_TYPESIZE (sizeof(float))
27 #define UT_BLOSC_COMPRESSION_LEVEL (9)
28 
29 /// Determines the compression type from a filename extension.
30 /// ".gz" maps to gzip, ".sc" maps to blosc, anything else is none.
31 inline UT_CompressionType
33 {
35  if (filename.matchFileExtension(".gz"))
36  compression = UT_COMPRESSION_TYPE_GZIP;
37  else if (filename.matchFileExtension(".sc"))
38  compression = UT_COMPRESSION_TYPE_BLOSC;
39  return compression;
40 }
41 
42 /// Converts the string we get from the parameter into an
43 /// enumeration that is used interally
44 /// The strange names for none and gzip (off and on) are for
45 /// backwards compatability with pervious compression parameter.
46 inline UT_CompressionType
48 {
49  if (string == "blosc")
50  {
52  }
53  else if (string == "off" || string == "none")
54  {
56  }
57  else if (string == "on" || string == "gzip")
58  {
60  }
61  else
62  {
63  UT_ASSERT(false && "Compression type not known. "
64  "You probably added the type to OBJ_Shared.C and not here.");
65  // If not assert then do default.
67  }
68 }
69 
70 
71 #endif /* UT_COMPRESSION_H_ */
GT_API const UT_StringHolder filename
bool matchFileExtension(const char *match_extension) const
Definition: UT_String.h:664
UT_CompressionType UTcompressionTypeFromString(const UT_String &string)
UT_CompressionType
UT_CompressionType UTcompressionTypeFromFilename(const UT_String &filename)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156