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 #define UT_BLOSC_COMPRESSION_LEVEL_USEENV (-1)
29 
30 /// Determines the compression type from a filename extension.
31 /// ".gz" maps to gzip, ".sc" maps to blosc, anything else is none.
32 inline UT_CompressionType
34 {
36  if (filename.matchFileExtension(".gz"))
37  compression = UT_COMPRESSION_TYPE_GZIP;
38  else if (filename.matchFileExtension(".sc"))
39  compression = UT_COMPRESSION_TYPE_BLOSC;
40  return compression;
41 }
42 
43 /// Converts the string we get from the parameter into an
44 /// enumeration that is used interally
45 /// The strange names for none and gzip (off and on) are for
46 /// backwards compatability with pervious compression parameter.
47 inline UT_CompressionType
49 {
50  if (string == "blosc")
51  {
53  }
54  else if (string == "off" || string == "none")
55  {
57  }
58  else if (string == "on" || string == "gzip")
59  {
61  }
62  else
63  {
64  UT_ASSERT(false && "Compression type not known. "
65  "You probably added the type to OBJ_Shared.C and not here.");
66  // If not assert then do default.
68  }
69 }
70 
71 
72 #endif /* UT_COMPRESSION_H_ */
GT_API const UT_StringHolder filename
bool matchFileExtension(const char *match_extension) const
Definition: UT_String.h:679
UT_CompressionType UTcompressionTypeFromString(const UT_String &string)
UT_CompressionType
UT_CompressionType UTcompressionTypeFromFilename(const UT_String &filename)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165