9048b3c47c2404e45e27a60d05c37ac3f5509ac1
[occt.git] / src / Units / Units_Token.hxx
1 // Created on: 1992-06-22
2 // Created by: Gilles DEBARBOUILLE
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Units_Token_HeaderFile
18 #define _Units_Token_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TCollection_AsciiString.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Transient.hxx>
26 #include <Standard_CString.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Standard_Boolean.hxx>
29 class Units_Dimensions;
30
31
32 class Units_Token;
33 DEFINE_STANDARD_HANDLE(Units_Token, Standard_Transient)
34
35 //! This class defines an elementary word contained in
36 //! a Sentence object.
37 class Units_Token : public Standard_Transient
38 {
39
40 public:
41
42   
43   //! Creates and returns a empty token.
44   Standard_EXPORT Units_Token();
45   
46   //! Creates  and returns  a token.   <aword>  is  a string
47   //! containing the available word.
48   Standard_EXPORT Units_Token(const Standard_CString aword);
49   
50   //! Creates and returns a  token.  <atoken> is  copied  in
51   //! the returned token.
52   Standard_EXPORT Units_Token(const Handle(Units_Token)& atoken);
53   
54   //! Creates  and  returns a  token.   <aword> is  a string
55   //! containing the  available word and  <amean>  gives the
56   //! signification of the token.
57   Standard_EXPORT Units_Token(const Standard_CString aword, const Standard_CString amean);
58   
59   //! Creates   and  returns a  token.   <aword> is a string
60   //! containing   the available  word,  <amean> gives   the
61   //! signification of the token and <avalue> is the numeric
62   //! value of the dimension.
63   Standard_EXPORT Units_Token(const Standard_CString aword, const Standard_CString amean, const Standard_Real avalue);
64   
65   //! Creates and returns  a  token.  <aword> is   a  string
66   //! containing the   available   word, <amean>   gives the
67   //! signification of  the  token, <avalue> is  the numeric
68   //! value  of the dimension,  and <adimensions>   is   the
69   //! dimension of the given word <aword>.
70   Standard_EXPORT Units_Token(const Standard_CString aword, const Standard_CString amean, const Standard_Real avalue, const Handle(Units_Dimensions)& adimension);
71   
72   //! Creates and returns a  token, which is a ShiftedToken.
73   Standard_EXPORT virtual Handle(Units_Token) Creates() const;
74   
75   //! Returns the length of the word.
76   Standard_EXPORT Standard_Integer Length() const;
77   
78   //! Returns the string <theword>
79     TCollection_AsciiString Word() const;
80   
81   //! Sets the field <theword> to <aword>.
82     void Word (const Standard_CString aword);
83   
84   //! Returns the significance of the word  <theword>, which
85   //! is in the field <themean>.
86     TCollection_AsciiString Mean() const;
87   
88   //! Sets the field <themean> to <amean>.
89     void Mean (const Standard_CString amean);
90   
91   //! Returns the value stored in the field <thevalue>.
92     Standard_Real Value() const;
93   
94   //! Sets the field <thevalue> to <avalue>.
95     void Value (const Standard_Real avalue);
96   
97   //! Returns the dimensions of the token <thedimensions>.
98     Handle(Units_Dimensions) Dimensions() const;
99   
100   //! Sets the field <thedimensions> to <adimensions>.
101   Standard_EXPORT void Dimensions (const Handle(Units_Dimensions)& adimensions);
102   
103   //! Updates     the  token  <me>    with  the   additional
104   //! signification  <amean> by  concatenation   of the  two
105   //! strings   <themean>    and   <amean>.   If    the  two
106   //! significations are  the same  , an information message
107   //! is written in the output device.
108   Standard_EXPORT void Update (const Standard_CString amean);
109   
110   Standard_EXPORT Handle(Units_Token) Add (const Standard_Integer aninteger) const;
111   
112   //! Returns a  token which is  the addition  of  <me>  and
113   //! another token <atoken>. The  addition  is  possible if
114   //! and only if the dimensions are the same.
115   Standard_EXPORT Handle(Units_Token) Add (const Handle(Units_Token)& atoken) const;
116   
117   //! Returns a token  which is the  subtraction of <me> and
118   //! another token <atoken>. The subtraction is possible if
119   //! and only if the dimensions are the same.
120   Standard_EXPORT Handle(Units_Token) Subtract (const Handle(Units_Token)& atoken) const;
121   
122   //! Returns a  token  which  is the  product of   <me> and
123   //! another token <atoken>.
124   Standard_EXPORT Handle(Units_Token) Multiply (const Handle(Units_Token)& atoken) const;
125   
126   //! This   virtual method is   called  by  the Measurement
127   //! methods,  to  compute    the   measurement   during  a
128   //! conversion.
129   Standard_EXPORT Standard_NODISCARD virtual Standard_Real Multiplied (const Standard_Real avalue) const;
130   
131   //! Returns a token which is the division of <me> by another
132   //! token <atoken>.
133   Standard_EXPORT Handle(Units_Token) Divide (const Handle(Units_Token)& atoken) const;
134   
135   //! This  virtual  method  is  called by  the  Measurement
136   //! methods,   to   compute   the measurement  during    a
137   //! conversion.
138   Standard_EXPORT Standard_NODISCARD virtual Standard_Real Divided (const Standard_Real avalue) const;
139   
140   //! Returns a token which is <me> to the power  of another
141   //! token <atoken>.  The computation  is possible  only if
142   //! <atoken> is a dimensionless constant.
143   Standard_EXPORT Handle(Units_Token) Power (const Handle(Units_Token)& atoken) const;
144   
145   //! Returns a token which is <me> to the power  of <anexponent>.
146   Standard_EXPORT Handle(Units_Token) Power (const Standard_Real anexponent) const;
147   
148   //! Returns true if  the  field <theword> and  the  string
149   //! <astring> are the same, false otherwise.
150   Standard_EXPORT Standard_Boolean IsEqual (const Standard_CString astring) const;
151   
152   //! Returns true  if the  field  <theword> and  the string
153   //! <theword> contained  in  the  token <atoken>  are  the
154   //! same, false otherwise.
155   Standard_EXPORT Standard_Boolean IsEqual (const Handle(Units_Token)& atoken) const;
156   
157   //! Returns false if  the field <theword>  and the  string
158   //! <astring> are the same, true otherwise.
159     Standard_Boolean IsNotEqual (const Standard_CString astring) const;
160   
161   //! Returns false if  the field <theword>  and the  string
162   //! <theword> contained  in the  token  <atoken>  are  the
163   //! same, true otherwise.
164     Standard_Boolean IsNotEqual (const Handle(Units_Token)& atoken) const;
165   
166   //! Returns   true  if the   field <theword>  is  strictly
167   //! contained at  the beginning  of the string  <astring>,
168   //! false otherwise.
169     Standard_Boolean IsLessOrEqual (const Standard_CString astring) const;
170   
171   //! Returns false  if   the field   <theword> is  strictly
172   //! contained at  the  beginning  of the string <astring>,
173   //! true otherwise.
174     Standard_Boolean IsGreater (const Standard_CString astring) const;
175   
176   //! Returns false  if   the field   <theword> is  strictly
177   //! contained at  the  beginning  of the string <astring>,
178   //! true otherwise.
179     Standard_Boolean IsGreater (const Handle(Units_Token)& atoken) const;
180   
181   //! Returns true  if  the string <astring>   is   strictly
182   //! contained   at the  beginning  of  the field <theword>
183   //! false otherwise.
184     Standard_Boolean IsGreaterOrEqual (const Handle(Units_Token)& atoken) const;
185   
186   //! Useful for debugging
187   Standard_EXPORT virtual void Dump (const Standard_Integer ashift, const Standard_Integer alevel) const;
188
189
190
191   DEFINE_STANDARD_RTTIEXT(Units_Token,Standard_Transient)
192
193 protected:
194
195
196
197
198 private:
199
200
201   TCollection_AsciiString theword;
202   TCollection_AsciiString themean;
203   Standard_Real thevalue;
204   Handle(Units_Dimensions) thedimensions;
205
206
207 };
208
209
210 #include <Units_Token.lxx>
211
212
213
214
215
216 #endif // _Units_Token_HeaderFile