An adapter for copying a list of C++ strings into a list of C-style strings for passing to C code that expects argc/argv parameters. More...
Public Member Functions | |
| CStringList (const CStringList &)=delete | |
| No copy construct. More... | |
| void | operator= (const CStringList &)=delete |
| No copy assignment. More... | |
| constexpr | CStringList () noexcept |
| Default construct, adding content later (via reset). More... | |
| CStringList (std::initializer_list< const char *const > input) | |
| Copy construct from a list of C-strings. More... | |
| template<class StringType > | |
| CStringList (const UList< StringType > &input) | |
| Copy construct from a list of strings. More... | |
| CStringList (const UList< std::string_view > &input) | |
| Copy construct from a list of string_views. More... | |
| CStringList (const std::vector< std::string_view > &input) | |
| Copy construct from a list of string_views. More... | |
| CStringList (const SubStrings &input) | |
| Copy construct from a list of sub-string references. More... | |
| ~CStringList () | |
| Destructor. Invokes clear() to free memory. More... | |
| bool | empty () const noexcept |
| True if the size (ie, argc) is zero. More... | |
| int | size () const noexcept |
| Return the number of C-strings (ie, argc) More... | |
| std::string_view | view () const |
| The flattened character content, with interspersed nul-chars. More... | |
| const char * | cdata_bytes () const noexcept |
| The flattened character content, with interspersed nul-chars. More... | |
| size_t | size_bytes () const noexcept |
| Overall length of the flattened character (data) content including interspersed nul-chars but not the trailing nul-char. More... | |
| const char * | data () const noexcept |
| Same as cdata_bytes() More... | |
| size_t | length () const noexcept |
| Same as size_bytes() More... | |
| const char * | get (int i) const |
| Return string element at the given index. No bounds checking. More... | |
| char ** | strings () const noexcept |
| Return the list of C-strings (ie, argv) More... | |
| char ** | strings (int start) const |
| Return the sublist of C-strings (ie, argv) starting at the specified offset. More... | |
| void | clear () |
| Clear contents and free memory. More... | |
| int | reset (std::initializer_list< const char *const > input) |
| Copy the input list of C-strings. More... | |
| template<class StringType > | |
| int | reset (const UList< StringType > &input) |
| Copy the input list of strings. More... | |
| int | reset (const SubStrings &input) |
| Copy the input list of strings. More... | |
| const char * | operator[] (int i) const |
| Return element at the given index. No bounds checking. More... | |
Static Public Member Functions | |
| static int | count (const char *const argv[]) |
| Count the number of parameters until the first nullptr. More... | |
| template<class StringType = std::string> | |
| static List< StringType > | asList (int argc, const char *const argv[]) |
| Create a list from argc/argv parameters. More... | |
| template<class StringType = std::string> | |
| static List< StringType > | asList (const char *const argv[]) |
| Create a list from a nullptr-terminated list of argv parameters. More... | |
An adapter for copying a list of C++ strings into a list of C-style strings for passing to C code that expects argc/argv parameters.
In addition to providing a C-compatible list of C-strings, the string lists are flattened into a single string of data that can be also be passed en mass.
Example use:
Definition at line 67 of file CStringList.H.
|
delete |
No copy construct.
|
inlinenoexcept |
Default construct, adding content later (via reset).
Definition at line 65 of file CStringListI.H.
|
inlineexplicit |
Copy construct from a list of C-strings.
Copies the input characters.
Definition at line 75 of file CStringListI.H.
References reset().

|
inlineexplicit |
Copy construct from a list of strings.
Copies the input characters.
Definition at line 86 of file CStringListI.H.
|
inlineexplicit |
Copy construct from a list of string_views.
Copies the input characters.
Definition at line 94 of file CStringListI.H.
|
inlineexplicit |
Copy construct from a list of string_views.
Copies the input characters.
Definition at line 103 of file CStringListI.H.
|
inlineexplicit |
Copy construct from a list of sub-string references.
Copies the input characters.
Definition at line 113 of file CStringListI.H.
|
inline |
Destructor. Invokes clear() to free memory.
Definition at line 123 of file CStringListI.H.
References clear().

|
delete |
No copy assignment.
|
inlinestatic |
Count the number of parameters until the first nullptr.
Return 0 if argv is nullptr.
Definition at line 49 of file CStringListI.H.
References n.
|
inlinenoexcept |
True if the size (ie, argc) is zero.
Definition at line 213 of file CStringList.H.
Referenced by Foam::system().

|
inlinenoexcept |
Return the number of C-strings (ie, argc)
Definition at line 218 of file CStringList.H.
|
inline |
The flattened character content, with interspersed nul-chars.
Definition at line 131 of file CStringListI.H.
|
inlinenoexcept |
The flattened character content, with interspersed nul-chars.
Definition at line 228 of file CStringList.H.
|
inlinenoexcept |
Overall length of the flattened character (data) content including interspersed nul-chars but not the trailing nul-char.
Definition at line 234 of file CStringList.H.
|
inlinenoexcept |
Same as cdata_bytes()
Definition at line 239 of file CStringList.H.
|
inlinenoexcept |
Same as size_bytes()
Definition at line 244 of file CStringList.H.
|
inline |
Return string element at the given index. No bounds checking.
Definition at line 249 of file CStringList.H.
|
inlinenoexcept |
Return the list of C-strings (ie, argv)
The position at argc is a nullptr
Definition at line 256 of file CStringList.H.
Referenced by Foam::system().

|
inline |
Return the sublist of C-strings (ie, argv) starting at the specified offset.
| start | the offset, must be less than argc |
Definition at line 155 of file CStringListI.H.
|
inline |
Clear contents and free memory.
Definition at line 137 of file CStringListI.H.
| int reset | ( | std::initializer_list< const char *const > | input | ) |
Copy the input list of C-strings.
|
inline |
Copy the input list of strings.
Definition at line 287 of file CStringList.H.
|
inline |
Copy the input list of strings.
Definition at line 297 of file CStringList.H.
|
static |
Create a list from argc/argv parameters.
A null pointer for argv is permissible when argc is zero.
|
inlinestatic |
Create a list from a nullptr-terminated list of argv parameters.
Using a nullptr for argv is permissible.
|
inline |
Return element at the given index. No bounds checking.
Definition at line 327 of file CStringList.H.