drogon
C++14/17-based HTTP application framework
Loading...
Searching...
No Matches
drogon::HttpViewData Class Reference

This class represents the data set displayed in views. More...

#include <drogon/HttpViewData.h>

Collaboration diagram for drogon::HttpViewData:

Public Member Functions

template<typename T>
const T & get (const std::string &key) const
void insert (const std::string &key, std::any &&obj)
 Insert an item identified by the key parameter into the data set;.
void insert (const std::string &key, const std::any &obj)
template<typename T>
void insertAsString (const std::string &key, T &&val)
void insertFormattedString (const std::string &key, const char *format,...)
 Insert a formatted string identified by the key parameter.
std::any & operator[] (const std::string &key) const
 Get the 'any' object by the key parameter.

Static Public Member Functions

static std::string htmlTranslate (const char *str, size_t length)
 Translate some special characters to HTML format.
static std::string htmlTranslate (const std::string_view &str)
static bool needTranslation (const std::string_view &str)

Protected Types

using ViewDataMap = std::unordered_map<std::string, std::any>

Protected Attributes

ViewDataMap viewData_

Detailed Description

This class represents the data set displayed in views.

Member Function Documentation

◆ get()

template<typename T>
const T & drogon::HttpViewData::get ( const std::string & key) const
inline

The function template is used to get an item in the data set by the key parameter.

◆ htmlTranslate()

std::string drogon::HttpViewData::htmlTranslate ( const char * str,
size_t length )
static

Translate some special characters to HTML format.

such as:

" --> &quot;
& --> &amp;
< --> &lt;
> --> &gt;

◆ insertAsString()

template<typename T>
void drogon::HttpViewData::insertAsString ( const std::string & key,
T && val )
inline

Insert an item identified by the key parameter into the data set; The item is converted to a string.


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