P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/p4tools/common/options.h
1#ifndef BACKENDS_P4TOOLS_COMMON_OPTIONS_H_
2#define BACKENDS_P4TOOLS_COMMON_OPTIONS_H_
3
4#include <cstdint>
5#include <optional>
6#include <tuple>
7#include <vector>
8
9#include "lib/compile_context.h"
10#include "lib/cstring.h"
11#include "lib/options.h"
12
13namespace P4::P4Tools {
14
19 private:
21 std::string _toolName;
22
23 public:
24 virtual ~AbstractP4cToolOptions() = default;
26 std::optional<uint32_t> seed = std::nullopt;
27
30
34 std::optional<ICompileContext *> process(const std::vector<const char *> &args);
35
37 std::vector<const char *> compilerArgs;
38
40 std::vector<const char *> *process(int argc, char *const argv[]) override;
41
42 protected:
43 // Self-assignments and copy constructor can only be used by other options.
44 AbstractP4cToolOptions &operator=(const AbstractP4cToolOptions &) = default;
47
48 [[nodiscard]] bool validateOptions() const override;
49
51 [[nodiscard]] const std::string &getToolName() const;
52
54 static std::tuple<int, char **> convertArgs(const std::vector<const char *> &args);
55
56 explicit AbstractP4cToolOptions(std::string_view toolName, std::string_view message);
57};
58
59} // namespace P4::P4Tools
60
61#endif /* BACKENDS_P4TOOLS_COMMON_OPTIONS_H_ */
Definition backends/p4tools/common/options.h:18
const std::string & getToolName() const
The name of the tool associated with these options.
Definition backends/p4tools/common/options.cpp:215
bool validateOptions() const override
Definition backends/p4tools/common/options.cpp:213
std::optional< uint32_t > seed
A seed for the PRNG.
Definition backends/p4tools/common/options.h:26
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.
Definition backends/p4tools/common/options.cpp:20
std::vector< const char * > compilerArgs
Command-line arguments to be sent to the compiler. Populated by @process.
Definition backends/p4tools/common/options.h:37
std::optional< ICompileContext * > process(const std::vector< const char * > &args)
Definition backends/p4tools/common/options.cpp:30
bool disableInformationLogging
Disable information logging.
Definition backends/p4tools/common/options.h:29
Definition lib/options.h:34
Definition common/compiler/compiler_result.cpp:3