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 | |
42cf5bc1 |
14 | |
15 | #include <Standard_Type.hxx> |
16 | #include <StepData_SelectMember.hxx> |
7fd59977 |
17 | |
18 | // Definitions reprises de Field : |
19 | #define KindInteger 1 |
20 | #define KindBoolean 2 |
21 | #define KindLogical 3 |
22 | #define KindEnum 4 |
23 | #define KindReal 5 |
24 | #define KindString 6 |
25 | |
26 | |
27 | |
b311480e |
28 | StepData_SelectMember::StepData_SelectMember () { } |
7fd59977 |
29 | |
30 | Standard_Boolean StepData_SelectMember::HasName () const { return Standard_False; } |
31 | Standard_CString StepData_SelectMember::Name () const { return ""; } |
32 | |
35e08fe8 |
33 | Standard_Boolean StepData_SelectMember::SetName (const Standard_CString /*bid*/) |
7fd59977 |
34 | { return Standard_False; } |
35 | |
36 | Standard_Boolean StepData_SelectMember::Matches (const Standard_CString name) const |
37 | { return !strcmp (name,Name()); } |
38 | |
39 | Standard_Integer StepData_SelectMember::Kind () const { return 0; } |
40 | void StepData_SelectMember::SetKind (const Standard_Integer ) { } |
41 | |
42 | Interface_ParamType StepData_SelectMember::ParamType () const |
43 | { |
44 | Standard_Integer kind = Kind(); |
45 | if (kind == 0) return Interface_ParamVoid; |
46 | if (kind == 1) return Interface_ParamInteger; |
47 | if (kind == 2 || kind == 3) return Interface_ParamLogical; |
48 | if (kind == 4) return Interface_ParamEnum; |
49 | if (kind == 5) return Interface_ParamReal; |
50 | if (kind == 6) return Interface_ParamText; |
51 | return Interface_ParamMisc; |
52 | } |
53 | |
54 | Standard_Integer StepData_SelectMember::Int () const { return 0; } |
55 | void StepData_SelectMember::SetInt (const Standard_Integer ) { } |
56 | |
57 | Standard_Integer StepData_SelectMember::Integer () const { return Int(); } |
58 | void StepData_SelectMember::SetInteger (const Standard_Integer val) |
59 | { SetKind(KindInteger); SetInt(val); } |
60 | Standard_Boolean StepData_SelectMember::Boolean () const { return (Int() > 0); } |
61 | void StepData_SelectMember::SetBoolean (const Standard_Boolean val) |
62 | { SetKind(KindBoolean); SetInt((val ? 1 : 0)); } |
63 | |
64 | StepData_Logical StepData_SelectMember::Logical () const |
65 | { |
66 | Standard_Integer ival = Int(); |
67 | if (ival == 0) return StepData_LFalse; |
68 | if (ival == 1) return StepData_LTrue; |
69 | return StepData_LUnknown; |
70 | } |
71 | |
72 | void StepData_SelectMember::SetLogical (const StepData_Logical val) |
73 | { |
74 | SetKind(KindLogical); |
75 | if (val == StepData_LFalse) SetInt(0); |
76 | if (val == StepData_LTrue) SetInt(0); |
77 | if (val == StepData_LUnknown) SetInt(0); |
78 | } |
79 | |
80 | Standard_Real StepData_SelectMember::Real () const { return 0.0; } |
81 | void StepData_SelectMember::SetReal (const Standard_Real ) { } |
82 | |
83 | Standard_CString StepData_SelectMember::String () const { return ""; } |
84 | void StepData_SelectMember::SetString (const Standard_CString ) { } |
85 | |
86 | Standard_Integer StepData_SelectMember::Enum () const { return Int(); } |
87 | Standard_CString StepData_SelectMember::EnumText () const { return String(); } |
88 | |
35e08fe8 |
89 | void StepData_SelectMember::SetEnum (const Standard_Integer val, |
90 | const Standard_CString text) |
7fd59977 |
91 | { |
92 | SetKind(KindEnum); |
93 | SetInt(val); |
94 | if (text && text[0] != '\0') SetEnumText(val,text); |
95 | } |
96 | |
35e08fe8 |
97 | void StepData_SelectMember::SetEnumText (const Standard_Integer /*val*/, |
98 | const Standard_CString text) |
99 | { |
100 | SetString(text); |
101 | } |