00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects 00008 * 477 Richmond Street West 00009 * Toronto, Ontario 00010 * Canada M5V 3E7 00011 * 416-504-9876 00012 * 00013 * COMMENT: This class encapsulates all the data required to build the 00014 * "Predefined Rules" menu that is common to some OPs including 00015 * Event and Group POPs. The data is read in from a default 00016 * data file $HFS/houdini/OP<name>Rules, where 00017 * name is the OP name (ie "Event"). If a similarly named 00018 * file is in the directory containing the user's houdini 00019 * preferences, (ie $HOME/houdini), the data in that file will 00020 * override the defaults. 00021 */ 00022 00023 #ifndef __OP_PreDefRules__ 00024 #define __OP_PreDefRules__ 00025 00026 #include "OP_API.h" 00027 #include <iostream.h> 00028 #include <UT/UT_String.h> 00029 #include <UT/UT_RefArray.h> 00030 00031 class UT_IStream; 00032 00033 class OP_API OP_PreDefRules 00034 { 00035 public: 00036 // Constructor. The file_name is the 00037 // name of the file that will contain 00038 // the table data (ie OPEventRules). 00039 OP_PreDefRules(const char* file_name); 00040 00041 // Destructor does nothing. 00042 ~OP_PreDefRules(); 00043 00044 // Number of rules. 00045 int getCount() { return myRuleCount; } 00046 00047 // The identifier token. 00048 const UT_String& getToken(int i) { return myTokens(i); } 00049 00050 // This is what appears in the menu. 00051 const UT_String& getLabel(int i) { return myLabels(i); } 00052 00053 // This is the rule string that corresponds 00054 // to the menu option. It ends up in the 00055 // "Rule" parameter box. 00056 const UT_String& getString(int i) { return myStrings(i); } 00057 00058 private: 00059 // Parses a table file. '#' is a comment, 00060 // and a rule is defined as: 00061 // <token> <label> <string> 00062 bool parseFile(UT_IStream &is); 00063 00064 // Adds a rule. 00065 void addRule(char* rule_token, 00066 char* rule_label, 00067 char* rule_string); 00068 00069 int myRuleCount; 00070 UT_RefArray<UT_String> myTokens; 00071 UT_RefArray<UT_String> myLabels; 00072 UT_RefArray<UT_String> myStrings; 00073 }; 00074 00075 #endif
1.5.9