Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ConvertInternal.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* ConvertInternal.h (C) 2000-2026 */
9/* */
10/* Functions to convert a character string into a given type. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_BASE_INTERNAL_CONVERTINTERNAL_H
13#define ARCCORE_BASE_INTERNAL_CONVERTINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane::Convert::Impl
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
29class ARCCORE_BASE_EXPORT ConvertPolicy
30{
31 public:
32
42 static void setUseFromChars(bool v) { m_use_from_chars = v; }
43 static bool isUseFromChars() { return m_use_from_chars; }
44
46 static void setVerbosity(Int32 v) { m_verbosity = v; }
47 static bool verbosity() { return m_verbosity; }
48
56 static void setUseSameConvertForAllReal(bool v)
57 {
58 m_use_same_convert_for_all_real = v;
59 }
60 static bool isUseSameConvertForAllReal()
61 {
62 return m_use_same_convert_for_all_real;
63 }
64
65 private:
66
67 static Int32 m_verbosity;
68 static bool m_use_from_chars;
69 static bool m_use_same_convert_for_all_real;
70};
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
78class ARCCORE_BASE_EXPORT StringViewToDoubleConverter
79{
80 public:
81
83 static Int64 _getDoubleValue(double& v, StringView s);
84};
85
86/*---------------------------------------------------------------------------*/
87/*---------------------------------------------------------------------------*/
88
96class ARCCORE_BASE_EXPORT StringViewToIntegral
97{
98 public:
99
100 static bool getValue(double& v, StringView s);
101 static bool getValue(int& v, StringView s);
102 static bool getValue(long& v, StringView s);
103 static bool getValue(long long& v, StringView s);
104 static bool getValue(bool& v, StringView s);
105};
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110extern "C++" ARCCORE_BASE_EXPORT StringView
111_removeLeadingSpaces(StringView s, Int64 pos = 0);
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116} // namespace Arcane::Convert::Impl
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121#endif
Declarations of types for the 'base' component of Arccore.
Information on the behavior of conversion methods.
static void setUseFromChars(bool v)
Indicates whether 'std::from_chars' is used to convert character strings into a numeric type.
static void setUseSameConvertForAllReal(bool v)
static void setVerbosity(Int32 v)
Sets the verbosity level for conversion functions.
Class for converting a 'StringView' to 'double'.
static Int64 _getDoubleValueWithFromChars(double &v, StringView s)
Converts a character string to a double.
static Int64 _getDoubleValue(double &v, StringView s)
Converts s to a double.
Class for converting a 'StringView' to an integral type.
View of a UTF-8 character string.
Definition StringView.h:44
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.