lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lintel::CommandParser< ENUM, undefined > Class Template Reference

#include <CommandParser.h>

Public Member Functions

 CommandParser ()=default
 
void addCommand (const Command &command, ENUM value)
 
void addCommand (Command &&command, ENUM value)
 
ENUM parse (const std::string &command, const std::vector< std::string > &flags)
 
void printHelp (const std::string &command, std::ostream &os=std::cout)
 
void printHelp (std::string_view componentName, const std::string_view alias, std::string_view description, std::ostream &os=std::cout)
 
void printCommandList (std::set< std::string > menuAlias, std::ostream &os=std::cout)
 
std::vector< std::string > allCommandsOf ()
 

Detailed Description

template<typename ENUM, ENUM undefined>
class lintel::CommandParser< ENUM, undefined >

Generic command parser that maps string commands to enum values

Template Parameters
ENUMenum type for command identifiers
undefinedenum value returned for unknown commands

Constructor & Destructor Documentation

◆ CommandParser()

template<typename ENUM , ENUM undefined>
lintel::CommandParser< ENUM, undefined >::CommandParser ( )
default

Member Function Documentation

◆ addCommand() [1/2]

template<typename ENUM , ENUM undefined>
void lintel::CommandParser< ENUM, undefined >::addCommand ( Command &&  command,
ENUM  value 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ addCommand() [2/2]

template<typename ENUM , ENUM undefined>
void lintel::CommandParser< ENUM, undefined >::addCommand ( const Command &  command,
ENUM  value 
)
inline

Register a command with its enum value

◆ allCommandsOf()

template<typename ENUM , ENUM undefined>
std::vector< std::string > lintel::CommandParser< ENUM, undefined >::allCommandsOf ( )
inline
Returns
vector of all registered command name strings

◆ parse()

template<typename ENUM , ENUM undefined>
ENUM lintel::CommandParser< ENUM, undefined >::parse ( const std::string &  command,
const std::vector< std::string > &  flags 
)
inline

Parse a command string and its flags

Parameters
commandthe command name
flagsthe flag arguments
Returns
the matching enum value, or undefined if not found

◆ printCommandList()

template<typename ENUM , ENUM undefined>
void lintel::CommandParser< ENUM, undefined >::printCommandList ( std::set< std::string >  menuAlias,
std::ostream &  os = std::cout 
)
inline

Print a compact list of all commands and aliases

◆ printHelp() [1/2]

template<typename ENUM , ENUM undefined>
void lintel::CommandParser< ENUM, undefined >::printHelp ( const std::string &  command,
std::ostream &  os = std::cout 
)
inline

Print help for a specific command

◆ printHelp() [2/2]

template<typename ENUM , ENUM undefined>
void lintel::CommandParser< ENUM, undefined >::printHelp ( std::string_view  componentName,
const std::string_view  alias,
std::string_view  description,
std::ostream &  os = std::cout 
)
inline

Print full help page for all commands in this component


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