|
||||
File indexing completed on 2025-01-18 10:05:06
0001 // Created on: 1995-10-25 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1995-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 _StepData_EnumTool_HeaderFile 0018 #define _StepData_EnumTool_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <TColStd_SequenceOfAsciiString.hxx> 0025 #include <Standard_CString.hxx> 0026 class TCollection_AsciiString; 0027 0028 0029 //! This class gives a way of conversion between the value of an 0030 //! enumeration and its representation in STEP 0031 //! An enumeration corresponds to an integer with reserved values, 0032 //! which begin to 0 0033 //! In STEP, it is represented by a name in capital letter and 0034 //! limited by two dots, e.g. .UNKNOWN. 0035 //! 0036 //! EnumTool works with integers, it is just required to cast 0037 //! between an integer and an enumeration of required type. 0038 //! 0039 //! Its definition is intended to allow static creation in once, 0040 //! without having to recreate once for each use. 0041 //! 0042 //! It is possible to define subclasses on it, which directly give 0043 //! the good list of definition texts, and accepts a enumeration 0044 //! of the good type instead of an integer 0045 class StepData_EnumTool 0046 { 0047 public: 0048 0049 DEFINE_STANDARD_ALLOC 0050 0051 0052 //! Creates an EnumTool with definitions given by e0 .. e<max> 0053 //! Each definition string can bring one term, or several 0054 //! separated by blanks. Each term corresponds to one value of the 0055 //! enumeration, if dots are not presents they are added 0056 //! 0057 //! Such a static constructor allows to build a static description 0058 //! as : static StepData_EnumTool myenumtool("e0","e1"...); 0059 //! then use it without having to initialise it 0060 //! 0061 //! A null definition can be input by given "$" :the corresponding 0062 //! position is attached to "null/undefined" value (as one 0063 //! particular item of the enumeration list) 0064 Standard_EXPORT StepData_EnumTool(const Standard_CString e0 = "", const Standard_CString e1 = "", const Standard_CString e2 = "", const Standard_CString e3 = "", const Standard_CString e4 = "", const Standard_CString e5 = "", const Standard_CString e6 = "", const Standard_CString e7 = "", const Standard_CString e8 = "", const Standard_CString e9 = "", const Standard_CString e10 = "", const Standard_CString e11 = "", const Standard_CString e12 = "", const Standard_CString e13 = "", const Standard_CString e14 = "", const Standard_CString e15 = "", const Standard_CString e16 = "", const Standard_CString e17 = "", const Standard_CString e18 = "", const Standard_CString e19 = "", const Standard_CString e20 = "", const Standard_CString e21 = "", const Standard_CString e22 = "", const Standard_CString e23 = "", const Standard_CString e24 = "", const Standard_CString e25 = "", const Standard_CString e26 = "", const Standard_CString e27 = "", const Standard_CString e28 = "", const Standard_CString e29 = "", const Standard_CString e30 = "", const Standard_CString e31 = "", const Standard_CString e32 = "", const Standard_CString e33 = "", const Standard_CString e34 = "", const Standard_CString e35 = "", const Standard_CString e36 = "", const Standard_CString e37 = "", const Standard_CString e38 = "", const Standard_CString e39 = ""); 0065 0066 //! Processes a definition, splits it according blanks if any 0067 //! empty definitions are ignored 0068 //! A null definition can be input by given "$" :the corresponding 0069 //! position is attached to "null/undefined" value (as one 0070 //! particular item of the enumeration list) 0071 //! See also IsSet 0072 Standard_EXPORT void AddDefinition (const Standard_CString term); 0073 0074 //! Returns True if at least one definition has been entered after 0075 //! creation time (i.e. by AddDefinition only) 0076 //! 0077 //! This allows to build a static description by a first pass : 0078 //! static StepData_EnumTool myenumtool("e0" ...); 0079 //! ... 0080 //! if (!myenumtool.IsSet()) { for further inits 0081 //! myenumtool.AddDefinition("e21"); 0082 //! ... 0083 //! } 0084 Standard_EXPORT Standard_Boolean IsSet() const; 0085 0086 //! Returns the maximum integer for a suitable value 0087 //! Remark : while values begin at zero, MaxValue is the count of 0088 //! recorded values minus one 0089 Standard_EXPORT Standard_Integer MaxValue() const; 0090 0091 //! Sets or Unsets the EnumTool to accept undefined value (for 0092 //! optional field). Ignored if no null value is defined (by "$") 0093 //! Can be changed during execution (to read each field), 0094 //! Default is True (if a null value is defined) 0095 Standard_EXPORT void Optional (const Standard_Boolean mode); 0096 0097 //! Returns the value attached to "null/undefined value" 0098 //! If none is specified or if Optional has been set to False, 0099 //! returns -1 0100 //! Null Value has been specified by definition "$" 0101 Standard_EXPORT Standard_Integer NullValue() const; 0102 0103 //! Returns the text which corresponds to a given numeric value 0104 //! It is limited by dots 0105 //! If num is out of range, returns an empty string 0106 Standard_EXPORT const TCollection_AsciiString& Text (const Standard_Integer num) const; 0107 0108 //! Returns the numeric value found for a text 0109 //! The text must be in capitals and limited by dots 0110 //! A non-suitable text gives a negative value to be returned 0111 Standard_EXPORT Standard_Integer Value (const Standard_CString txt) const; 0112 0113 //! Same as above but works on an AsciiString 0114 Standard_EXPORT Standard_Integer Value (const TCollection_AsciiString& txt) const; 0115 0116 0117 0118 0119 protected: 0120 0121 0122 0123 0124 0125 private: 0126 0127 0128 0129 TColStd_SequenceOfAsciiString thetexts; 0130 Standard_Integer theinit; 0131 Standard_Boolean theopt; 0132 0133 0134 }; 0135 0136 0137 0138 0139 0140 0141 0142 #endif // _StepData_EnumTool_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |