Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::StringVariableReplace Class Reference
Collaboration diagram for Arcane::StringVariableReplace:

Static Public Member Functions

static String replaceWithCmdLineArgs (StringView string_with_symbols, bool fatal_if_not_found=false, bool fatal_if_invalid=true)
static String replaceWithCmdLineArgs (const ParameterListWithCaseOption &parameter_list, StringView string_with_symbols, bool fatal_if_not_found=false, bool fatal_if_invalid=true)
 Method allowing symbols in the character string string_with_symbols to be replaced by their values defined in the parameter list.

Static Private Member Functions

static void _splitString (StringView str_view, ArrayView< StringView > str_view_array, char c)
 Method allowing the string "str_view" to be split into multiple segments. The splits will occur between the chars "c". The segments will be added to the "str_view_array" array. Segments with an odd position are symbols. Segments with an even position are not symbols. In the case where the number of segments is even, the last segment will not be a symbol. In the case where an at sign is escaped, it will be placed at an odd position. This special symbol will be considered.
static void _countChar (StringView str_view, char c, Integer &count_c, Integer &count_c_with_escape)
 Method allowing counting the number of separator characters in a character string.

Detailed Description

Definition at line 32 of file StringVariableReplace.h.

Member Function Documentation

◆ _countChar()

void Arcane::StringVariableReplace::_countChar ( StringView str_view,
char c,
Integer & count_c,
Integer & count_c_with_escape )
staticprivate

Method allowing counting the number of separator characters in a character string.

Parameters
str_viewThe character string.
cThe character separating the segments.
count_cThe total number of character c
count_c_with_escapeThe number of characters c preceded by a backslash.

Definition at line 264 of file StringVariableReplace.cc.

References Arcane::StringView::bytes().

Referenced by replaceWithCmdLineArgs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _splitString()

void Arcane::StringVariableReplace::_splitString ( StringView str_view,
ArrayView< StringView > str_view_array,
char c )
staticprivate

Method allowing the string "str_view" to be split into multiple segments. The splits will occur between the chars "c". The segments will be added to the "str_view_array" array. Segments with an odd position are symbols. Segments with an even position are not symbols. In the case where the number of segments is even, the last segment will not be a symbol. In the case where an at sign is escaped, it will be placed at an odd position. This special symbol will be considered.

Parameters
str_view[IN] The character string to split.
str_view_array[OUT] The array that will contain the segments.
cThe character delimiting the segments.

Definition at line 192 of file StringVariableReplace.cc.

References Arcane::StringView::bytes(), Arcane::StringView::length(), and Arcane::StringView::subView().

Referenced by replaceWithCmdLineArgs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceWithCmdLineArgs() [1/2]

String Arcane::StringVariableReplace::replaceWithCmdLineArgs ( const ParameterListWithCaseOption & parameter_list,
StringView string_with_symbols,
bool fatal_if_not_found = false,
bool fatal_if_invalid = true )
static

Method allowing symbols in the character string string_with_symbols to be replaced by their values defined in the parameter list.

A symbol is represented by a character string surrounded by two "\@".

Example: "\@mesh_dir\@/cube.msh" with a parameter "mesh_dir=~/mesh" results in: "~/mesh/cube.msh".

To prevent a "\@" from being replaced, it is possible to put a backslash before it. The backslash will be removed by this method.

Example: "\@mesh_dir\@/cube\\\@.msh" with a parameter "mesh_dir=~/mesh" results in: "~/mesh/cube\@.msh".

If the number of at signs is incorrect (excluding escaped at signs), an error will be triggered, unless the parameter fatal_if_invalid is set to false. In this case, the last at sign will simply be removed.

Example: "\@mesh_dir\@\@/cube.msh" with a parameter "mesh_dir=~/mesh" results in: "~/mesh/cube.msh".

Symbols that are not found will be removed or, if the parameter fatal_if_not_found is set to true, an error will be triggered.

Example: "\@mesh_dir\@/cube.msh" without parameters results in: "/cube.msh".

Finally, having a parameter whose name contains an at sign will be invalid. (However, the value may contain at signs).

Invalid example: parameter "mesh\@_dir=~/mesh" Valid example: parameter "mesh_dir=~/\@/mesh"

Parameters
parameter_listThe list of parameters to consider.
string_with_symbolsThe character string with symbols to replace.
fatal_if_not_foundIf a symbol is not found in the parameter list, an error will be triggered if this parameter is true.
fatal_if_invalidIf the character string is incorrect, an error will be triggered if this parameter is true. Otherwise, the result is not guaranteed.
Returns
The character string with symbols replaced by their values.

Definition at line 97 of file StringVariableReplace.cc.

References _countChar(), _splitString(), Arcane::StringBuilder::append(), ARCANE_FATAL, Arcane::StringView::bytes(), Arcane::StringView::empty(), Arcane::platform::getEnvironmentVariable(), Arcane::ParameterListWithCaseOption::getParameterOrNull(), Arcane::String::null(), Arcane::AbstractArray< T >::size(), and Arcane::StringBuilder::toString().

Here is the call graph for this function:

◆ replaceWithCmdLineArgs() [2/2]

String Arcane::StringVariableReplace::replaceWithCmdLineArgs ( StringView string_with_symbols,
bool fatal_if_not_found = false,
bool fatal_if_invalid = true )
static

Definition at line 36 of file StringVariableReplace.cc.


The documentation for this class was generated from the following files: