22 std::string
const &name) {
23 if (args.size() < min || args.size() > max) {
24 std::string msg =
"'" + name +
"' directive requires ";
30 msg +=
" argument(s).";
40 if (arg.
type != expectedType) {
50 std::string
const &name) {
51 if (allowedContexts.find(block.
name()) == std::string::npos) {
52 throw ConfigError(
"'" + name +
"' directive is not allowed in: " + block.
name());
Base class for configuration blocks like 'server' and 'location'.
Definition Block.hpp:15
std::string const & name() const
Gets the name of the block.
Definition Block.cpp:149
Definition ConfigException.hpp:26
Static utility class for common configuration validation tasks.
Definition ValidationUtils.hpp:15
static void checkType(Token const &arg, TokenType expectedType, std::string const &name)
Verifies that a specific argument matches the expected token type.
Definition ValidationUtils.hpp:39
static void checkArgs(ParsedDirectiveArgs const &args, size_t min, size_t max, std::string const &name)
Verifies that the number of arguments is within the inclusive range [min, max].
Definition ValidationUtils.hpp:21
static void checkContext(Block const &block, std::string const &allowedContexts, std::string const &name)
Verifies if the directive is being processed within an allowed context.
Definition ValidationUtils.hpp:49
static std::string getTokenTypeName(TokenType type)
Definition ValidationUtils.hpp:57
Definition ArgumentFactory.hpp:5
std::vector< Token > ParsedDirectiveArgs
Definition types.hpp:13
TokenType
Represents the type of a lexical token.
Definition Token.hpp:12
@ STRING
A quoted string literal, e.g., "hello world".
Definition Token.hpp:14
@ IDENTIFIER
A keyword or variable name, e.g., "server_name".
Definition Token.hpp:13
@ NUMBER
A numeric literal, e.g., 8080.
Definition Token.hpp:15
std::string toString(T const &v)
Definition string.hpp:7
Represents a single lexical token with a type and a literal value.
Definition Token.hpp:28
TokenType type
Definition Token.hpp:30