Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cAppArgs Class Reference

#include <cAppState.h>

Inheritance diagram for Gray::cAppArgs:
GrayLib::cSQLConnectionString

Public Member Functions

cStringF get_ArgsStr () const noexcept
 
ITERATE_t get_ArgsQty () const noexcept
 
cStringF GetArgsEnum (ITERATE_t i) const
 command line arg. More...
 
void InitArgsF (const FILECHAR_t *pszCommandArgs, const FILECHAR_t *pszSep=nullptr)
 
void InitArgs2 (int argc, APP_ARGS_t argv)
 
ITERATE_t FindCommandArg (const FILECHAR_t *pszCommandArg, bool bRegex=true, bool bIgnoreCase=true) const
 
ITERATE_t _cdecl FindCommandArgs (bool bIgnoreCase, const FILECHAR_t *pszCommandArgFind,...) const
 
bool HasCommandArg (const FILECHAR_t *pszCommandArg, bool bRegex=true, bool bIgnoreCase=true) const
 

Static Public Member Functions

static bool IsArgSwitch (wchar_t ch) noexcept
 

Public Attributes

cArrayString< FILECHAR_tm_asArgs
 Array of parsed m_sArguments. [0]=appname.exe, [1]=first arg. NOT nullptr terminated like APP_ARGS_t. Honors quoted text. More...
 

Detailed Description

Parse and store command line args used to start an app. Handle Windows and POSIX/DOS formats. Use FILECHAR_t Like MFC CCommandLineInfo

Member Function Documentation

◆ FindCommandArg()

ITERATE_t Gray::cAppArgs::FindCommandArg ( const FILECHAR_t pszCommandArg,
bool  bRegex = true,
bool  bIgnoreCase = true 
) const

Find a command line arg as regex or ignoring case.

  • bRegex = Search for a wildcard prefix.

◆ FindCommandArgs()

ITERATE_t Gray::cAppArgs::FindCommandArgs ( bool  bIgnoreCase,
const FILECHAR_t pszCommandArgFind,
  ... 
) const

Find one of several possible command line args maybe ignoring case. nullptr terminated list.

Returns
index of the first one.

◆ get_ArgsQty()

ITERATE_t Gray::cAppArgs::get_ArgsQty ( ) const
noexcept
Returns
1 = just app path. 2 = app has 1 argument value. etc.

◆ get_ArgsStr()

cStringF Gray::cAppArgs::get_ArgsStr ( ) const
noexcept

Unparsed Command line args as a single line/string. might be used for cOSProcess. Does not contain App.exe name.

◆ GetArgsEnum()

cStringF Gray::cAppArgs::GetArgsEnum ( ITERATE_t  i) const

command line arg.

Get a command line argument parsed param by index. Command line arguments honor "quoted strings" as a single argument.

  • i [0]=app path.
    Returns
    "" = end or array of args.

◆ HasCommandArg()

bool Gray::cAppArgs::HasCommandArg ( const FILECHAR_t pszCommandArg,
bool  bRegex = true,
bool  bIgnoreCase = true 
) const
inline

Do we have a particular argument? pszCommandArg

◆ InitArgs2()

void Gray::cAppArgs::InitArgs2 ( int  argc,
APP_ARGS_t  argv 
)

Posix, _CONSOLE or DOS style arguments. main() style init. set pre-parsed arguments from console style start. ppszArgs[0] = app path

Note
M$ unit tests will block arguments!

◆ InitArgsF()

void Gray::cAppArgs::InitArgsF ( const FILECHAR_t pszCommandArgs,
const FILECHAR_t pszSep = nullptr 
)

set m_sArguments and parse pszCommandArgs to cArrayString. Windows WinMain() style init.

  • pszCommandArgs = assumed to NOT contain the app path name. Similar to _WIN32 CommandLineToArgvW() Honor quotes.

◆ IsArgSwitch()

static bool Gray::cAppArgs::IsArgSwitch ( wchar_t  ch)
inlinestaticnoexcept

Is FILECHAR_t char 'ch' a command line switch char?

Member Data Documentation

◆ m_asArgs

cArrayString<FILECHAR_t> Gray::cAppArgs::m_asArgs

Array of parsed m_sArguments. [0]=appname.exe, [1]=first arg. NOT nullptr terminated like APP_ARGS_t. Honors quoted text.


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