NAWA 0.9
Web Application Framework for C++
nawa::request::GPC Class Reference

#include <nawa/request/GPC/GPC.h>

Inherited by nawa::request::Post.

Public Types

enum class  Source { GET , POST , COOKIE }
 

Public Member Functions

virtual ~GPC ()
 
 GPC (RequestInitContainer const &requestInit, Source source)
 
std::string operator[] (std::string const &gpcVar) const
 
std::vector< std::string > getVector (std::string const &gpcVar) const
 
size_t count (std::string const &gpcVar) const
 
std::unordered_multimap< std::string, std::string > const & getMultimap () const
 
std::unordered_multimap< std::string, std::string >::const_iterator begin () const
 
std::unordered_multimap< std::string, std::string >::const_iterator end () const
 
virtual operator bool () const
 

Detailed Description

Accessor for GET, POST, and COOKIE variables.

Definition at line 40 of file GPC.h.

Member Enumeration Documentation

◆ Source

enum class nawa::request::GPC::Source
strong
Enumerator
GET 
POST 
COOKIE 

Definition at line 44 of file GPC.h.

Constructor & Destructor Documentation

◆ ~GPC()

virtual nawa::request::GPC::~GPC ( )
virtual

◆ GPC()

request::GPC::GPC ( RequestInitContainer const &  requestInit,
Source  source 
)

Definition at line 39 of file GPC.cpp.

Member Function Documentation

◆ operator[]()

std::string request::GPC::operator[] ( std::string const &  gpcVar) const

Get a GET, POST, or COOKIE variable. If the query contains more than one variable of the same name, only one of them (usually the first definition) will be returned. For accessing all definitions, please use getVector(). Complexity is logarithmic, so if you want to access a value multiple times, saving it in a variable is a good idea.

Parameters
gpcVarName of the variable.
Returns
Value of the variable. Empty string if not set (or empty - use count() for checking whether the variable is set).

Definition at line 54 of file GPC.cpp.

◆ getVector()

std::vector< std::string > request::GPC::getVector ( std::string const &  gpcVar) const

Get all GET, POST, or COOKIE variables with the given name.

Parameters
gpcVarName of the variables.
Returns
Vector of values. Empty if not set.

Definition at line 62 of file GPC.cpp.

◆ count()

size_t request::GPC::count ( std::string const &  gpcVar) const

Get the number of submitted GET, POST, or COOKIE variables with the given name.

Parameters
gpcVarName of the variables.
Returns
Number of occurrences.

Definition at line 71 of file GPC.cpp.

◆ getMultimap()

std::unordered_multimap< std::string, std::string > const & request::GPC::getMultimap ( ) const

Get a reference to the GET, POST, or COOKIE multimap.

Returns
Reference to the multimap.

Definition at line 75 of file GPC.cpp.

◆ begin()

std::unordered_multimap< std::string, std::string >::const_iterator request::GPC::begin ( ) const

Get constant begin iterator to the multimap containing all GET, POST, or COOKIE data.

Returns
Iterator to the first element of the multimap.

Definition at line 79 of file GPC.cpp.

◆ end()

std::unordered_multimap< std::string, std::string >::const_iterator request::GPC::end ( ) const

Get constant end iterator to the multimap containing all GET, POST, or COOKIE data.

Returns
Iterator to the end of the multimap.

Definition at line 83 of file GPC.cpp.

◆ operator bool()

request::GPC::operator bool ( ) const
explicitvirtual

Shortcut to check for the existence of GET/POST/COOKIE values (including files in the case of POST).

Returns
True if GET/POST/COOKIE values are available.

Reimplemented in nawa::request::Post.

Definition at line 87 of file GPC.cpp.


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