HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_IOTable.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: IO table definition
7  *
8  * COMMENTS: This class can be used to initialize an IO table for
9  * use in other libraries. For example, to use this class
10  * you can have a static instansiation giving the desired
11  * table name:
12  * static UT_IOTable fbIOtable("FBio", 3)
13  *
14  */
15 
16 #ifndef __UT_IOTable_h__
17 #define __UT_IOTable_h__
18 
19 #include "UT_API.h"
20 #include "UT_Array.h"
21 #include "UT_LinkList.h"
22 #include "UT_String.h"
23 
24 // Instantiating a static UT_IOTable requires that the static data in
25 // <tools/henv.C> has already been initialized. Our current mechanism
26 // for ensuring this is to include the header.
27 #include <tools/henv.h>
28 
30 {
31 public:
32  UT_IOEntry(const char *ext, const char *magic, const char *read,
33  const char *write);
34  ~UT_IOEntry() override;
35 
36  UT_IOEntry(const UT_IOEntry &) = delete;
37  UT_IOEntry &operator=(const UT_IOEntry &) = delete;
38 
39  UT_String extension; // File extension
40  unsigned magic; // Magic number
41  UT_String readFrom; // Command to read from an external file type
42  UT_String writeTo; // Command to write to the external file type
43 
44  //
45  // In cases where there are more than three arguments on each
46  // line of the table, the following structure is filled up with
47  // duplicates of each argument
48  //
49  char **argv;
50 };
51 
53 {
54 public:
55  UT_IOTable(const char *path, char commentChar='#');
56  ~UT_IOTable() override;
57 
58  UT_IOTable(const UT_IOTable &) = delete;
59  UT_IOTable &operator=(const UT_IOTable &) = delete;
60 
61  const UT_IOEntry *findExtension(const UT_String &filename) const;
62  const UT_IOEntry *findMagic(unsigned magic) const;
63 };
64 
66 {
67 public:
68  UT_ExtensionList(const char *filepath, const char *iopath=0);
69  int findExtension(const char *extension) const;
70  int hasSuffix(const char *filename) const;
71  /// Add given extension to the list, if it doesn't already exist.
72  void addExtension(const char *extension);
73  int getExtensions(UT_Array<const char *> &list) const;
74  int readFile(const char *filepath);
75  int readIOFile(const char *filepath);
76 
77 private:
78  char **array;
79  int entries;
80 };
81 
85 
88 UT_API extern UT_IOTable *UTgetIOTable(const char *filename);
89 
91 UT_API extern UT_IOTable *UTgetChanTable(const char *filename);
92 
99 
103 
104 #endif
UT_API UT_ExtensionList * UTgetI3dExtensions()
GT_API const UT_StringHolder filename
Definition: UT_IOTable.h:29
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UT_String readFrom
Definition: UT_IOTable.h:41
UT_API UT_ExtensionList * UTgetPicExtensions()
#define UT_API
Definition: UT_API.h:14
UT_API UT_ExtensionList * UTgetSimExtensions()
UT_API UT_ExtensionList * UTgetMidiExtensions()
void read(T &in, bool &v)
Definition: ImfXdr.h:502
char ** argv
Definition: UT_IOTable.h:49
UT_API UT_ExtensionList * UTgetLutExtensions()
UT_API UT_ExtensionList * UTgetUsdExtensions()
UT_API UT_ExtensionList * UTgetGltfExtensions()
UT_API UT_ExtensionList * UTgetCaptExtensions()
UT_API UT_ExtensionList * UTgetChanExtensions()
UT_API UT_ExtensionList * UTgetRampExtensions()
UT_String extension
Definition: UT_IOTable.h:39
unsigned magic
Definition: UT_IOTable.h:40
UT_String writeTo
Definition: UT_IOTable.h:42
UT_API UT_IOTable * UTgetChanTable(const char *filename)
UT_API UT_ExtensionList * UTgetCmdExtensions()
virtual bool readFile(GA_Detail &g, const char *filename, const GA_LoadOptions *opts, UT_StringArray *errors) const
Class which defines an I/O interface to save/load geometry.
UT_API UT_ExtensionList * UTgetGeoExtensions()
UT_API UT_ExtensionList * UTgetSqliteExtensions()
void write(T &out, bool v)
Definition: ImfXdr.h:287
UT_API UT_IOTable * UTgetIOTable(const char *filename)
UT_API UT_ExtensionList * UTgetSimdataExtensions()
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
UT_API UT_ExtensionList * UTgetHipExtensions()