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 ¶meter_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. | |
Definition at line 32 of file StringVariableReplace.h.
|
staticprivate |
Method allowing counting the number of separator characters in a character string.
| str_view | The character string. |
| c | The character separating the segments. |
| count_c | The total number of character c |
| count_c_with_escape | The number of characters c preceded by a backslash. |
Definition at line 264 of file StringVariableReplace.cc.
References Arcane::StringView::bytes().
Referenced by replaceWithCmdLineArgs().
|
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.
| str_view | [IN] The character string to split. |
| str_view_array | [OUT] The array that will contain the segments. |
| c | The 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().
|
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"
| parameter_list | The list of parameters to consider. |
| string_with_symbols | The character string with symbols to replace. |
| fatal_if_not_found | If a symbol is not found in the parameter list, an error will be triggered if this parameter is true. |
| fatal_if_invalid | If the character string is incorrect, an error will be triggered if this parameter is true. Otherwise, the result is not guaranteed. |
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().
|
static |
Definition at line 36 of file StringVariableReplace.cc.