ComPPare 1.0.0
Loading...
Searching...
No Matches
comppare::plugin::PluginArgParser Class Reference

Argument parser for plugin command-line arguments. More...

#include <plugin.hpp>

Public Member Functions

 PluginArgParser (std::string header, bool strict_missing_value=false)
 
 PluginArgParser (const PluginArgParser &)=delete
 
PluginArgParseroperator= (const PluginArgParser &)=delete
 
 PluginArgParser (PluginArgParser &&)=default
 
PluginArgParseroperator= (PluginArgParser &&)=default
 
 ~PluginArgParser ()=default
 
std::pair< int, char ** > parse (int argc, char **argv)
 
int argc () const
 
char ** argv ()
 
const std::vector< std::string > & args () const
 

Static Private Member Functions

static bool starts_with (const std::string &s, const std::string &prefix)
 
static std::vector< std::string > split_shell_like (const std::string &s)
 
static void append_tokens (std::vector< std::string > &dst, const std::string &value)
 

Private Attributes

std::string header_
 
bool strict_
 
std::vector< std::string > args_
 
std::vector< char * > cargv_
 

Detailed Description

Argument parser for plugin command-line arguments.

This class is responsible for parsing command-line arguments specific to a plugin. Each plugin can have its own set of arguments, which are prefixed by a unique header. The parser supports both --header=value and --header value formats for specifying arguments.

Example usage:

PluginArgParser parser("--myplugin");
Argument parser for plugin command-line arguments.
Definition plugin.hpp:107

In Command Line:

--myplugin="--flag=value"
--myplugin "--flag1 value1 --flag2=value2"

Then parser.parse(argc, argv) will extract the quoted values as arguments for the plugin.

Constructor & Destructor Documentation

◆ PluginArgParser() [1/3]

comppare::plugin::PluginArgParser::PluginArgParser ( std::string  header,
bool  strict_missing_value = false 
)
inlineexplicit

◆ PluginArgParser() [2/3]

comppare::plugin::PluginArgParser::PluginArgParser ( const PluginArgParser )
delete

◆ PluginArgParser() [3/3]

comppare::plugin::PluginArgParser::PluginArgParser ( PluginArgParser &&  )
default

◆ ~PluginArgParser()

comppare::plugin::PluginArgParser::~PluginArgParser ( )
default

Member Function Documentation

◆ append_tokens()

static void comppare::plugin::PluginArgParser::append_tokens ( std::vector< std::string > &  dst,
const std::string &  value 
)
inlinestaticprivate

◆ argc()

int comppare::plugin::PluginArgParser::argc ( ) const
inline

◆ args()

const std::vector< std::string > & comppare::plugin::PluginArgParser::args ( ) const
inline

◆ argv()

char ** comppare::plugin::PluginArgParser::argv ( )
inline

◆ operator=() [1/2]

PluginArgParser & comppare::plugin::PluginArgParser::operator= ( const PluginArgParser )
delete

◆ operator=() [2/2]

PluginArgParser & comppare::plugin::PluginArgParser::operator= ( PluginArgParser &&  )
default

◆ parse()

std::pair< int, char ** > comppare::plugin::PluginArgParser::parse ( int  argc,
char **  argv 
)
inline

◆ split_shell_like()

static std::vector< std::string > comppare::plugin::PluginArgParser::split_shell_like ( const std::string &  s)
inlinestaticprivate

◆ starts_with()

static bool comppare::plugin::PluginArgParser::starts_with ( const std::string &  s,
const std::string &  prefix 
)
inlinestaticprivate

Member Data Documentation

◆ args_

std::vector<std::string> comppare::plugin::PluginArgParser::args_
private

◆ cargv_

std::vector<char *> comppare::plugin::PluginArgParser::cargv_
private

◆ header_

std::string comppare::plugin::PluginArgParser::header_
private

◆ strict_

bool comppare::plugin::PluginArgParser::strict_
private

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