0022898: IGES import fails in german environment
[occt.git] / src / Units / Units_Unit.cxx
1 // Created on: 1992-06-24
2 // Created by: Gilles DEBARBOUILLE
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <Units_Unit.ixx>
24 #include <Units.hxx>
25 #include <Units_UnitsDictionary.hxx>
26 #include <TCollection_HAsciiString.hxx>
27 #include <TCollection_AsciiString.hxx>
28 #include <TColStd_HSequenceOfHAsciiString.hxx>
29
30 //=======================================================================
31 //function : Units_Unit
32 //purpose  : 
33 //=======================================================================
34
35 Units_Unit::Units_Unit(const Standard_CString aname,
36                        const Standard_CString asymbol,
37                        const Standard_Real avalue,
38                        const Handle(Units_Quantity)& aquantity)
39 {
40   thename       = new TCollection_HAsciiString(aname);
41   thevalue      = avalue;
42   thequantity = aquantity;
43   Handle(TCollection_HAsciiString) symbol = new TCollection_HAsciiString(asymbol);
44   thesymbolssequence = new TColStd_HSequenceOfHAsciiString();
45   thesymbolssequence->Prepend(symbol);
46 }
47
48 //=======================================================================
49 //function : Units_Unit
50 //purpose  : 
51 //=======================================================================
52
53 Units_Unit::Units_Unit(const Standard_CString aname,
54                        const Standard_CString asymbol)
55 {
56   thename       = new TCollection_HAsciiString(aname);
57   thevalue      = 0.;
58   Handle(TCollection_HAsciiString) symbol = new TCollection_HAsciiString(asymbol);
59   thesymbolssequence = new TColStd_HSequenceOfHAsciiString();
60   thesymbolssequence->Prepend(symbol);
61 }
62
63 //=======================================================================
64 //function : Units_Unit
65 //purpose  : 
66 //=======================================================================
67
68 Units_Unit::Units_Unit(const Standard_CString aname)
69 {
70   thename  = new TCollection_HAsciiString(aname);
71   thevalue = 0.;
72   thesymbolssequence = new TColStd_HSequenceOfHAsciiString();
73 }
74
75 //=======================================================================
76 //function : Symbol
77 //purpose  : 
78 //=======================================================================
79
80 void Units_Unit::Symbol(const Standard_CString asymbol)
81 {
82   Handle(TCollection_HAsciiString) symbol = new TCollection_HAsciiString(asymbol);
83   thesymbolssequence->Append(symbol);
84 }
85
86 //=======================================================================
87 //function : Token
88 //purpose  : 
89 //=======================================================================
90
91 Handle(Units_Token) Units_Unit::Token() const
92 {
93   TCollection_AsciiString string = thesymbolssequence->Value(1)->String();
94   return new Units_Token(string.ToCString()," ",thevalue,thequantity->Dimensions());
95 }
96
97 //=======================================================================
98 //function : IsEqual
99 //purpose  : 
100 //=======================================================================
101
102 Standard_Boolean Units_Unit::IsEqual(const Standard_CString astring) const
103 {
104   Standard_Integer index;
105   TCollection_AsciiString symbol;
106
107   for(index=1;index<=thesymbolssequence->Length();index++)
108     {
109       symbol = thesymbolssequence->Value(index)->String();
110       if(symbol == astring) return Standard_True;
111     }
112
113   return Standard_False;
114 }
115
116 //=======================================================================
117 //function : Dump
118 //purpose  : 
119 //=======================================================================
120
121 void Units_Unit::Dump(const Standard_Integer /*ashift*/,
122                       const Standard_Integer) const
123 {
124   Standard_Integer index;
125   TCollection_AsciiString string;
126
127 //  int i;
128 //  for(i=0; i<ashift; i++)cout<<"  ";
129   for(index=1;index<=thesymbolssequence->Length();index++)
130     {
131       string = thesymbolssequence->Value(index)->String();
132       if(index != 1) cout << " or " ;
133       cout<<"\""<<string.ToCString()<<"\"";
134     }
135   cout<< "              Name:  " <<Name().ToCString()<<"                (= " << thevalue << " SI)" <<endl;
136 }
137
138 //=======================================================================
139 //function : operator ==
140 //purpose  : 
141 //=======================================================================
142
143 Standard_Boolean operator ==(const Handle(Units_Unit)& aunit,const Standard_CString astring)
144 {
145   return aunit->IsEqual(astring);
146 }