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"
31 //============================================================================
32 /*! Function : SALOMEDSImpl_ScalarVariable
35 //============================================================================
36 SALOMEDSImpl_ScalarVariable::
37 SALOMEDSImpl_ScalarVariable(SALOMEDSImpl_GenericVariable::VariableTypes type,
38 const string& theName):
39 SALOMEDSImpl_GenericVariable(type,theName)
42 //============================================================================
43 /*! Function : ~SALOMEDSImpl_ScalarVariable()
46 //============================================================================
47 SALOMEDSImpl_ScalarVariable::~SALOMEDSImpl_ScalarVariable(){}
49 //============================================================================
53 //============================================================================
54 bool SALOMEDSImpl_ScalarVariable::setValue(const double theValue)
57 if(myValue == theValue)
64 //============================================================================
68 //============================================================================
69 bool SALOMEDSImpl_ScalarVariable::setStringValue(const string& theValue)
72 if(myStrValue == theValue)
75 myStrValue = theValue;
79 //============================================================================
80 /*! Function : getValue()
83 //============================================================================
84 double SALOMEDSImpl_ScalarVariable::getValue() const
89 //============================================================================
90 /*! Function : getStringValue()
93 //============================================================================
94 string SALOMEDSImpl_ScalarVariable::getStringValue() const
99 //============================================================================
100 /*! Function : Save()
103 //============================================================================
104 string SALOMEDSImpl_ScalarVariable::Save() const{
108 case SALOMEDSImpl_GenericVariable::REAL_VAR:
110 sprintf(buffer, "%.64e", myValue);
113 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
114 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
116 sprintf(buffer, "%d", (int)myValue);
119 case SALOMEDSImpl_GenericVariable::STRING_VAR:
121 sprintf(buffer, "\"%s\"", myStrValue.c_str());
126 return string(buffer);
129 //============================================================================
130 /*! Function : SaveToScript()
133 //============================================================================
134 string SALOMEDSImpl_ScalarVariable::SaveToScript() const
139 case SALOMEDSImpl_GenericVariable::REAL_VAR:
141 sprintf(buffer, "%g", myValue);
144 case SALOMEDSImpl_GenericVariable::INTEGER_VAR:
146 sprintf(buffer, "%d", (int)myValue);
149 case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR:
152 sprintf(buffer, "%s", "True");
154 sprintf(buffer, "%s", "False");
157 case SALOMEDSImpl_GenericVariable::STRING_VAR:
159 sprintf(buffer, "\"%s\"", myStrValue.c_str());
164 return string(buffer);
167 //============================================================================
168 /*! Function : SaveType()
171 //============================================================================
172 string SALOMEDSImpl_ScalarVariable::SaveType() const{
174 sprintf(buffer, "%d", (int)Type());
175 return string(buffer);
178 //============================================================================
179 /*! Function : Load()
182 //============================================================================
183 void SALOMEDSImpl_ScalarVariable::Load(const string& theStrValue)
185 double aValue = atof(theStrValue.c_str());