Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:14:27

0001 // Created on: 1992-06-22
0002 // Created by: Gilles DEBARBOUILLE
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Units_Token_HeaderFile
0018 #define _Units_Token_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TCollection_AsciiString.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <Standard_Integer.hxx>
0026 class Units_Dimensions;
0027 
0028 //! This class defines an elementary word contained in
0029 //! a Sentence object.
0030 class Units_Token : public Standard_Transient
0031 {
0032 
0033 public:
0034   //! Creates and returns a empty token.
0035   Standard_EXPORT Units_Token();
0036 
0037   //! Creates and returns a token. <aword> is a string
0038   //! containing the available word.
0039   Standard_EXPORT Units_Token(const char* const aword);
0040 
0041   //! Creates and returns a token. <atoken> is copied in
0042   //! the returned token.
0043   Standard_EXPORT Units_Token(const occ::handle<Units_Token>& atoken);
0044 
0045   //! Creates and returns a token. <aword> is a string
0046   //! containing the available word and <amean> gives the
0047   //! signification of the token.
0048   Standard_EXPORT Units_Token(const char* const aword, const char* const amean);
0049 
0050   //! Creates and returns a token. <aword> is a string
0051   //! containing the available word, <amean> gives the
0052   //! signification of the token and <avalue> is the numeric
0053   //! value of the dimension.
0054   Standard_EXPORT Units_Token(const char* const aword,
0055                               const char* const amean,
0056                               const double      avalue);
0057 
0058   //! Creates and returns a token. <aword> is a string
0059   //! containing the available word, <amean> gives the
0060   //! signification of the token, <avalue> is the numeric
0061   //! value of the dimension, and <adimensions> is the
0062   //! dimension of the given word <aword>.
0063   Standard_EXPORT Units_Token(const char* const                    aword,
0064                               const char* const                    amean,
0065                               const double                         avalue,
0066                               const occ::handle<Units_Dimensions>& adimension);
0067 
0068   //! Creates and returns a token, which is a ShiftedToken.
0069   Standard_EXPORT virtual occ::handle<Units_Token> Creates() const;
0070 
0071   //! Returns the length of the word.
0072   Standard_EXPORT int Length() const;
0073 
0074   //! Returns the string <theword>
0075   TCollection_AsciiString Word() const;
0076 
0077   //! Sets the field <theword> to <aword>.
0078   void Word(const char* const aword);
0079 
0080   //! Returns the significance of the word <theword>, which
0081   //! is in the field <themean>.
0082   TCollection_AsciiString Mean() const;
0083 
0084   //! Sets the field <themean> to <amean>.
0085   void Mean(const char* const amean);
0086 
0087   //! Returns the value stored in the field <thevalue>.
0088   double Value() const;
0089 
0090   //! Sets the field <thevalue> to <avalue>.
0091   void Value(const double avalue);
0092 
0093   //! Returns the dimensions of the token <thedimensions>.
0094   occ::handle<Units_Dimensions> Dimensions() const;
0095 
0096   //! Sets the field <thedimensions> to <adimensions>.
0097   Standard_EXPORT void Dimensions(const occ::handle<Units_Dimensions>& adimensions);
0098 
0099   //! Updates the token <me> with the additional
0100   //! signification <amean> by concatenation of the two
0101   //! strings <themean> and <amean>. If the two
0102   //! significations are the same, an information message
0103   //! is written in the output device.
0104   Standard_EXPORT void Update(const char* const amean);
0105 
0106   Standard_EXPORT occ::handle<Units_Token> Add(const int aninteger) const;
0107 
0108   //! Returns a token which is the addition of <me> and
0109   //! another token <atoken>. The addition is possible if
0110   //! and only if the dimensions are the same.
0111   Standard_EXPORT occ::handle<Units_Token> Add(const occ::handle<Units_Token>& atoken) const;
0112 
0113   //! Returns a token which is the subtraction of <me> and
0114   //! another token <atoken>. The subtraction is possible if
0115   //! and only if the dimensions are the same.
0116   Standard_EXPORT occ::handle<Units_Token> Subtract(const occ::handle<Units_Token>& atoken) const;
0117 
0118   //! Returns a token which is the product of <me> and
0119   //! another token <atoken>.
0120   Standard_EXPORT occ::handle<Units_Token> Multiply(const occ::handle<Units_Token>& atoken) const;
0121 
0122   //! This virtual method is called by the Measurement
0123   //! methods, to compute the measurement during a
0124   //! conversion.
0125   [[nodiscard]] Standard_EXPORT virtual double Multiplied(const double avalue) const;
0126 
0127   //! Returns a token which is the division of <me> by another
0128   //! token <atoken>.
0129   Standard_EXPORT occ::handle<Units_Token> Divide(const occ::handle<Units_Token>& atoken) const;
0130 
0131   //! This virtual method is called by the Measurement
0132   //! methods, to compute the measurement during a
0133   //! conversion.
0134   [[nodiscard]] Standard_EXPORT virtual double Divided(const double avalue) const;
0135 
0136   //! Returns a token which is <me> to the power of another
0137   //! token <atoken>. The computation is possible only if
0138   //! <atoken> is a dimensionless constant.
0139   Standard_EXPORT occ::handle<Units_Token> Power(const occ::handle<Units_Token>& atoken) const;
0140 
0141   //! Returns a token which is <me> to the power of <anexponent>.
0142   Standard_EXPORT occ::handle<Units_Token> Power(const double anexponent) const;
0143 
0144   //! Returns true if the field <theword> and the string
0145   //! <astring> are the same, false otherwise.
0146   Standard_EXPORT bool IsEqual(const char* const astring) const;
0147 
0148   //! Returns true if the field <theword> and the string
0149   //! <theword> contained in the token <atoken> are the
0150   //! same, false otherwise.
0151   Standard_EXPORT bool IsEqual(const occ::handle<Units_Token>& atoken) const;
0152 
0153   //! Returns false if the field <theword> and the string
0154   //! <astring> are the same, true otherwise.
0155   bool IsNotEqual(const char* const astring) const;
0156 
0157   //! Returns false if the field <theword> and the string
0158   //! <theword> contained in the token <atoken> are the
0159   //! same, true otherwise.
0160   bool IsNotEqual(const occ::handle<Units_Token>& atoken) const;
0161 
0162   //! Returns true if the field <theword> is strictly
0163   //! contained at the beginning of the string <astring>,
0164   //! false otherwise.
0165   bool IsLessOrEqual(const char* const astring) const;
0166 
0167   //! Returns false if the field <theword> is strictly
0168   //! contained at the beginning of the string <astring>,
0169   //! true otherwise.
0170   bool IsGreater(const char* const astring) const;
0171 
0172   //! Returns false if the field <theword> is strictly
0173   //! contained at the beginning of the string <astring>,
0174   //! true otherwise.
0175   bool IsGreater(const occ::handle<Units_Token>& atoken) const;
0176 
0177   //! Returns true if the string <astring> is strictly
0178   //! contained at the beginning of the field <theword>
0179   //! false otherwise.
0180   bool IsGreaterOrEqual(const occ::handle<Units_Token>& atoken) const;
0181 
0182   //! Useful for debugging
0183   Standard_EXPORT virtual void Dump(const int ashift, const int alevel) const;
0184 
0185   DEFINE_STANDARD_RTTIEXT(Units_Token, Standard_Transient)
0186 
0187 private:
0188   TCollection_AsciiString       theword;
0189   TCollection_AsciiString       themean;
0190   double                        thevalue;
0191   occ::handle<Units_Dimensions> thedimensions;
0192 };
0193 
0194 #include <Units_Token.lxx>
0195 
0196 #endif // _Units_Token_HeaderFile