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 * Mark Elendt 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: PRM_DisableList.h ( PRM Library, C++) 00015 * 00016 * COMMENTS: Disable information based on a disable when string. 00017 */ 00018 00019 #ifndef __PRM_DisableList__ 00020 #define __PRM_DisableList__ 00021 00022 #include "PRM_API.h" 00023 #include <UT/UT_IntArray.h> 00024 #include <UT/UT_PtrArray.h> 00025 #include <UT/UT_StringArray.h> 00026 00027 class PRM_API PRM_DisableInfo 00028 { 00029 public: 00030 PRM_DisableInfo() 00031 { } 00032 ~PRM_DisableInfo() 00033 { } 00034 00035 // Create a new instance of the disable information for parameters 00036 // contained within multi-parms. 00037 PRM_DisableInfo *instance(UT_IntArray &idx); 00038 00039 const PRM_DisableInfo &operator=(const PRM_DisableInfo &src) 00040 { 00041 myControlParms = src.myControlParms; 00042 myControlValues = src.myControlValues; 00043 myTestOperators = src.myTestOperators; 00044 00045 return *this; 00046 } 00047 00048 void clear() 00049 { 00050 myControlParms.clear(); 00051 myControlValues.clear(); 00052 myTestOperators.resize(0); 00053 } 00054 void addInfo(const char *parm, 00055 const char *value, 00056 const char *testoperator) 00057 { 00058 myControlParms.append(parm); 00059 myControlValues.append(value); 00060 myTestOperators.append(testoperator); 00061 } 00062 00063 const UT_StringArray &getControlParms() const 00064 { return myControlParms; } 00065 const UT_StringArray &getControlValues() const 00066 { return myControlValues; } 00067 const UT_StringArray &getTestOperators() const 00068 { return myTestOperators; } 00069 00070 private: 00071 UT_StringArray myControlParms; 00072 UT_StringArray myControlValues; 00073 UT_StringArray myTestOperators; 00074 }; 00075 00076 class PRM_API PRM_DisableList 00077 { 00078 public: 00079 PRM_DisableList(); 00080 explicit PRM_DisableList(const char *disable); 00081 ~PRM_DisableList(); 00082 00083 // Create a new disable list for use within multi-parms. Since the disable 00084 // information may be dependent on the index of the multiparm, we need to 00085 // replace any #'s in the disable info's with the actual index. 00086 PRM_DisableList *instance(UT_IntArray &idx); 00087 00088 int entries() const; 00089 const PRM_DisableInfo *operator()(int index) const; 00090 const PRM_DisableList &operator=(const PRM_DisableList &src); 00091 00092 void clear(); 00093 PRM_DisableInfo *addInfo(); 00094 00095 void getStringFromList(UT_String &str) const; 00096 void getStringFromList(UT_String &str, 00097 const UT_StringArray &validparms) const; 00098 bool setListFromString(const char *disable, 00099 UT_String &error); 00100 00101 // Verifies the provided string is in proper disable format. 00102 // Proper format is: 00103 // All non-whitespace is enclosed in { }. 00104 // Each { or } has whitespace seperating it from its neighbours. 00105 // Inside brackets, each parm name has a value paired to it. 00106 // All open quotes have matching close quotes. 00107 static bool verifyDisableString(const char *disable, 00108 UT_String &error); 00109 00110 static bool isValidOperator(const char *testoperator); 00111 00112 private: 00113 void getStringFromList(UT_String &str, 00114 const UT_StringArray *validparms) const; 00115 00116 UT_PtrArray<PRM_DisableInfo *> myDisableInfos; 00117 }; 00118 00119 #endif 00120
1.5.9