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// Boost
5#include <cstdint>
6#include <optional>
7#include <tuple>
8#include <vector>
9
10#include "lib/compile_context.h"
11#include "lib/cstring.h"
12#include "lib/options.h"
13
14namespace P4Tools {
15
20 private:
22 std::string _toolName;
23
24 public:
25 virtual ~AbstractP4cToolOptions() = default;
27 std::optional<uint32_t> seed = std::nullopt;
28
31
35 std::optional<ICompileContext *> process(const std::vector<const char *> &args);
36
37 // No copy constructor and no self-assignments.
39
40 AbstractP4cToolOptions &operator=(const AbstractP4cToolOptions &) = delete;
41
42 protected:
44 std::vector<const char *> compilerArgs;
45
47 std::vector<const char *> *process(int argc, char *const argv[]) override;
48
49 [[nodiscard]] bool validateOptions() const override;
50
52 [[nodiscard]] const std::string &getToolName() const;
53
55 static std::tuple<int, char **> convertArgs(const std::vector<const char *> &args);
56
57 explicit AbstractP4cToolOptions(std::string_view toolName, std::string_view message);
58};
59
60} // namespace P4Tools
61
62#endif /* BACKENDS_P4TOOLS_COMMON_OPTIONS_H_ */
Definition backends/p4tools/common/options.h:19
bool validateOptions() const override
Definition backends/p4tools/common/options.cpp:213
std::vector< const char * > compilerArgs
Command-line arguments to be sent to the compiler. Populated by @process.
Definition backends/p4tools/common/options.h:44
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::optional< uint32_t > seed
A seed for the PRNG.
Definition backends/p4tools/common/options.h:27
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:30
const std::string & getToolName() const
The name of the tool associated with these options.
Definition backends/p4tools/common/options.cpp:215
Definition lib/options.h:34
Definition common/compiler/compiler_result.cpp:3