0023072: Eliminate compiler warnings (level 3) on Windows / MSVC++
[occt.git] / src / StepData / StepData_EnumTool.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 #include <StepData_EnumTool.ixx>
19
20 static TCollection_AsciiString nulstr("");
21
22 StepData_EnumTool::StepData_EnumTool
23   (const Standard_CString e0, const Standard_CString e1,
24    const Standard_CString e2, const Standard_CString e3,
25    const Standard_CString e4, const Standard_CString e5,
26    const Standard_CString e6, const Standard_CString e7,
27    const Standard_CString e8, const Standard_CString e9,
28    const Standard_CString e10,const Standard_CString e11,
29    const Standard_CString e12,const Standard_CString e13,
30    const Standard_CString e14,const Standard_CString e15,
31    const Standard_CString e16,const Standard_CString e17,
32    const Standard_CString e18,const Standard_CString e19,
33    const Standard_CString e20,const Standard_CString e21,
34    const Standard_CString e22,const Standard_CString e23,
35    const Standard_CString e24,const Standard_CString e25,
36    const Standard_CString e26,const Standard_CString e27,
37    const Standard_CString e28,const Standard_CString e29,
38    const Standard_CString e30,const Standard_CString e31,
39    const Standard_CString e32,const Standard_CString e33,
40    const Standard_CString e34,const Standard_CString e35,
41    const Standard_CString e36,const Standard_CString e37,
42    const Standard_CString e38,const Standard_CString e39)
43 {
44   AddDefinition (e0);   AddDefinition (e1);   AddDefinition (e2);
45   AddDefinition (e3);   AddDefinition (e4);   AddDefinition (e5);
46   AddDefinition (e6);   AddDefinition (e7);   AddDefinition (e8);
47   AddDefinition (e9);   AddDefinition (e10);  AddDefinition (e11);
48   AddDefinition (e12);  AddDefinition (e13);  AddDefinition (e14);
49   AddDefinition (e15);  AddDefinition (e16);  AddDefinition (e17);
50   AddDefinition (e18);  AddDefinition (e19);  AddDefinition (e20);
51   AddDefinition (e21);  AddDefinition (e22);  AddDefinition (e23);
52   AddDefinition (e24);  AddDefinition (e25);  AddDefinition (e26);
53   AddDefinition (e27);  AddDefinition (e28);  AddDefinition (e29);
54   AddDefinition (e30);  AddDefinition (e31);  AddDefinition (e32);
55   AddDefinition (e33);  AddDefinition (e34);  AddDefinition (e35);
56   AddDefinition (e36);  AddDefinition (e37);  AddDefinition (e38);
57   AddDefinition (e39);
58   theinit = thetexts.Length();  theopt = Standard_True;
59 }
60
61     void  StepData_EnumTool::AddDefinition (const Standard_CString term)
62 {
63   char text[80];
64   if (!term) return;
65   if (term[0] == '\0') return;
66   Standard_Integer n0 = 0, n1 = 0;
67   for (; term[n0] != '\0'; n0 ++)  {
68     if (term[n0] <= 32) {
69       if (n1 == 0) continue;
70       if (n1 > 1 || text[0] != '$') {
71         if (text[n1-1] != '.')  {  text[n1] = '.';  n1 ++;  }
72         text[n1] = '\0';
73       }
74       thetexts.Append ( TCollection_AsciiString(text) );
75       n1 = 0;
76     }
77     if (n1 == 0 && term[n0] != '.' && term[n0] != '$')  {  text[0] = '.';   n1 ++;  }
78     text[n1] = term[n0];  n1 ++;
79   }
80   if (n1 > 0 || text[0] != '$') {
81     if (text[n1-1] != '.')  {  text[n1] = '.';  n1 ++;  }
82     text[n1] = '\0';
83   }
84   if (text[n1-1] != '.')  {  text[n1] = '.';  n1 ++;  }
85   text[n1] = '\0';
86   thetexts.Append ( TCollection_AsciiString(text) );
87 }
88
89     Standard_Boolean  StepData_EnumTool::IsSet () const
90       {  return (thetexts.Length() > theinit);  }
91
92     Standard_Integer  StepData_EnumTool::MaxValue () const
93       {  return thetexts.Length() - 1;  }
94
95     void  StepData_EnumTool::Optional (const Standard_Boolean mode)
96       {  theopt = mode;  }
97
98     Standard_Integer  StepData_EnumTool::NullValue () const
99       {  return (theopt ? Value("$") : Standard_False);  }
100
101     const TCollection_AsciiString&  StepData_EnumTool::Text
102   (const Standard_Integer num) const
103 {
104   if (num < 0 || num >= thetexts.Length()) return nulstr;
105   return thetexts.Value (num+1);
106 }
107
108     Standard_Integer  StepData_EnumTool::Value
109   (const Standard_CString txt) const
110 {
111   Standard_Integer nb = thetexts.Length();
112   for (Standard_Integer i = 1; i <= nb; i ++) {
113     if (thetexts.Value(i).IsEqual(txt)) return i-1;
114   }
115   return (-1);
116 }
117
118     Standard_Integer  StepData_EnumTool::Value
119   (const TCollection_AsciiString& txt) const
120 {
121   Standard_Integer nb = thetexts.Length();
122   for (Standard_Integer i = 1; i <= nb; i ++) {
123     if (thetexts.Value(i).IsEqual(txt)) return i-1;
124   }
125   return (-1);
126 }