1 -- Created on: 1995-10-25
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1995-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
23 class EnumTool from StepData
25 ---Purpose : This class gives a way of conversion between the value of an
26 -- enumeration and its representation in STEP
27 -- An enumeration corresponds to an integer with reserved values,
29 -- In STEP, it is represented by a name in capital letter and
30 -- limited by two dots, e.g. .UNKNOWN.
32 -- EnumTool works with integers, it is just required to cast
33 -- between an integer and an enumeration of required type.
35 -- Its definition is intended to allow static creation in once,
36 -- without having to recreate once for each use.
38 -- It is possible to define subclasses on it, which directly give
39 -- the good list of definition texts, and accepts a enumeration
40 -- of the good type instead of an integer
42 uses CString, AsciiString, SequenceOfAsciiString
46 Create (e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,e31,e32,e33,e34,e35,e36,e37,e38,e39 : CString = "")
48 ---Purpose : Creates an EnumTool with definitions given by e0 .. e<max>
49 -- Each definition string can bring one term, or several
50 -- separated by blanks. Each term corresponds to one value of the
51 -- enumeration, if dots are not presents they are added
53 -- Such a static constructor allows to build a static description
54 -- as : static StepData_EnumTool myenumtool("e0","e1"...);
55 -- then use it without having to initialise it
57 -- A null definition can be input by given "$" :the corresponding
58 -- position is attached to "null/undefined" value (as one
59 -- particular item of the enumeration list)
61 AddDefinition (me : in out; term : CString);
62 ---Purpose : Processes a definition, splits it according blanks if any
63 -- empty definitions are ignored
64 -- A null definition can be input by given "$" :the corresponding
65 -- position is attached to "null/undefined" value (as one
66 -- particular item of the enumeration list)
69 IsSet (me) returns Boolean;
70 ---Purpose : Returns True if at least one definition has been entered after
71 -- creation time (i.e. by AddDefinition only)
73 -- This allows to build a static description by a first pass :
74 -- static StepData_EnumTool myenumtool("e0" ...);
76 -- if (!myenumtool.IsSet()) { for further inits
77 -- myenumtool.AddDefinition("e21");
81 MaxValue (me) returns Integer;
82 ---Purpose : Returns the maximum integer for a suitable value
83 -- Remark : while values begin at zero, MaxValue is the count of
84 -- recorded values minus one
86 Optional (me : in out; mode : Boolean);
87 ---Purpose : Sets or Unsets the EnumTool to accept undefined value (for
88 -- optional field). Ignored if no null value is defined (by "$")
89 -- Can be changed during execution (to read each field),
90 -- Default is True (if a null value is defined)
92 NullValue (me) returns Integer;
93 ---Purpose : Returns the value attached to "null/undefined value"
94 -- If none is specified or if Optional has been set to False,
96 -- Null Value has been specified by definition "$"
98 Text (me; num : Integer) returns AsciiString;
99 ---Purpose : Returns the text which corresponds to a given numeric value
100 -- It is limited by dots
101 -- If num is out of range, returns an empty string
102 ---C++ : return const &
104 Value (me; txt : CString) returns Integer;
105 ---Purpose : Returns the numeric value found for a text
106 -- The text must be in capitals and limited by dots
107 -- A non-suitable text gives a negative value to be returned
109 Value (me; txt : AsciiString) returns Integer;
110 ---Purpose : Same as above but works on an AsciiString
114 thetexts : SequenceOfAsciiString;