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

Represents a single 'server' block from the configuration file. More...

#include <ServerBlock.hpp>

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

Public Member Functions

 ServerBlock ()
bool hasLocation (LocationBlock const &)
void addLocation (LocationBlock const &)
void setListen (std::string const &listenArg)
 Parses a listen directive string and sets the address and port.
LocationBlock const * getLocation (std::string const &name) const
 Retrieves the configuration for a specific location path.
LocationBlockMap const & locations () const
LocationBlockMaplocations ()
int getPort () const
std::string const & getAddress () const
Public Member Functions inherited from config::Block
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)

Private Attributes

int port_
std::string address_
LocationBlockMap locations_

Additional Inherited Members

Protected Attributes inherited from config::Block
DirectiveMap directives_

Detailed Description

Represents a single 'server' block from the configuration file.

This class is a strongly-typed container for all the directives and nested location blocks defined within a single server context. It holds settings like the listening port, server names, and a collection of LocationBlock objects.

Constructor & Destructor Documentation

◆ ServerBlock()

config::ServerBlock::ServerBlock ( )

Member Function Documentation

◆ addLocation()

void config::ServerBlock::addLocation ( LocationBlock const & b)

◆ getAddress()

std::string const & config::ServerBlock::getAddress ( ) const
inline

◆ getLocation()

LocationBlock const * config::ServerBlock::getLocation ( std::string const & name) const

Retrieves the configuration for a specific location path.

Parameters
nameThe request path (URI) to match against a location block.
Returns
A const pointer to the matched LocationBlock, or NULL if no match is found.

◆ getPort()

int config::ServerBlock::getPort ( ) const
inline

◆ hasLocation()

bool config::ServerBlock::hasLocation ( LocationBlock const & b)

◆ locations() [1/2]

LocationBlockMap & config::ServerBlock::locations ( )
inline

◆ locations() [2/2]

LocationBlockMap const & config::ServerBlock::locations ( ) const
inline

◆ setListen()

void config::ServerBlock::setListen ( std::string const & listenArg)

Parses a listen directive string and sets the address and port.

Parameters
listenArgThe raw string argument from the config file (e.g., "8080", "127.0.0.1:80").
Exceptions
ConfigErrorif the argument is invalid.

Member Data Documentation

◆ address_

std::string config::ServerBlock::address_
private

◆ locations_

LocationBlockMap config::ServerBlock::locations_
private

◆ port_

int config::ServerBlock::port_
private

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