Webserv
Loading...
Searching...
No Matches
config::Block Class Reference

Base class for configuration blocks like 'server' and 'location'. More...

#include <Block.hpp>

Inheritance diagram for config::Block:
config::LocationBlock config::ServerBlock

Public Member Functions

virtual ~Block ()
bool has (std::string const &key) const
 Checks if a directive exists within the block.
StringVector const * operator[] (std::string const &key) const
StringVectoroperator[] (std::string const &key)
void add (std::string const &key, StringVector const &values)
void add (std::string const &key, std::string const &value)
DirectiveMap const & getDirectives () const
 Provides read-only access to the underlying directive map.
DirectiveMapgetDirectives ()
 Provides read-write access to the underlying directive map.
StringVector const * get (std::string const &key) const
 Retrieves the arguments for a specific directive.
std::string getRoot () const
 A convenient, strongly-typed accessor for the 'root' directive.
void setRoot (std::string const &root)

Protected Attributes

DirectiveMap directives_

Friends

class DirectiveHandler

Detailed Description

Base class for configuration blocks like 'server' and 'location'.

This class provides a generic storage mechanism for configuration directives using a map, allowing for high extensibility.

Constructor & Destructor Documentation

◆ ~Block()

config::Block::~Block ( )
virtual

Member Function Documentation

◆ add() [1/2]

void config::Block::add ( std::string const & key,
std::string const & value )

◆ add() [2/2]

void config::Block::add ( std::string const & key,
StringVector const & values )

◆ get()

StringVector const * config::Block::get ( std::string const & key) const

Retrieves the arguments for a specific directive.

Parameters
keyThe name of the directive (e.g., "root").
Returns
A const pointer to the vector of arguments, or NULL if the directive is not found or has no arguments.

◆ getDirectives() [1/2]

DirectiveMap & config::Block::getDirectives ( )

Provides read-write access to the underlying directive map.

Provides read-write access to the underlying directive map. (Primarily for use by the ConfigBuilder).

◆ getDirectives() [2/2]

DirectiveMap const & config::Block::getDirectives ( ) const

Provides read-only access to the underlying directive map.

◆ getRoot()

std::string config::Block::getRoot ( ) const

A convenient, strongly-typed accessor for the 'root' directive.

Returns
The root path if set, otherwise an empty string.

◆ has()

bool config::Block::has ( std::string const & key) const

Checks if a directive exists within the block.

◆ operator[]() [1/2]

StringVector & config::Block::operator[] ( std::string const & key)

◆ operator[]() [2/2]

StringVector const * config::Block::operator[] ( std::string const & key) const

◆ setRoot()

void config::Block::setRoot ( std::string const & root)

◆ DirectiveHandler

friend class DirectiveHandler
friend

Member Data Documentation

◆ directives_

DirectiveMap config::Block::directives_
protected

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