12#ifndef ARCCORE_COMMON_INTERNAL_FIELDPROPERTY_H
13#define ARCCORE_COMMON_INTERNAL_FIELDPROPERTY_H
17#include "arccore/common/Array.h"
18#include "arccore/base/internal/ConvertInternal.h"
33 template <
typename DataType>
38 explicit FieldProperty(
const DataType& default_value)
39 : m_value(default_value)
40 , m_default_value(default_value)
43 : FieldProperty(DataType())
45 FieldProperty& operator=(
const DataType& v)
50 explicit(
false)
operator DataType()
const {
return m_value; }
54 void setValue(
const DataType& v)
65 DataType value()
const {
return m_value; }
66 bool isValueSet()
const {
return m_has_value; }
67 void setValidator(std::function<
void(DataType&)>&& func) { m_validator = func; }
72 DataType m_default_value;
73 bool m_has_value =
false;
74 std::function<void(DataType&)> m_validator;
81 explicit Int32Value(
Int32 v)
84 explicit(
false)
operator Int32()
const {
return value; }
88 Int32Value minValue(
Int32 x)
const
90 return Int32Value(std::max(value, x));
92 Int32Value maxValue(
Int32 x)
const
94 return Int32Value(std::min(value, x));
104 Int32 v = default_value;
105 if (!str_value.
null()) {
106 bool is_bad = Convert::Impl::StringViewToIntegral::getValue(v, str_value);
110 return Int32Value(v);
112 static void checkSet(FieldProperty<bool>& p,
const String& str_value)
116 if (str_value.null())
119 bool is_bad = Convert::Impl::StringViewToIntegral::getValue(v, str_value);
127 if (str_value.null())
130 bool is_bad = Convert::Impl::StringViewToIntegral::getValue(v, str_value);
138 if (str_value.null())
148 p.setValue(str_values);
154 if (str_value.null())
156 p.setValue(str_value);
193 const String& default_value)
195 if (!param_name.
null()) {
196 String v = _searchParam(param_name);
200 for (
const auto& x : env_values) {
205 return default_value;
209 m_values.add(NameValuePair(name, value));
222 for (
const auto& x : m_values) {
223 if (x.name == param_name)
String getValue(const UniqueArray< String > &env_values, const String ¶m_name, const String &default_value)
Récupère la valeur d'une option.
Chaîne de caractères unicode.
bool null() const
Retourne true si la chaîne est nulle.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
List< String > StringList
Tableau de chaînes de caractères unicode.
std::int32_t Int32
Type entier signé sur 32 bits.