HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_ScriptPage.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: PRM_ScriptPage.h ( PRM Library, C++)
7  *
8  * COMMENTS: A page of scripted parameters. These pages are used to define
9  * the folder tabs for each page in a std. switcher.
10  */
11 
12 #ifndef __PRM_ScriptPage__
13 #define __PRM_ScriptPage__
14 
15 #include "PRM_API.h"
16 #include <UT/UT_String.h>
17 #include <UT/UT_ValArray.h>
18 
19 #define ISERROR(msg) { is.error(msg); return 0; }
20 #define ISWARNING(msg) { is.warning(msg); }
21 
22 class DS_Stream;
23 class PRM_ScriptParm;
24 class PRM_Template;
25 class PRM_ScriptImports;
26 class PRM_SpareData;
28 
30 public:
32  virtual ~PRM_ScriptPage();
33 
34  enum {
35  PRM_SCRIPT_RMAN = 0x01, // RenderMan style command script
36  PRM_SCRIPT_SHELL = 0x02, // Shell style command script
37  PRM_SCRIPT_VEX = 0x04, // Vex style command script
38  PRM_SCRIPT_INVISIBLE = 0x08, // This group of parms is invisible
39  PRM_SCRIPT_INVISIBLETAB = 0x10, // This page of parms is invisible
40  PRM_SCRIPT_OBSOLETE = 0x20 // This group/page of parms is obsolete
41  };
42 
43  /// normally, we are parsing the whole stream & thus expect the opening
44  /// brace. However, a derived Reader might want to read some meta data,
45  /// then hand off to us, in which case expect_open_brace will be false.
46  int parse(DS_Stream &is,
47  bool expect_open_brace,
48  PRM_ScriptParm *group_owner_parm,
49  bool parsing_import,
50  bool fix_invalid_joins=true,
51  int multiparm_depth=0);
52 
53  void appendScriptParms(
55 
56  const char *getToken() const { return myToken; }
57  void setToken(const char *token) { myToken = token; }
58  const char *getLabel() const { return myLabel; }
59  const char *getDefault() const { return myDefault; }
60  PRM_ScriptParm *getParm(int i) { return myParms(i); }
61  int getParmEntries() const { return myParms.entries(); }
62  bool getBaseParm() const { return myBaseParm; }
63  bool getTabBreak() const { return myTabBreak; }
65  { return myConditionalGroup; }
67  { return myConditionalPage; }
68  PRM_SpareData *getSpareData(bool create=false);
69  void enforceOptions();
70 
71  bool containsReservedName() const;
72 
73  // Set the default if there is no default defined...
74  void setEmptyDefault(const char *str)
75  {
76  if (!myDefault.isstring())
77  myDefault.harden(str);
78  }
79 
80  void setFlag(unsigned flag) { myFlag |= flag; }
81  void clearFlag(unsigned flag) { myFlag &= ~flag; }
82  unsigned getFlag(unsigned bit) const { return myFlag & bit;}
83 
84  // By default, this will simply return the number of parameters in my page
85  virtual int countParameters() const;
86 
87  // Gets the actual number of templates required by this page, including
88  // all pages within pages and so on.
89  int computeTemplateSize();
90  // Fills an array of PRM_Templates from all our parms. The size of the
91  // array must be at least computeTemplateSize() + 1. By passing in a
92  // non-zero idx starting value the templates from this page can be
93  // appended after some existing templates.
94  void fillTemplate(PRM_Template *tplate, int &idx,
95  PRM_ScriptImports *&imports);
96 
97  // Obsolete template handling.
98  int computeObsoleteTemplateSize();
99  void fillObsoleteTemplate(PRM_Template *tplate);
100 
102  {
103  const char *token;
105  };
106 
107  /// a list of tokens not handled by PRM_ScriptPage, but which may be
108  /// handled by my subclasses or should at least be ignored without
109  /// generating an error. Each token contains the expected parameter count.
110  /// Negative values indicate tokens that take brace-enclosed blocks.
111  static const TokenParmCount theTokens[];
112 
113 protected:
114  friend class PRM_ScriptGroup;
115 
116  virtual PRM_ScriptParm *newParm();
117  virtual PRM_ScriptPage *newImportPage();
118  virtual int parseHelp(DS_Stream &is, UT_String &help);
119  virtual int handleUnknown(DS_Stream &is, UT_String &token);
120  int parseImport(DS_Stream &is,
121  int multiparm_depth);
122  void processImportPage(PRM_ScriptPage *page);
123  int parseAttribute(DS_Stream &is);
124 
125  void fillTemplate(PRM_Template *tplate, int &idx,
126  PRM_ScriptImports *&imports,
127  int nest_level, int switcher_idx,
128  int folder);
129 
130 
146  unsigned myFlag;
147 
148 };
149 
150 #endif
PRM_ScriptImports * myImports
void fillTemplate(PRM_Template *array, int &idx, PRM_ScriptImports *&imports, int nest_level)
int getParmEntries() const
void setToken(const char *token)
PRM_SpareData * mySpareData
const char * getToken() const
UT_ValArray< PRM_ScriptParm * > myObsoleteParms
std::string help(const App *app, const Error &e)
Printout the full help string on error (if this fn is set, the old default for CLI11) ...
Definition: CLI11.h:8978
UT_String myImportToken
UT_String myLabel
PRM_ConditionalGroup * getPageConditional() const
bool getBaseParm() const
PRM_ConditionalGroup * myConditionalPage
void setFlag(unsigned flag)
void setEmptyDefault(const char *str)
UT_String myImportMask
const char * getDefault() const
void clearFlag(unsigned flag)
PRM_ConditionalGroup * getGroupConditional() const
UT_String myImportSource
bool getTabBreak() const
PRM_ScriptParm * getParm(int i)
This class allow setting multiple conditionals for a PRM_Template.
const char * getLabel() const
PRM_ConditionalGroup * myConditionalGroup
UT_String myToken
UT_String myDefault
unsigned getFlag(unsigned bit) const
UT_ValArray< PRM_ScriptParm * > myParms
#define PRM_API
Definition: PRM_API.h:10