Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ScalarVariant.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ScalarVariant.cc (C) 2000-2022 */
9/* */
10/* Type de base polymorphe pour les scalaires (dimension 0). */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/datatype/ScalarVariant.h"
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19namespace Arcane
20{
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25ScalarVariant::
26ScalarVariant()
27: VariantBase(0, TUnknown)
28, m_real_value(0.)
29, m_int32_value(0)
30, m_int64_value(0)
31, m_bool_value(false)
32{
33}
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38ScalarVariant::
39ScalarVariant(const ScalarVariant& v)
40: VariantBase(0, v.m_type)
41, m_real_value(v.m_real_value)
42, m_real2_value(v.m_real2_value)
43, m_real3_value(v.m_real3_value)
44, m_real2x2_value(v.m_real2x2_value)
45, m_real3x3_value(v.m_real3x3_value)
46, m_int32_value(v.m_int32_value)
47, m_int64_value(v.m_int64_value)
48, m_bool_value(v.m_bool_value)
49, m_string_value(v.m_string_value)
50{
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56ScalarVariant::
57ScalarVariant(Real v)
58: VariantBase(0, TReal)
59, m_real_value(v)
60, m_int32_value(0)
61, m_int64_value(0)
62, m_bool_value(false)
63{
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69ScalarVariant::
70ScalarVariant(Real2 v)
71: VariantBase(0, TReal2)
72, m_real_value(0.)
73, m_real2_value(v)
74, m_int32_value(0)
75, m_int64_value(0)
76, m_bool_value(false)
77{
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83ScalarVariant::
84ScalarVariant(Real3 v)
85: VariantBase(0, TReal3)
86, m_real_value(0.)
87, m_real3_value(v)
88, m_int32_value(0)
89, m_int64_value(0)
90, m_bool_value(false)
91{
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97ScalarVariant::
98ScalarVariant(Real2x2 v)
99: VariantBase(0, TReal2x2)
100, m_real_value(0.)
101, m_real2x2_value(v)
102, m_int32_value(0)
103, m_int64_value(0)
104, m_bool_value(false)
105{
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111ScalarVariant::
112ScalarVariant(Real3x3 v)
113: VariantBase(0, TReal3x3)
114, m_real_value(0.)
115, m_real3x3_value(v)
116, m_int32_value(0)
117, m_int64_value(0)
118, m_bool_value(false)
119{
120}
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125ScalarVariant::
126ScalarVariant(Int32 v)
127: VariantBase(0, TInt32)
128, m_real_value(0.)
129, m_real2_value(Real2::null())
130, m_real3_value(Real3::null())
131, m_int32_value(v)
132, m_int64_value(0)
133, m_bool_value(false)
134{
135}
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140ScalarVariant::
141ScalarVariant(Int64 v)
142: VariantBase(0, TInt64)
143, m_real_value(0.)
144, m_int32_value(0)
145, m_int64_value(v)
146, m_bool_value(false)
147{
148}
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
153ScalarVariant::
154ScalarVariant(bool v)
155: VariantBase(0, TBool)
156, m_real_value(0.)
157, m_int32_value(0)
158, m_int64_value(0)
159, m_bool_value(v)
160{
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166ScalarVariant::
167ScalarVariant(const String& v)
168: VariantBase(0,TString)
169, m_real_value(0.)
170, m_int32_value(0)
171, m_int64_value(0)
172, m_bool_value(false)
173, m_string_value(v)
174{
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180ScalarVariant& ScalarVariant::
181operator= (const ScalarVariant& v)
182{
183 m_dim = 0;
184 m_type = v.m_type;
185 m_real_value = v.m_real_value;
186 m_real2_value = v.m_real2_value;
187 m_real3_value = v.m_real3_value;
188 m_real2x2_value = v.m_real2x2_value;
189 m_real3x3_value = v.m_real3x3_value;
190 m_int64_value = v.m_int64_value;
191 m_int32_value = v.m_int32_value;
192 m_bool_value = v.m_bool_value;
193 m_string_value = v.m_string_value;
194 return (*this);
195}
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
200Integer ScalarVariant::
201asInteger() const
202{
203#ifdef ARCANE_64BIT
204 return asInt64();
205#else
206 return asInt32();
207#endif
208}
209
210/*---------------------------------------------------------------------------*/
211/*---------------------------------------------------------------------------*/
212
213} // End namespace Arcane
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.