P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::AbstractP4cToolOptions Class Reference

#include <options.h>

Inheritance diagram for P4::P4Tools::AbstractP4cToolOptions:
[legend]

Public Member Functions

std::optional< ICompileContext * > process (const std::vector< const char * > &args)
 
std::vector< const char * > * process (int argc, char *const argv[]) override
 Hook for customizing options processing.
 

Public Attributes

std::vector< const char * > compilerArgs
 Command-line arguments to be sent to the compiler. Populated by @process.
 
bool disableInformationLogging = false
 Disable information logging.
 
std::optional< uint32_t > seed = std::nullopt
 A seed for the PRNG.
 

Protected Member Functions

 AbstractP4cToolOptions (AbstractP4cToolOptions &&)=default
 
 AbstractP4cToolOptions (const AbstractP4cToolOptions &)=default
 
 AbstractP4cToolOptions (std::string_view toolName, std::string_view message)
 
const std::string & getToolName () const
 The name of the tool associated with these options.
 
AbstractP4cToolOptionsoperator= (const AbstractP4cToolOptions &)=default
 
bool validateOptions () const override
 
- Protected Member Functions inherited from P4::Util::Options
 Options (std::string_view message)
 
void registerOption (const char *option, const char *argName, OptionProcessor processor, const char *description, OptionFlags flags=OptionFlags::Default)
 
void registerUsage (const char *msg)
 
void setOutStream (std::ostream *out)
 
cstring getBinaryName ()
 
cstring getBuildDate ()
 
cstring getCompileCommand ()
 
virtual const char * getIncludePath () const =0
 
virtual void usage ()
 

Static Protected Member Functions

static std::tuple< int, char ** > convertArgs (const std::vector< const char * > &args)
 Converts a vector of command-line arguments into the traditional (argc, argv) format.
 

Additional Inherited Members

- Protected Types inherited from P4::Util::Options
enum  OptionFlags { Default = 0 , Hide = 1 << 0 , OptionalArgument = 1 << 1 }
 
using OptionProcessor = std::function<bool(const char *)>
 
- Protected Attributes inherited from P4::Util::Options
std::vector< const char * > additionalUsage
 
const char * binaryName
 
cstring buildDate
 
bool collectUnknownOptions = false
 
cstring compileCommand
 
cstring message
 
std::vector< cstringoptionOrder
 
std::map< cstring, const Option * > options
 
std::ostream * outStream = &std::cerr
 
std::vector< const char * > remainingOptions
 

Detailed Description

Encapsulates and processes command-line options for a compiler-based tool. Implementations should use the singleton pattern and define a static get() for obtaining the singleton instance.

Member Function Documentation

◆ process() [1/2]

std::optional< ICompileContext * > P4::P4Tools::AbstractP4cToolOptions::process ( const std::vector< const char * > & args)

Processes options.

Returns
a compilation context on success, std::nullopt on error.

◆ process() [2/2]

std::vector< const char * > * P4::P4Tools::AbstractP4cToolOptions::process ( int argc,
char *const argv[] )
overridevirtual

Hook for customizing options processing.

Reimplemented from P4::Util::Options.

◆ validateOptions()

bool P4::P4Tools::AbstractP4cToolOptions::validateOptions ( ) const
nodiscardoverrideprotectedvirtual

Checks if parsed options make sense with respect to each-other.

Returns
true if the validation was successful and false otherwise.

Reimplemented from P4::Util::Options.

Reimplemented in P4::P4Tools::P4Testgen::TestgenOptions.