12#ifndef ARCCORE_COMMON_INTERNAL_FIELDPROPERTY_H
13#define ARCCORE_COMMON_INTERNAL_FIELDPROPERTY_H
17#include "arccore/base/String.h"
18#include "arccore/base/PlatformUtils.h"
19#include "arccore/base/internal/ConvertInternal.h"
21#include "arccore/common/Array.h"
22#include "arccore/common/List.h"
39 template <
typename DataType>
44 explicit FieldProperty(
const DataType& default_value)
45 : m_value(default_value)
46 , m_default_value(default_value)
49 : FieldProperty(DataType())
51 FieldProperty& operator=(
const DataType& v)
56 explicit(
false)
operator DataType()
const {
return m_value; }
60 void setValue(
const DataType& v)
71 DataType value()
const {
return m_value; }
72 bool isValueSet()
const {
return m_has_value; }
73 void setValidator(std::function<
void(DataType&)>&& func) { m_validator = func; }
78 DataType m_default_value;
79 bool m_has_value =
false;
80 std::function<void(DataType&)> m_validator;
87 explicit Int32Value(
Int32 v)
90 explicit(
false)
operator Int32()
const {
return value; }
94 Int32Value minValue(
Int32 x)
const
96 return Int32Value(std::max(value, x));
98 Int32Value maxValue(
Int32 x)
const
100 return Int32Value(std::min(value, x));
110 Int32 v = default_value;
111 if (!str_value.
null()) {
112 bool is_bad = Convert::Impl::StringViewToIntegral::getValue(v, str_value);
116 return Int32Value(v);
118 static void checkSet(FieldProperty<bool>& p,
const String& str_value)
122 if (str_value.null())
125 bool is_bad = Convert::Impl::StringViewToIntegral::getValue(v, str_value);
133 if (str_value.null())
136 bool is_bad = Convert::Impl::StringViewToIntegral::getValue(v, str_value);
144 if (str_value.null())
154 p.setValue(str_values);
160 if (str_value.null())
162 p.setValue(str_value);
199 const String& default_value)
201 if (!param_name.
null()) {
202 String v = _searchParam(param_name);
206 for (
const auto& x : env_values) {
211 return default_value;
215 m_values.add(NameValuePair(name, value));
228 for (
const auto& x : m_values) {
229 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.