changed del_line_in_str to etract_line
This commit is contained in:
@@ -151,10 +151,14 @@ std::string str_tolower(std::string str)
|
||||
return str;
|
||||
}
|
||||
|
||||
void del_line_in_str(std::string * str, size_t pos, std::string delim)
|
||||
// identify a line in a string, by delim (ex. '\n')
|
||||
// delete this line from the string
|
||||
// and return the deleted line
|
||||
std::string extract_line(std::string * str, size_t pos, std::string delim)
|
||||
{
|
||||
size_t begin;
|
||||
size_t end;
|
||||
std::string del_str;
|
||||
size_t begin;
|
||||
size_t end;
|
||||
|
||||
begin = (*str).rfind(delim, pos);
|
||||
if (begin == std::string::npos)
|
||||
@@ -168,10 +172,18 @@ void del_line_in_str(std::string * str, size_t pos, std::string delim)
|
||||
else
|
||||
end += delim.size();
|
||||
|
||||
del_str = (*str).substr(begin, end - begin);
|
||||
(*str).erase(begin, end - begin);
|
||||
return del_str;
|
||||
}
|
||||
|
||||
|
||||
// transform a str, like a http header, into a map
|
||||
// with <keys> delim <values>
|
||||
// and perform an action on keys and values
|
||||
// action receives address of keys and values, and return bool error :
|
||||
// bool action(&keys, &values)
|
||||
//std::map<std:string, std::string>
|
||||
// str_to_map(str, delim, action = NULL)
|
||||
|
||||
bool operator==(const listen_socket& lhs, int fd)
|
||||
{ return lhs.fd == fd; }
|
||||
|
||||
Reference in New Issue
Block a user