Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::CommandLineArgs Class Reference

Provides a program's command line arguments encoded in UTF-8. More...

#include <bond/tools/commandline.h>

Public Member Functions

 CommandLineArgs (Allocator &allocator, int argc, const char *argv[])
 Constructs a CommandLineArgs object.
 CommandLineArgs (const CommandLineArgs &other)=delete
CommandLineArgs & operator= (const CommandLineArgs &other)=delete
int GetArgc () const
 Returns the number of arguments, including the program name.
const char ** GetArgv () const
 Returns the UTF-8 encoded, null-terminated argument vector. It remains valid for the lifetime of this object.

Detailed Description

Provides a program's command line arguments encoded in UTF-8.

On Windows, the narrow argv passed to main is encoded in the ANSI code page, so non-ASCII arguments are altered or lost. CommandLineArgs retrieves the UTF-16 command line from the operating system and converts each argument to UTF-8. If that fails, it falls back to the given argv. On other platforms, argv is already UTF-8 and is returned unchanged.

Constructor & Destructor Documentation

◆ CommandLineArgs() [1/2]

Bond::CommandLineArgs::CommandLineArgs ( Allocator & allocator,
int argc,
const char * argv[] )

Constructs a CommandLineArgs object.

Parameters
allocatorAllocator used for the converted arguments. It must outlive this object.
argcThe argument count passed to main.
argvThe argument vector passed to main.

◆ CommandLineArgs() [2/2]

Bond::CommandLineArgs::CommandLineArgs ( const CommandLineArgs & other)
delete

Member Function Documentation

◆ GetArgc()

int Bond::CommandLineArgs::GetArgc ( ) const
inline

Returns the number of arguments, including the program name.

◆ GetArgv()

const char ** Bond::CommandLineArgs::GetArgv ( ) const
inline

Returns the UTF-8 encoded, null-terminated argument vector. It remains valid for the lifetime of this object.

◆ operator=()

CommandLineArgs & Bond::CommandLineArgs::operator= ( const CommandLineArgs & other)
delete

The documentation for this class was generated from the following file:
  • include/bond/tools/commandline.h