HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_SerializationOptions.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  * COMMENTS:
7  */
8 
9 #ifndef __PDG_SERIALIZATION_OPTIONS_H__
10 #define __PDG_SERIALIZATION_OPTIONS_H__
11 
12 #include "PDG_API.h"
13 #include "PDG_AttributeTypes.h"
14 
15 #include <UT/UT_Compression.h>
16 #include <UT/UT_StringHolder.h>
17 
18 /*
19  * Configuration options for serializing work items
20  */
22 {
23  /// Enumeration of supported file compression t ypes
25  {
29  };
30 
31  /// Constructs a new serialization struct with default values (automatic
32  /// compression, flattened attributes, etc)
34  : myAttribSaveType(PDG_AttributeSaveType::eFlatten)
35  , myCompressType(eCompressAutomatic)
36  , myBinary(false)
37  , myRecursive(false)
38  , myPrettyPrint(false)
39  , mySkipDefault(false)
40  , mySaveGlobalAttributes(false)
41  , mySaveBoundAttributes(false) {}
42 
43  /// Converts the compression settings and optional file path to a
44  /// UT_CompressionType. If the CompressType type is Automatic, then the
45  /// extension on the file is used to determine whether or not gzip
46  /// compression should be used
48  const UT_StringHolder* file_path=nullptr) const
49  {
50  return compressionType(myCompressType, file_path);
51  }
52 
53  /// Static version of the compressionType, whichc can be called without
54  /// any arguments
56  CompressType compress_type,
57  const UT_StringHolder* file_path=nullptr)
58  {
59  if (compress_type == PDG_SerializationOptions::eCompressGZip)
61  else if (compress_type == PDG_SerializationOptions::eCompressNone)
63 
64  if (!file_path || !isGZipFile(*file_path))
66 
68  }
69 
70  /// Returns true if the specified file has the .gz extension, otherwise
71  /// return false
72  static bool isGZipFile(const UT_StringHolder& file_path)
73  {
74  const char* ext = UT_StringWrap(file_path).fileExtension();
75  if (!ext)
76  return false;
77  return (SYSstrcasecmp(ext,".gz") == 0);
78  }
79 
80  /// The attribute data flattening mode
82 
83  /// Serialization compression mode
85 
86  /// Whether or not the work item should be stored as binary data
87  bool myBinary;
88 
89  /// Whether or not the serialization should recurse into batches
91 
92  /// Whether or not the serialization should be human-readable or use
93  /// minimal whitespace.
95 
96  /// Whether or not the serialization should skip fields that are
97  /// at their default value
99 
100  /// Whether or not graph level global attributes should be saved
102 
103  /// Whether or not bound attributes should be saved
105 };
106 
107 #endif
Flatten attributes, saving both dynamic and static as a mix.
CompressType myCompressType
Serialization compression mode.
char * fileExtension()
Definition: UT_String.h:640
#define PDG_API
Definition: PDG_API.h:23
bool myBinary
Whether or not the work item should be stored as binary data.
static bool isGZipFile(const UT_StringHolder &file_path)
PDG_AttributeSaveType myAttribSaveType
The attribute data flattening mode.
CompressType
Enumeration of supported file compression t ypes.
static UT_CompressionType compressionType(CompressType compress_type, const UT_StringHolder *file_path=nullptr)
bool mySaveGlobalAttributes
Whether or not graph level global attributes should be saved.
UT_CompressionType compressionType(const UT_StringHolder *file_path=nullptr) const
PDG_AttributeSaveType
Enumeration of the different ways that attributes can be saved.
bool mySaveBoundAttributes
Whether or not bound attributes should be saved.
UT_CompressionType
int SYSstrcasecmp(const char *a, const char *b)
Definition: SYS_String.h:220
bool myRecursive
Whether or not the serialization should recurse into batches.