HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PI_ImportUtils.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: PI_ImportUtils.h ( PI Library, C++)
7  *
8  * COMMENTS:
9  *
10  * This class encapsulates some useful utility methods for dealing
11  * with import sources in a PI_EditScriptedParm.
12  */
13 
14 #ifndef __PI_ImportUtils_h__
15 #define __PI_ImportUtils_h__
16 
17 #include "PI_API.h"
18 #include <UT/UT_UniquePtr.h>
19 
20 class UT_String;
21 template<typename T>
23 class UT_WorkBuffer;
24 class OP_Node;
25 class PRM_ScriptPage;
26 class PRM_Parm;
27 class PRM_ScriptParm;
28 class PRM_Template;
29 
30 #define PI_IMPORTBLOCK_TOKEN "importblock"
31 
33 {
37 };
38 
40 {
41 public:
42 
43  static PI_ImportType queryImportType(const char *source);
44 
45  static void buildFolderToken(UT_WorkBuffer &buffer,
46  const char *switcher,
47  const char *folder);
48 
49  // Parse the given source string and extract the src node path. The
50  // caller is responsible for hardening the string. The node referenced
51  // in the source string, if found, is returned.
52  static OP_Node *parseOpSource(const char *source,
53  const OP_Node *relative_to,
54  UT_String &src_node_path);
55 
56  // Build the appropriate import source string given the arguments.
57  static void buildOpSource(UT_WorkBuffer &buffer,
58  const char *rel_node_path);
59 
60  // This method parses the given source string, and returns whether it
61  // refers to the specified relative node path and the given source token
62  // belongs to parm_table (which maps parameter names to PRM_Parm pointers).
63  // Folders are rejected as valid sources if they're flagged as not being
64  // available for import. Regular parameters not available for import
65  // should not be in the parm_table. Finally, this method will also reject
66  // any parameters that have changed either into or from a multiparm, an
67  // operation unsupported by a simple update.
68  static bool validateOpSource(const char *source, const char *token,
69  bool is_folder, bool is_multiparm,
70  const char *src_node_rel_path,
71  const UT_SymbolMap<PRM_Parm *> &parm_table);
72 
73  // This method checks flags on the supplied parm to determine if we can
74  // import it. The subindex is used only for switcher parms to query a
75  // specific folder.
76  static bool isAvailableForImport(const PRM_Template *templ,
77  int subindex = -1);
78  static bool isAvailableForImport(const PRM_Parm *parm,
79  int subindex = -1);
80 
81  // Parse the given source string and extract the src file path. The
82  // caller is responsible for hardening the returned string.
83  static bool parseFileSource(const char *source, UT_String &file);
84 
85  // Build the appropriate import source string given the arguments.
86  static void buildFileSource(UT_WorkBuffer &buffer,
87  const char *file_path);
88 
90  parseImportFile(const char *file);
91 
92  // This method parses the given source string, and returns whether it
93  // refers to the specified file and the given source token belongs to
94  // parm_table (which maps parameter names to PRM_ScriptParm pointers).
95  // Finally, this method will also reject any parameters that have
96  // changed either into or from a multiparm, an operation unsupported by
97  // a simple update.
98  static bool validateFileSource(const char *source,
99  const char *token, bool is_folder,
100  bool is_multiparm, const char *file,
101  const UT_SymbolMap<PRM_ScriptParm *> &parm_table);
102 };
103 
104 #endif
#define PI_API
Definition: PI_API.h:10
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
Definition: core.h:760
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
PI_ImportType