Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ValueConvertInternal.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/* ValueConvertInternal.h (C) 2000-2022 */
9/* */
10/* Fonctions pour convertir une chaîne de caractère en un type donné. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_VALUECONVERTINTERNAL_H
13#define ARCANE_UTILS_VALUECONVERTINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18#include "arcane/utils/String.h"
19
20#include <iostream>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31template <typename T> inline bool
32builtInGetArrayValueFromStream(Array<T>& v, std::istream& sbuf)
33{
34 T read_val = T();
35 if (!sbuf.eof())
36 sbuf >> ws;
37 while (!sbuf.eof()) {
38 sbuf >> read_val;
39 if (sbuf.fail() || sbuf.bad())
40 return true;
41 v.add(read_val);
42 sbuf >> ws;
43 }
44 return false;
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50template <typename T> inline bool
51builtInGetArrayValue(Array<T>& v, const String& s)
52{
53 std::istringstream sbuf(s.localstr());
54 return builtInGetArrayValueFromStream(v, sbuf);
55}
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60} // End namespace Arcane
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65#endif
66
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-