1 // Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_ScalarVariable.cxx
21 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
24 #include "SALOMEDSImpl_ScalarVariable.hxx"
25 #include "SALOMEDSImpl_GenericVariable.hxx"
32 //============================================================================
33 /*! Function : SALOMEDSImpl_ScalarVariable
36 //============================================================================
37 SALOMEDSImpl_ScalarVariable::
38 SALOMEDSImpl_ScalarVariable(SALOMEDSImpl_GenericVariable::VariableTypes type,
39 const string& theName):
40 SALOMEDSImpl_GenericVariable(type,theName)
43 //============================================================================
44 /*! Function : ~SALOMEDSImpl_ScalarVariable()
47 //============================================================================
48 SALOMEDSImpl_ScalarVariable::~SALOMEDSImpl_ScalarVariable(){}
50 //============================================================================
54 //============================================================================
55 bool SALOMEDSImpl_ScalarVariable::setValue(const double theValue)
58 if(myValue == theValue)
65 //============================================================================
69 //============================================================================
70 bool SALOMEDSImpl_ScalarVariable::setStringValue(const string& theValue)
73 if(myStrValue == theValue)
76 myStrValue = theValue;
80 //============================================================================
81 /*! Function : getValue()
84 //============================================================================
85 double SALOMEDSImpl_ScalarVariable::getValue() const
90 //============================================================================
91 /*! Function : getStringValue()
94 //============================================================================
95 string SALOMEDSImpl_ScalarVariable::getStringValue() const
100 //============================================================================
101 /*! Function : Save()
104 //============================================================================
105 string SALOMEDSImpl_ScalarVariable::Save() const{
109 case SALOMEDSImpl_GenericVariable::REAL_VAR:
111 sprintf(buffer, "%.64e", myValue);
114 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
115 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
117 sprintf(buffer, "%d", (int)myValue);
120 case SALOMEDSImpl_GenericVariable::STRING_VAR:
122 sprintf(buffer, "\"%s\"", myStrValue.c_str());
127 return string(buffer);
130 //============================================================================
131 /*! Function : SaveToScript()
134 //============================================================================
135 string SALOMEDSImpl_ScalarVariable::SaveToScript() const
140 case SALOMEDSImpl_GenericVariable::REAL_VAR:
142 sprintf(buffer, "%g", myValue);
145 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
147 sprintf(buffer, "%d", (int)myValue);
150 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
153 sprintf(buffer, "%s", "True");
155 sprintf(buffer, "%s", "False");
158 case SALOMEDSImpl_GenericVariable::STRING_VAR:
160 sprintf(buffer, "\"%s\"", myStrValue.c_str());
165 return string(buffer);
168 //============================================================================
169 /*! Function : SaveType()
172 //============================================================================
173 string SALOMEDSImpl_ScalarVariable::SaveType() const{
175 sprintf(buffer, "%d", (int)Type());
176 return string(buffer);
179 //============================================================================
180 /*! Function : Load()
183 //============================================================================
184 void SALOMEDSImpl_ScalarVariable::Load(const string& theStrValue)
186 double aValue = atof(theStrValue.c_str());