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 
19 class UT_String;
20 template<typename T>
22 class UT_WorkBuffer;
23 class OP_Node;
24 class PRM_ScriptPage;
25 class PRM_Parm;
26 class PRM_ScriptParm;
27 class PRM_Template;
28 
29 #define PI_IMPORTBLOCK_TOKEN "importblock"
30 
32 {
36 };
37 
39 {
40 public:
41 
42  static PI_ImportType queryImportType(const char *source);
43 
44  static void buildFolderToken(UT_WorkBuffer &buffer,
45  const char *switcher,
46  const char *folder);
47 
48  // Parse the given source string and extract the src node path. The
49  // caller is responsible for hardening the string. The node referenced
50  // in the source string, if found, is returned.
51  static OP_Node *parseOpSource(const char *source,
52  const OP_Node *relative_to,
53  UT_String &src_node_path);
54 
55  // Build the appropriate import source string given the arguments.
56  static void buildOpSource(UT_WorkBuffer &buffer,
57  const char *rel_node_path);
58 
59  // This method parses the given source string, and returns whether it
60  // refers to the specified relative node path and the given source token
61  // belongs to parm_table (which maps parameter names to PRM_Parm pointers).
62  // Folders are rejected as valid sources if they're flagged as not being
63  // available for import. Regular parameters not available for import
64  // should not be in the parm_table. Finally, this method will also reject
65  // any parameters that have changed either into or from a multiparm, an
66  // operation unsupported by a simple update.
67  static bool validateOpSource(const char *source, const char *token,
68  bool is_folder, bool is_multiparm,
69  const char *src_node_rel_path,
70  const UT_SymbolMap<PRM_Parm *> &parm_table);
71 
72  // This method checks flags on the supplied parm to determine if we can
73  // import it. The subindex is used only for switcher parms to query a
74  // specific folder.
75  static bool isAvailableForImport(const PRM_Template *templ,
76  int subindex = -1);
77  static bool isAvailableForImport(const PRM_Parm *parm,
78  int subindex = -1);
79 
80  // Parse the given source string and extract the src file path. The
81  // caller is responsible for hardening the returned string.
82  static bool parseFileSource(const char *source, UT_String &file);
83 
84  // Build the appropriate import source string given the arguments.
85  static void buildFileSource(UT_WorkBuffer &buffer,
86  const char *file_path);
87 
88  static PRM_ScriptPage *parseImportFile(const char *file);
89 
90  // This method parses the given source string, and returns whether it
91  // refers to the specified file and the given source token belongs to
92  // parm_table (which maps parameter names to PRM_ScriptParm pointers).
93  // Finally, this method will also reject any parameters that have
94  // changed either into or from a multiparm, an operation unsupported by
95  // a simple update.
96  static bool validateFileSource(const char *source,
97  const char *token, bool is_folder,
98  bool is_multiparm, const char *file,
99  const UT_SymbolMap<PRM_ScriptParm *> &parm_table);
100 };
101 
102 #endif
#define PI_API
Definition: PI_API.h:10
GLuint buffer
Definition: glcorearb.h:659
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
PI_ImportType