Salome HOME
1b62cddfc59dc8d124105dc6119955c91e9a69b0
[modules/shaper.git] / src / ModelAPI / ModelAPI_Expression.cpp
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ModelAPI_Expression.h"
21
22 #include <Locale_Convert.h>
23
24 #include <cwctype>
25
26 ModelAPI_Expression::ModelAPI_Expression()
27 {
28
29 }
30
31 ModelAPI_Expression::~ModelAPI_Expression()
32 {
33
34 }
35
36 bool ModelAPI_Expression::isInitialized()
37 {
38   return myIsInitialized;
39 }
40
41 void ModelAPI_Expression::setInitialized()
42 {
43   myIsInitialized = true;
44 }
45
46 ModelAPI_ExpressionDouble::ModelAPI_ExpressionDouble()
47 {
48
49 }
50
51 ModelAPI_ExpressionInteger::ModelAPI_ExpressionInteger()
52 {
53
54
55 }
56
57 bool ModelAPI_Expression::isVariable(const std::string& theString)
58 {
59   return isVariable(Locale::Convert::toWString(theString));
60 }
61
62 bool ModelAPI_Expression::isVariable(const std::wstring& theString)
63 {
64   if (theString.empty())
65     return false;
66   try {
67     std::wstring::const_iterator it = theString.begin();
68     if (!(iswalpha(*it) || (*it) == L'_') || it == theString.end())
69       return false;
70     it++;
71     for ( ; it != theString.end(); ++it ) {
72       if(!(iswalnum(*it) || (*it) == L'_')) {
73         return false;
74       }
75     }
76   } catch(...) {
77     return false;
78   }
79   return true;
80 }
81