1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOME_EvalVariant.hxx
23 // Author : Peter KURNEV
26 #ifndef SALOME_EvalVariant_Header_File
27 #define SALOME_EvalVariant_Header_File
30 #pragma warning(disable : 4786)
36 #include <SALOME_Eval.hxx>
40 typedef unsigned int uint;
43 class SALOME_EvalVariant;
44 class SALOME_EvalVariantData;
45 typedef list<SALOME_EvalVariant> SALOME_ListOfEvalVariant;
47 // SALOME_EvalVariantType
48 enum SALOME_EvalVariantType {
49 SALOME_EvalVariant_Invalid,
50 SALOME_EvalVariant_Boolean,
51 SALOME_EvalVariant_Int,
52 SALOME_EvalVariant_UInt,
53 SALOME_EvalVariant_Double,
54 SALOME_EvalVariant_String,
55 SALOME_EvalVariant_List
58 typedef list<SALOME_EvalVariantType> SALOME_ListOfEvalVariantType;
60 typedef set<SALOME_EvalVariantType> SALOME_SetOfEvalVariantType;
61 typedef SALOME_SetOfEvalVariantType::iterator SALOME_SetIteratorOfSetOfEvalVariantType;
62 typedef pair<SALOME_SetIteratorOfSetOfEvalVariantType, bool> SALOME_SetPairOfEvalVariantType;
64 //=======================================================================
65 //union : SALOME_EvalVariantValue
67 //=======================================================================
68 union SALOME_EvalVariantValue {
75 //=======================================================================
76 //class : SALOME_EvalVariantData
78 //=======================================================================
79 class SALOME_EvalVariantData {
81 SALOME_EvalVariantData(){
82 myType=SALOME_EvalVariant_Invalid;
83 myValue.myBoolean=false;
90 ~SALOME_EvalVariantData(){
94 SALOME_EvalVariantData(const SALOME_EvalVariantData& other);
95 SALOME_EvalVariantData& operator=(const SALOME_EvalVariantData& other);
96 bool operator==(const SALOME_EvalVariantData& other) const;
99 if (myType==SALOME_EvalVariant_String) {
101 SALOME_String *pStr=(SALOME_String *)myValue.myPtr;
107 else if (myType==SALOME_EvalVariant_List) {
109 SALOME_ListOfEvalVariant *p=(SALOME_ListOfEvalVariant *)myValue.myPtr;
115 myValue.myBoolean=false;
123 SALOME_EvalVariantType myType;
124 SALOME_EvalVariantValue myValue;
126 //=======================================================================
127 //class : SALOME_EvalVariant
129 //=======================================================================
130 class SALOME_EvalVariant
138 ~SALOME_EvalVariant()
144 SALOME_EvalVariant(const SALOME_EvalVariant& other) : myData(other.myData)
148 SALOME_EvalVariant& operator=(const SALOME_EvalVariant& other) {
153 bool operator==(const SALOME_EvalVariant& theOther) const {
154 return myData==theOther.myData;;
158 void operator=(const SALOME_String& aString);
159 void operator=(const bool theValue);
160 void operator=(const int theValue);
161 void operator=(const uint theValue);
162 void operator=(const double theValue);
163 void operator=(const char* theValue);
165 SALOME_EvalVariant(bool b);
166 SALOME_EvalVariant(int i);
167 SALOME_EvalVariant(uint ui);
168 SALOME_EvalVariant(double d);
169 SALOME_EvalVariant(const SALOME_String& s);
170 SALOME_EvalVariant(const SALOME_ListOfEvalVariant& s);
172 SALOME_EvalVariantType type() const {
176 bool isValid() const {
177 return type()!=SALOME_EvalVariant_Invalid;
180 bool isNull() const {
189 int toInt(bool *ok) const;
190 uint toUInt(bool *ok) const;
191 double toDouble(bool *ok) const;
192 SALOME_String toString() const;
193 SALOME_ListOfEvalVariant toList() const;
195 const SALOME_EvalVariantData& Data() const{
199 static bool contains(const SALOME_ListOfEvalVariant& aL,
200 const SALOME_EvalVariant& aV);
203 SALOME_EvalVariantType& ChangeDataType() {
204 return ChangeData().myType;
207 SALOME_EvalVariantData& ChangeData() {
211 SALOME_EvalVariantValue& ChangeDataValue() {
212 return ChangeData().myValue;
215 bool& ChangeDataValueBoolean() {
216 return ChangeDataValue().myBoolean;
219 int& ChangeDataValueInt() {
220 return ChangeDataValue().myInt;
223 uint& ChangeDataValueUInt() {
224 return ChangeDataValue().myUInt;
227 double& ChangeDataValueDouble() {
228 return ChangeDataValue().myDouble;
231 const SALOME_EvalVariantType& DataType() const{
232 return Data().myType;
235 const SALOME_EvalVariantValue& DataValue() const{
236 return Data().myValue;
239 bool DataValueBoolean() const {
240 return DataValue().myBoolean;
243 int DataValueInt() const {
244 return DataValue().myInt;
247 uint DataValueUInt() const {
248 return DataValue().myUInt;
251 double DataValueDouble() const {
252 return DataValue().myDouble;
255 const SALOME_String& DataValueString() const {
256 return *((string *)(DataValue().myPtr));
259 const SALOME_ListOfEvalVariant& DataValueList() const {
260 return *((SALOME_ListOfEvalVariant *)(DataValue().myPtr));
264 SALOME_EvalVariantData myData;// data itself