Changeset 209
- Timestamp:
- 02/07/08 14:40:49 (4 years ago)
- Files:
-
- branches/2.3.2beta3/src/include/preference.h (modified) (2 diffs)
- branches/2.3.2beta3/src/preference.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.3.2beta3/src/include/preference.h
r38 r209 15 15 */ 16 16 17 /** 18 * \file preference.h 19 * Preference definition class. 20 * \author François Ingelrest 21 * \author Andrew Schofield 22 **/ 23 17 24 #ifndef _PREFERENCE_H 18 25 #define _PREFERENCE_H … … 24 31 25 32 26 // Storage class for the value of a preference 33 /** 34 * Class for storing preference values. 35 **/ 27 36 class Preference 28 37 { 29 38 protected: 30 31 // Order *MUST* not be changed 32 // This is for compatibility with older versions 39 /** 40 * Preference definition. 41 * The order must not be changed to maintain compatibility with older versions. 42 **/ 33 43 enum _PREF_TYPE 34 44 { 35 PT_BOOL, 36 PT_UINT, 37 PT_INT, 38 PT_DOUBLE, 39 PT_STRING, 40 PT_UNKNOWN, 41 PT_HIDDEN_STRING // Used for string that should not be directly "human-readable" from the disk45 PT_BOOL, /**< Boolean preference */ 46 PT_UINT, /**< Unsigned integer preference */ 47 PT_INT, /**< Signed integer preference */ 48 PT_DOUBLE, /**< Double preference */ 49 PT_STRING, /**< String preference */ 50 PT_UNKNOWN, /**< Unknown preference */ 51 PT_HIDDEN_STRING /**< Hidden string. Used for string that should not be directly "human-readable" from the disk */ 42 52 }; 43 53 44 54 45 PrefType mPrefType; 46 wxString mPrefName; 47 wxString mStringValue; // Used for both PT_STRING and PT_HIDDEN_STRING48 wxUint32 mUintValue; 49 wxInt32 mIntValue; 50 double mDoubleValue; 51 bool mBoolValue; 55 PrefType mPrefType; /**< The preference type */ 56 wxString mPrefName; /**< Preference name */ 57 wxString mStringValue; /**< String value. Used for both PT_STRING and PT_HIDDEN_STRING */ 58 wxUint32 mUintValue; /**< Unsigned integer value */ 59 wxInt32 mIntValue; /**< Signed integer value */ 60 double mDoubleValue; /**< Double value */ 61 bool mBoolValue; /**< Boolean value */ 52 62 53 63 54 64 public: 65 /** 66 * Null contructor. 67 **/ 55 68 Preference(void); 69 70 /** 71 * Constructor for boolean prefs. 72 * @param name Preference name. 73 * @param value Boolean value 74 **/ 56 75 Preference(wxString name, bool value); 76 77 /** 78 * Contructor for double prefs. 79 * @param name Preference name. 80 * @param value Double value 81 **/ 57 82 Preference(wxString name, double value); 83 84 /** 85 * Contructor for signed integer prefs. 86 * @param name Preference name. 87 * @param value Int32 value 88 **/ 58 89 Preference(wxString name, wxInt32 value); 90 91 /** 92 * Contructor for unsigned integer prefs. 93 * @param name Preference name. 94 * @param value Uint32 value 95 **/ 59 96 Preference(wxString name, wxUint32 value); 97 98 /** 99 * Contructor for string and hidden string prefs. 100 * @param name Preference name. 101 * @param value string value 102 * @param isHidden Hidden state 103 **/ 60 104 Preference(wxString name, const wxString& value, bool isHidden = false); 61 105 106 /** 107 * Read the preference from the given input stream. 108 * @param in The input data stream. 109 **/ 62 110 void Read(DataInputStream& in); 111 112 /** 113 * Write this preference to the given output stream. 114 * @param out The output data stream. 115 **/ 63 116 void Write(DataOutputStream& out) const; 64 117 118 /** 119 * Checks if preference is boolean. 120 **/ 65 121 bool IsABoolPref(void) const {return mPrefType == PT_BOOL;} 122 123 /** 124 * Checks if preference is a signed integer. 125 **/ 66 126 bool IsAnIntPref(void) const {return mPrefType == PT_INT;} 127 128 /** 129 * Checks if preference is an unsigned integer. 130 **/ 67 131 bool IsAnUintPref(void) const {return mPrefType == PT_UINT;} 132 133 /** 134 * Checks if preference is a double. 135 **/ 68 136 bool IsADoublePref(void) const {return mPrefType == PT_DOUBLE;} 137 138 /** 139 * Checks if preference is a string. 140 **/ 69 141 bool IsAStringPref(void) const {return mPrefType == PT_STRING;} 142 143 /** 144 * Checks if preference is an hidden string. 145 **/ 70 146 bool IsAnHiddenStringPref(void) const {return mPrefType == PT_HIDDEN_STRING;} 71 147 72 148 // --- Getters 149 /** 150 * Get boolean value of preference. 151 **/ 73 152 bool GetBoolValue(void) const {return mBoolValue;} 153 154 /** 155 * Get double value of preference. 156 **/ 74 157 double GetDoubleValue(void) const {return mDoubleValue;} 158 159 /** 160 * Get int32 value of preference. 161 **/ 75 162 wxInt32 GetIntValue(void) const {return mIntValue;} 163 164 /** 165 * Get name of preference. 166 **/ 76 167 wxString GetName(void) const {return mPrefName;} 168 169 /** 170 * Get string value of preference. 171 **/ 77 172 wxString GetStringValue(void) const {return mStringValue;} 173 174 /** 175 * Get hidden string value of preference. 176 **/ 78 177 wxString GetHiddenStringValue(void) const {return mStringValue;} 178 179 /** 180 * Get uint32 value of preference. 181 **/ 79 182 wxUint32 GetUintValue(void) const {return mUintValue;} 80 183 }; branches/2.3.2beta3/src/preference.cpp
r148 r209 15 15 */ 16 16 17 /** 18 * \file preference.cpp 19 * Preference definition class. 20 * \author François Ingelrest 21 * \author Andrew Schofield 22 **/ 23 17 24 #include "preference.h" 18 25 … … 20 27 21 28 22 /**23 * Constructor24 **/25 29 Preference::Preference(void) 26 30 { … … 30 34 31 35 32 /**33 * Constructor34 **/35 36 Preference::Preference(wxString name, bool value) 36 37 { … … 41 42 42 43 43 /**44 * Constructor45 **/46 44 Preference::Preference(wxString name, wxUint32 value) 47 45 { … … 52 50 53 51 54 /**55 * Constructor56 **/57 52 Preference::Preference(wxString name, wxInt32 value) 58 53 { … … 63 58 64 59 65 /**66 * Constructor67 **/68 60 Preference::Preference(wxString name, double value) 69 61 { … … 74 66 75 67 76 /**77 * Constructor78 **/79 68 Preference::Preference(wxString name, const wxString& value, bool isHidden) 80 69 { … … 95 84 96 85 97 /**98 * Read the preference from the given input stream99 **/100 86 void Preference::Read(DataInputStream& in) 101 87 { … … 141 127 142 128 143 /**144 * Write this preference to the given output stream145 **/146 129 void Preference::Write(DataOutputStream& out) const 147 130 {
