973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | #include <StepData_SelectMember.ixx> |
15 | |
16 | // Definitions reprises de Field : |
17 | #define KindInteger 1 |
18 | #define KindBoolean 2 |
19 | #define KindLogical 3 |
20 | #define KindEnum 4 |
21 | #define KindReal 5 |
22 | #define KindString 6 |
23 | |
24 | |
25 | |
b311480e |
26 | StepData_SelectMember::StepData_SelectMember () { } |
7fd59977 |
27 | |
28 | Standard_Boolean StepData_SelectMember::HasName () const { return Standard_False; } |
29 | Standard_CString StepData_SelectMember::Name () const { return ""; } |
30 | |
35e08fe8 |
31 | Standard_Boolean StepData_SelectMember::SetName (const Standard_CString /*bid*/) |
7fd59977 |
32 | { return Standard_False; } |
33 | |
34 | Standard_Boolean StepData_SelectMember::Matches (const Standard_CString name) const |
35 | { return !strcmp (name,Name()); } |
36 | |
37 | Standard_Integer StepData_SelectMember::Kind () const { return 0; } |
38 | void StepData_SelectMember::SetKind (const Standard_Integer ) { } |
39 | |
40 | Interface_ParamType StepData_SelectMember::ParamType () const |
41 | { |
42 | Standard_Integer kind = Kind(); |
43 | if (kind == 0) return Interface_ParamVoid; |
44 | if (kind == 1) return Interface_ParamInteger; |
45 | if (kind == 2 || kind == 3) return Interface_ParamLogical; |
46 | if (kind == 4) return Interface_ParamEnum; |
47 | if (kind == 5) return Interface_ParamReal; |
48 | if (kind == 6) return Interface_ParamText; |
49 | return Interface_ParamMisc; |
50 | } |
51 | |
52 | Standard_Integer StepData_SelectMember::Int () const { return 0; } |
53 | void StepData_SelectMember::SetInt (const Standard_Integer ) { } |
54 | |
55 | Standard_Integer StepData_SelectMember::Integer () const { return Int(); } |
56 | void StepData_SelectMember::SetInteger (const Standard_Integer val) |
57 | { SetKind(KindInteger); SetInt(val); } |
58 | Standard_Boolean StepData_SelectMember::Boolean () const { return (Int() > 0); } |
59 | void StepData_SelectMember::SetBoolean (const Standard_Boolean val) |
60 | { SetKind(KindBoolean); SetInt((val ? 1 : 0)); } |
61 | |
62 | StepData_Logical StepData_SelectMember::Logical () const |
63 | { |
64 | Standard_Integer ival = Int(); |
65 | if (ival == 0) return StepData_LFalse; |
66 | if (ival == 1) return StepData_LTrue; |
67 | return StepData_LUnknown; |
68 | } |
69 | |
70 | void StepData_SelectMember::SetLogical (const StepData_Logical val) |
71 | { |
72 | SetKind(KindLogical); |
73 | if (val == StepData_LFalse) SetInt(0); |
74 | if (val == StepData_LTrue) SetInt(0); |
75 | if (val == StepData_LUnknown) SetInt(0); |
76 | } |
77 | |
78 | Standard_Real StepData_SelectMember::Real () const { return 0.0; } |
79 | void StepData_SelectMember::SetReal (const Standard_Real ) { } |
80 | |
81 | Standard_CString StepData_SelectMember::String () const { return ""; } |
82 | void StepData_SelectMember::SetString (const Standard_CString ) { } |
83 | |
84 | Standard_Integer StepData_SelectMember::Enum () const { return Int(); } |
85 | Standard_CString StepData_SelectMember::EnumText () const { return String(); } |
86 | |
35e08fe8 |
87 | void StepData_SelectMember::SetEnum (const Standard_Integer val, |
88 | const Standard_CString text) |
7fd59977 |
89 | { |
90 | SetKind(KindEnum); |
91 | SetInt(val); |
92 | if (text && text[0] != '\0') SetEnumText(val,text); |
93 | } |
94 | |
35e08fe8 |
95 | void StepData_SelectMember::SetEnumText (const Standard_Integer /*val*/, |
96 | const Standard_CString text) |
97 | { |
98 | SetString(text); |
99 | } |