1 -- Created on: 1995-10-25
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1995-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 class EnumTool from StepData
19 ---Purpose : This class gives a way of conversion between the value of an
20 -- enumeration and its representation in STEP
21 -- An enumeration corresponds to an integer with reserved values,
23 -- In STEP, it is represented by a name in capital letter and
24 -- limited by two dots, e.g. .UNKNOWN.
26 -- EnumTool works with integers, it is just required to cast
27 -- between an integer and an enumeration of required type.
29 -- Its definition is intended to allow static creation in once,
30 -- without having to recreate once for each use.
32 -- It is possible to define subclasses on it, which directly give
33 -- the good list of definition texts, and accepts a enumeration
34 -- of the good type instead of an integer
36 uses CString, AsciiString, SequenceOfAsciiString
40 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 = "")
42 ---Purpose : Creates an EnumTool with definitions given by e0 .. e<max>
43 -- Each definition string can bring one term, or several
44 -- separated by blanks. Each term corresponds to one value of the
45 -- enumeration, if dots are not presents they are added
47 -- Such a static constructor allows to build a static description
48 -- as : static StepData_EnumTool myenumtool("e0","e1"...);
49 -- then use it without having to initialise it
51 -- A null definition can be input by given "$" :the corresponding
52 -- position is attached to "null/undefined" value (as one
53 -- particular item of the enumeration list)
55 AddDefinition (me : in out; term : CString);
56 ---Purpose : Processes a definition, splits it according blanks if any
57 -- empty definitions are ignored
58 -- A null definition can be input by given "$" :the corresponding
59 -- position is attached to "null/undefined" value (as one
60 -- particular item of the enumeration list)
63 IsSet (me) returns Boolean;
64 ---Purpose : Returns True if at least one definition has been entered after
65 -- creation time (i.e. by AddDefinition only)
67 -- This allows to build a static description by a first pass :
68 -- static StepData_EnumTool myenumtool("e0" ...);
70 -- if (!myenumtool.IsSet()) { for further inits
71 -- myenumtool.AddDefinition("e21");
75 MaxValue (me) returns Integer;
76 ---Purpose : Returns the maximum integer for a suitable value
77 -- Remark : while values begin at zero, MaxValue is the count of
78 -- recorded values minus one
80 Optional (me : in out; mode : Boolean);
81 ---Purpose : Sets or Unsets the EnumTool to accept undefined value (for
82 -- optional field). Ignored if no null value is defined (by "$")
83 -- Can be changed during execution (to read each field),
84 -- Default is True (if a null value is defined)
86 NullValue (me) returns Integer;
87 ---Purpose : Returns the value attached to "null/undefined value"
88 -- If none is specified or if Optional has been set to False,
90 -- Null Value has been specified by definition "$"
92 Text (me; num : Integer) returns AsciiString;
93 ---Purpose : Returns the text which corresponds to a given numeric value
94 -- It is limited by dots
95 -- If num is out of range, returns an empty string
96 ---C++ : return const &
98 Value (me; txt : CString) returns Integer;
99 ---Purpose : Returns the numeric value found for a text
100 -- The text must be in capitals and limited by dots
101 -- A non-suitable text gives a negative value to be returned
103 Value (me; txt : AsciiString) returns Integer;
104 ---Purpose : Same as above but works on an AsciiString
108 thetexts : SequenceOfAsciiString;