HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_PreDefRules.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  * COMMENT: This class encapsulates all the data required to build the
7  * "Predefined Rules" menu that is common to some OPs including
8  * Event and Group POPs. The data is read in from a default
9  * data file $HFS/houdini/OP<name>Rules, where
10  * name is the OP name (ie "Event"). If a similarly named
11  * file is in the directory containing the user's houdini
12  * preferences, (ie $HOME/houdini), the data in that file will
13  * override the defaults.
14  */
15 
16 #ifndef __OP_PreDefRules__
17 #define __OP_PreDefRules__
18 
19 #include "OP_API.h"
20 #include <UT/UT_StringArray.h>
21 
22 class UT_IStream;
23 
25 {
26 public:
27  // Constructor. The file_name is the
28  // name of the file that will contain
29  // the table data (ie OPEventRules).
30  OP_PreDefRules(const char* file_name);
31 
32  // Destructor does nothing.
33  ~OP_PreDefRules();
34 
35  // Number of rules.
36  int getCount() { return myTokens.entries(); }
37 
38  // The identifier token.
39  const char *getToken(int i) { return myTokens(i); }
40 
41  // This is what appears in the menu.
42  const char *getLabel(int i) { return myLabels(i); }
43 
44  // This is the rule string that corresponds
45  // to the menu option. It ends up in the
46  // "Rule" parameter box.
47  const char *getString(int i) { return myStrings(i); }
48 
49 private:
50  // Parses a table file. '#' is a comment,
51  // and a rule is defined as:
52  // <token> <label> <string>
53  bool parseFile(UT_IStream &is);
54 
55  // Adds a rule.
56  void addRule(char* rule_token,
57  char* rule_label,
58  char* rule_string);
59 
60  UT_StringArray myTokens;
61  UT_StringArray myLabels;
62  UT_StringArray myStrings;
63 };
64 
65 #endif
const char * getLabel(int i)
const char * getString(int i)
const char * getToken(int i)
#define OP_API
Definition: OP_API.h:10