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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Units_Token_HeaderFile
18 #define _Units_Token_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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;
33 DEFINE_STANDARD_HANDLE(Units_Token, Standard_Transient)
35 //! This class defines an elementary word contained in
36 //! a Sentence object.
37 class Units_Token : public Standard_Transient
43 //! Creates and returns a empty token.
44 Standard_EXPORT Units_Token();
46 //! Creates and returns a token. <aword> is a string
47 //! containing the available word.
48 Standard_EXPORT Units_Token(const Standard_CString aword);
50 //! Creates and returns a token. <atoken> is copied in
51 //! the returned token.
52 Standard_EXPORT Units_Token(const Handle(Units_Token)& atoken);
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);
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);
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);
72 //! Creates and returns a token, which is a ShiftedToken.
73 Standard_EXPORT virtual Handle(Units_Token) Creates() const;
75 //! Returns the length of the word.
76 Standard_EXPORT Standard_Integer Length() const;
78 //! Returns the string <theword>
79 TCollection_AsciiString Word() const;
81 //! Sets the field <theword> to <aword>.
82 void Word (const Standard_CString aword);
84 //! Returns the significance of the word <theword>, which
85 //! is in the field <themean>.
86 TCollection_AsciiString Mean() const;
88 //! Sets the field <themean> to <amean>.
89 void Mean (const Standard_CString amean);
91 //! Returns the value stored in the field <thevalue>.
92 Standard_Real Value() const;
94 //! Sets the field <thevalue> to <avalue>.
95 void Value (const Standard_Real avalue);
97 //! Returns the dimensions of the token <thedimensions>.
98 Handle(Units_Dimensions) Dimensions() const;
100 //! Sets the field <thedimensions> to <adimensions>.
101 Standard_EXPORT void Dimensions (const Handle(Units_Dimensions)& adimensions);
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);
110 Standard_EXPORT Handle(Units_Token) Add (const Standard_Integer aninteger) const;
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;
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;
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;
126 //! This virtual method is called by the Measurement
127 //! methods, to compute the measurement during a
129 Standard_EXPORT Standard_NODISCARD virtual Standard_Real Multiplied (const Standard_Real avalue) const;
131 //! Returns a token which is the division of <me> by another
133 Standard_EXPORT Handle(Units_Token) Divide (const Handle(Units_Token)& atoken) const;
135 //! This virtual method is called by the Measurement
136 //! methods, to compute the measurement during a
138 Standard_EXPORT Standard_NODISCARD virtual Standard_Real Divided (const Standard_Real avalue) const;
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;
145 //! Returns a token which is <me> to the power of <anexponent>.
146 Standard_EXPORT Handle(Units_Token) Power (const Standard_Real anexponent) const;
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;
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;
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;
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;
166 //! Returns true if the field <theword> is strictly
167 //! contained at the beginning of the string <astring>,
169 Standard_Boolean IsLessOrEqual (const Standard_CString astring) const;
171 //! Returns false if the field <theword> is strictly
172 //! contained at the beginning of the string <astring>,
174 Standard_Boolean IsGreater (const Standard_CString astring) const;
176 //! Returns false if the field <theword> is strictly
177 //! contained at the beginning of the string <astring>,
179 Standard_Boolean IsGreater (const Handle(Units_Token)& atoken) const;
181 //! Returns true if the string <astring> is strictly
182 //! contained at the beginning of the field <theword>
184 Standard_Boolean IsGreaterOrEqual (const Handle(Units_Token)& atoken) const;
186 //! Useful for debugging
187 Standard_EXPORT virtual void Dump (const Standard_Integer ashift, const Standard_Integer alevel) const;
191 DEFINE_STANDARD_RTTIEXT(Units_Token,Standard_Transient)
201 TCollection_AsciiString theword;
202 TCollection_AsciiString themean;
203 Standard_Real thevalue;
204 Handle(Units_Dimensions) thedimensions;
210 #include <Units_Token.lxx>
216 #endif // _Units_Token_HeaderFile