42cf5bc1 |
1 | // Created on: 1992-10-26 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _IGESData_ParamCursor_HeaderFile |
18 | #define _IGESData_ParamCursor_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Integer.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | class Interface_InterfaceError; |
27 | |
28 | |
29 | //! Auxiliary class for ParamReader. |
30 | //! It stores commands for a ParamReader to manage the current |
31 | //! parameter number. Used by methods Read... from ParamReader. |
32 | //! It allows to define the following commands : |
33 | //! - read a parameter specified by a precise Number (basic case) |
34 | //! - read a parameter then set Current Number to follow its number |
35 | //! - read the current parameter (with Current Number) then |
36 | //! advance Current Number by one |
37 | //! - idem with several : read "nb" parameters from one specified, |
38 | //! included, with or without setting Current Number to follow |
39 | //! last parameter read |
40 | //! - read several parameter from the current one, then advance |
41 | //! Current Number to follow the last one read |
42 | //! - Read several parameters (as above) but in interlaced lists, |
43 | //! i.e. from complex items (each one including successively for |
44 | //! instance, an Integer, a Real, an Entity ...) |
45 | //! |
46 | //! If commands to advance Current Number are not set, it must be |
47 | //! set by the user (with method SetCurrent from ParamReader) |
48 | //! ParamReader offers methods which create most useful cases |
49 | class IGESData_ParamCursor |
50 | { |
51 | public: |
52 | |
53 | DEFINE_STANDARD_ALLOC |
54 | |
55 | |
56 | //! Creates a Cursor to read a precise parameter of ParamReader, |
57 | //! identified by its number, then set Current Number to "num + 1" |
58 | //! (this constructor allows to simply give a Number to a method |
59 | //! Read... from ParamReader, which will be translated into a |
60 | //! ParamCursor by compiler) |
61 | Standard_EXPORT IGESData_ParamCursor(const Standard_Integer num); |
62 | |
63 | //! Creates a Cursor to read a list of parameters (count "nb") |
64 | //! starting from a precise one (number "num") included, then |
65 | //! set Current Number of ParamNumber to the first following one |
66 | //! ("num + nb") |
67 | //! If size is given, it means that each parameter is made of more |
68 | //! than one term. One term is the normal (default) case : for |
69 | //! instance, a Parameter comprises one Integer, or one Entity ... |
70 | //! Size gives the complete size of each Item if it is complex. |
71 | //! To be used ONLY IF it is constant |
72 | Standard_EXPORT IGESData_ParamCursor(const Standard_Integer num, const Standard_Integer nb, const Standard_Integer size = 1); |
73 | |
74 | //! Defines the size of a term to read in the item : this commands |
75 | //! ParamReader to read "size" parameters for each item, then |
76 | //! skip the remainder of the item to the same term of next Item |
77 | //! (that is, skip "item size" - "term size") |
78 | //! |
79 | //! In addition, Offset from beginning of Item is managed : |
0177fe26 |
80 | //! After being created, and for the first call to SetTerm, the |
42cf5bc1 |
81 | //! part of Item to be read begins exactly as the Item begins |
82 | //! But after a SetTerm, the next read will add an offset which is |
83 | //! the size of former term. |
84 | //! |
85 | //! autoadv commands Advance management. If it is True (default), |
86 | //! the last SetTerm (Item size has been covered) calls SetAdvance |
87 | //! If it is False, SetAdvance must be called directly if necessary |
88 | //! |
89 | //! Error if a SetTerm overpasses the size of the Item |
90 | Standard_EXPORT void SetTerm (const Standard_Integer size, const Standard_Boolean autoadv = Standard_True); |
91 | |
92 | //! Defines a term of one Parameter (very current case) |
93 | Standard_EXPORT void SetOne (const Standard_Boolean autoadv = Standard_True); |
94 | |
95 | //! Defines a term of two Parameters for a XY (current case) |
96 | Standard_EXPORT void SetXY (const Standard_Boolean autoadv = Standard_True); |
97 | |
98 | //! Defines a term of three Parameters for XYZ (current case) |
99 | Standard_EXPORT void SetXYZ (const Standard_Boolean autoadv = Standard_True); |
100 | |
101 | //! Changes command to advance current cursor after reading |
102 | //! parameters. If "advance" True, sets advance, if "False", |
103 | //! resets it. ParamCursor is created by default with True. |
104 | Standard_EXPORT void SetAdvance (const Standard_Boolean advance); |
105 | |
106 | //! Returns (included) starting number for reading parameters |
107 | Standard_Integer Start() const; |
108 | |
109 | //! Returns (excluded) upper limit number for reading parameters |
110 | Standard_Integer Limit() const; |
111 | |
112 | //! Returns required count of items to be read |
113 | Standard_Integer Count() const; |
114 | |
115 | //! Returns length of item (count of parameters per item) |
116 | Standard_Integer ItemSize() const; |
117 | |
118 | //! Returns length of current term (count of parameters) in item |
119 | Standard_Integer TermSize() const; |
120 | |
121 | //! Returns offset from which current term must be read in item |
122 | Standard_Integer Offset() const; |
123 | |
124 | //! Returns True if Advance command has been set |
125 | Standard_Boolean Advance() const; |
126 | |
127 | |
128 | |
129 | |
130 | protected: |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | private: |
137 | |
138 | |
139 | |
140 | Standard_Integer thestart; |
141 | Standard_Integer thelimit; |
142 | Standard_Integer thecount; |
143 | Standard_Integer theisize; |
144 | Standard_Integer theoffst; |
145 | Standard_Integer thetsize; |
146 | Standard_Boolean theadv; |
147 | |
148 | |
149 | }; |
150 | |
151 | |
152 | #include <IGESData_ParamCursor.lxx> |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | #endif // _IGESData_ParamCursor_HeaderFile |