Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Convert.h
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/* Convert.h (C) 2000-2022 */
9/* */
10/* Fonctions pour convertir un type en un autre. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_CONVERT_H
13#define ARCANE_UTILS_CONVERT_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include <optional>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
33namespace Convert
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
39inline double
41{
42#ifdef ARCANE_REAL_USE_APFLOAT
43 return ap2double(r.ap);
44#else
45 return (double)r;
46#endif
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
52inline Integer
54{
55 return (Integer)toDouble(r);
56}
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
61inline Int64
63{
64 return (Int64)toDouble(r);
65}
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
70inline Int32
72{
73 return (Int32)toDouble(r);
74}
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
79inline bool
80toBool(Real r)
81{
82 return (bool)toDouble(r);
83}
84
86inline Real
87toReal(Real r)
88{
89 return r;
90}
92inline Real
94{
95 return (Real)r;
96}
98inline Real
99toReal(unsigned int r)
100{
101 return (Real)r;
102}
104inline Real
106{
107 return (Real)r;
108}
110inline Real
111toReal(unsigned long r)
112{
113 return (Real)r;
114}
115
117inline Real
118toReal(long long r)
119{
120#ifdef ARCANE_REAL_USE_APFLOAT
121 return (Real)((long)r);
122#else
123 return (Real)r;
124#endif
125}
127inline Real
128toReal(unsigned long long r)
129{
130#ifdef ARCANE_REAL_USE_APFLOAT
131 return (Real)((unsigned long)r);
132#else
133 return (Real)r;
134#endif
135}
136
143extern ARCANE_UTILS_EXPORT String
145
152extern ARCANE_UTILS_EXPORT String
154
161extern ARCANE_UTILS_EXPORT String
162toHexaString(Real input);
163
171extern ARCANE_UTILS_EXPORT void
172toHexaString(Int64 input,Span<Byte> output);
173
174/*---------------------------------------------------------------------------*/
175/*---------------------------------------------------------------------------*/
176
177} // End namespace Convert
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182} // End namespace Arcane
183
184/*---------------------------------------------------------------------------*/
185/*---------------------------------------------------------------------------*/
186
187#endif
188
Déclarations des types utilisés dans Arcane.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Vue constante d'un tableau de type T.
Chaîne de caractères unicode.
Int64 toInt64(Real r)
Converti un Real en Int64.
Definition Convert.h:62
Integer toInteger(Real r)
Converti un Real en Integer.
Definition Convert.h:53
bool toBool(Real r)
Converti un Real en Integer.
Definition Convert.h:80
Real toReal(Real r)
Converti r en un Real.
Definition Convert.h:87
String toHexaString(ByteConstArrayView input)
Converti un tableau d'octet en sa représentation hexadécimale.
Definition Convert.cc:388
double toDouble(Real r)
Converti un Real en double.
Definition Convert.h:40
Int32 toInt32(Real r)
Converti un Real en Int32.
Definition Convert.h:71
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-