mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-27 22:31:09 -04:00
Do not use std::sto[fi] or std::to_string.
This commit is contained in:
parent
4c3acd06de
commit
282b85c341
@ -105,6 +105,15 @@ static pthread_mutex_t searchLock = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
static pthread_mutex_t compressorLock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t compressorLock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static pthread_mutex_t regexLock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t regexLock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline std::string _tostring(const T& value)
|
||||||
|
{
|
||||||
|
std::ostringstream stream;
|
||||||
|
stream << value;
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Try to get the mimeType from the file extension */
|
/* Try to get the mimeType from the file extension */
|
||||||
static std::string getMimeTypeForFile(const std::string& filename)
|
static std::string getMimeTypeForFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
@ -352,7 +361,7 @@ static struct MHD_Response* build_callback_response_from_entry(
|
|||||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_RANGE, oss.str().c_str());
|
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_RANGE, oss.str().c_str());
|
||||||
|
|
||||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_LENGTH,
|
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_LENGTH,
|
||||||
std::to_string(range_len).c_str());
|
_tostring(range_len).c_str());
|
||||||
|
|
||||||
/* Specify the mime type */
|
/* Specify the mime type */
|
||||||
MHD_add_response_header(
|
MHD_add_response_header(
|
||||||
|
@ -197,16 +197,6 @@ std::string RequestContext::get_argument(const std::string& name) {
|
|||||||
return arguments.at(name);
|
return arguments.at(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
|
||||||
unsigned int RequestContext::get_argument(const std::string& name) {
|
|
||||||
return std::stoi(arguments.at(name).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
float RequestContext::get_argument(const std::string& name) {
|
|
||||||
return std::stof(arguments.at(name).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string RequestContext::get_header(const std::string& name) {
|
std::string RequestContext::get_header(const std::string& name) {
|
||||||
return headers.at(name);
|
return headers.at(name);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,13 @@ class RequestContext {
|
|||||||
|
|
||||||
std::string get_header(const std::string& name);
|
std::string get_header(const std::string& name);
|
||||||
template<typename T=std::string>
|
template<typename T=std::string>
|
||||||
T get_argument(const std::string& name);
|
T get_argument(const std::string& name) {
|
||||||
|
std::istringstream stream(arguments.at(name));
|
||||||
|
T v;
|
||||||
|
stream >> v;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RequestMethod get_method();
|
RequestMethod get_method();
|
||||||
std::string get_url();
|
std::string get_url();
|
||||||
@ -96,5 +102,7 @@ class RequestContext {
|
|||||||
static int fill_argument(void *, enum MHD_ValueKind, const char*, const char*);
|
static int fill_argument(void *, enum MHD_ValueKind, const char*, const char*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> std::string RequestContext::get_argument(const std::string& name);
|
||||||
|
|
||||||
|
|
||||||
#endif //REQUEST_CONTEXT_H
|
#endif //REQUEST_CONTEXT_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user