Public Member Functions | Static Public Member Functions | List of all members
CStringList Class Reference

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 ()
 
template<class StringType >
 CStringList (const UList< StringType > &input)
 
template<class StringType >
 CStringList (const SubStrings< StringType > &input)
 
 ~CStringList ()
 
bool empty () const noexcept
 
int size () const noexcept
 
char ** strings () const
 
char ** strings (int start) const
 
size_t length () const
 
const char * data () const
 
void clear ()
 
template<class StringType >
int reset (const UList< StringType > &input)
 
template<class StringType >
int reset (const SubStrings< StringType > &input)
 
const char * operator[] (int i) const
 
template<class StringType >
Foam::List< StringType > asList (int argc, const char *const argv[])
 
template<class StringType >
Foam::List< StringType > asList (const char *const argv[])
 

Static Public Member Functions

static int count (const char *const argv[])
 
template<class StringType >
static List< StringType > asList (int argc, const char *const argv[])
 
template<class StringType >
static List< StringType > asList (const char *const argv[])
 

Detailed Description

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:

wordList myStrings; ...
CStringList cstr(myStrings);
// pass as argc, argv:
someMain(cstr.size(), cstr.strings());
// access the raw characters:
os.write(cstr.data(), cstr.length());

Definition at line 63 of file CStringList.H.

Constructor & Destructor Documentation

◆ CStringList() [1/3]

CStringList ( )
inline

Definition at line 54 of file CStringListI.H.

◆ CStringList() [2/3]

CStringList ( const UList< StringType > &  input)
inlineexplicit

Definition at line 64 of file CStringListI.H.

References Foam::input(), and CStringList::reset().

Here is the call graph for this function:

◆ CStringList() [3/3]

CStringList ( const SubStrings< StringType > &  input)
inlineexplicit

Definition at line 73 of file CStringListI.H.

References Foam::input(), and CStringList::reset().

Here is the call graph for this function:

◆ ~CStringList()

~CStringList ( )
inline

Definition at line 83 of file CStringListI.H.

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ count()

int count ( const char *const  argv[])
inlinestatic

Definition at line 38 of file CStringListI.H.

References n.

◆ empty()

bool empty ( ) const
inlinenoexcept

Definition at line 109 of file CStringListI.H.

Referenced by Foam::system().

Here is the caller graph for this function:

◆ size()

int size ( ) const
inlinenoexcept

Definition at line 115 of file CStringListI.H.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ strings() [1/2]

char ** strings ( ) const
inline

Definition at line 127 of file CStringListI.H.

Referenced by Foam::system().

Here is the caller graph for this function:

◆ strings() [2/2]

char ** strings ( int  start) const
inline

Definition at line 133 of file CStringListI.H.

◆ length()

size_t length ( ) const
inline

Definition at line 121 of file CStringListI.H.

◆ data()

const char * data ( ) const
inline

Definition at line 139 of file CStringListI.H.

◆ clear()

void clear ( )
inline

Definition at line 91 of file CStringListI.H.

◆ reset() [1/2]

int reset ( const UList< StringType > &  input)
inline

Definition at line 146 of file CStringListI.H.

References Foam::input().

Referenced by CStringList::CStringList().

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

◆ reset() [2/2]

int reset ( const SubStrings< StringType > &  input)
inline

Definition at line 153 of file CStringListI.H.

References Foam::input().

Here is the call graph for this function:

◆ asList() [1/4]

static List<StringType> asList ( int  argc,
const char *const  argv[] 
)
static

◆ asList() [2/4]

static List<StringType> asList ( const char *const  argv[])
inlinestatic

◆ operator[]()

const char * operator[] ( int  i) const
inline

Definition at line 161 of file CStringListI.H.

◆ asList() [3/4]

Foam::List<StringType> asList ( int  argc,
const char *const  argv[] 
)

Definition at line 69 of file CStringListTemplates.C.

◆ asList() [4/4]

Foam::List<StringType> asList ( const char *const  argv[])

Definition at line 84 of file CStringListTemplates.C.

References Foam::BitOps::count().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:58
os
OBJstream os(runTime.globalPath()/outputName)