Browse Source

add methods to Request for adding and removing parameters

Added methods:
void AddParam(const std::wstring & param_name, const std::wstring & param_value);
void AddParam(const wchar_t * param_name, const wchar_t * param_value);
void RemoveParam(const wchar_t * param_name);
void RemoveParam(const std::wstring & param_name);

This is only temporarily, we will be using the pt::Space structure in the future.
master
Tomasz Sowa 4 months ago
parent
commit
df04075f1c
  1. 84
      winixd/core/request.cpp
  2. 6
      winixd/core/request.h

84
winixd/core/request.cpp

@ -541,6 +541,90 @@ const std::wstring & Request::ParamValue(const std::wstring & param_name)
}
void Request::AddParam(const std::wstring & param_name, const std::wstring & param_value)
{
bool found = false;
ParamTab::iterator i;
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
{
if( i->name == param_name )
{
i->value = param_value;
found = true;
}
}
if( !found )
{
Param param;
param.name = param_name;
param.value = param_value;
param_tab.push_back(param);
}
}
void Request::AddParam(const wchar_t * param_name, const wchar_t * param_value)
{
bool found = false;
ParamTab::iterator i;
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
{
if( i->name == param_name )
{
i->value = param_value;
found = true;
}
}
if( !found )
{
Param param;
param.name = param_name;
param.value = param_value;
param_tab.push_back(param);
}
}
void Request::RemoveParam(const wchar_t * param_name)
{
ParamTab::iterator i;
for(size_t i=0 ; i < param_tab.size() ; )
{
if( param_tab[i].name == param_name )
{
param_tab.erase(param_tab.begin() + i);
}
else
{
++i;
}
}
}
void Request::RemoveParam(const std::wstring & param_name)
{
ParamTab::iterator i;
for(size_t i=0 ; i < param_tab.size() ; )
{
if( param_tab[i].name == param_name )
{
param_tab.erase(param_tab.begin() + i);
}
else
{
++i;
}
}
}
void Request::current_dir(morm::Wrapper & wrapper)

6
winixd/core/request.h

@ -437,6 +437,12 @@ public:
std::wstring * ParamValuep(const wchar_t * param_name); // returns nullptr if there is no such a parameter
std::wstring * ParamValuep(const std::wstring & param_name); // returns nullptr if there is no such a parameter
void AddParam(const std::wstring & param_name, const std::wstring & param_value);
void AddParam(const wchar_t * param_name, const wchar_t * param_value);
void RemoveParam(const wchar_t * param_name);
void RemoveParam(const std::wstring & param_name);
bool IsPostVar(const wchar_t * var);
bool IsPostVar(const std::wstring & var);
const std::wstring & PostVar(const wchar_t * var); // returns an empty string if there is no such a parameter

Loading…
Cancel
Save