simplify string utilities
This commit is contained in:
+10
-8
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <codecvt>
|
||||
|
||||
#include "boost/algorithm/string.hpp"
|
||||
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/string.h"
|
||||
#include "webcc/utility.h"
|
||||
@@ -64,7 +66,7 @@ const std::string& Headers::Get(const std::string& key, bool* existed) const {
|
||||
std::vector<Header>::iterator Headers::Find(const std::string& key) {
|
||||
auto it = headers_.begin();
|
||||
for (; it != headers_.end(); ++it) {
|
||||
if (iequals(it->first, key)) {
|
||||
if (boost::iequals(it->first, key)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -76,7 +78,7 @@ std::vector<Header>::iterator Headers::Find(const std::string& key) {
|
||||
static bool ParseValue(const std::string& str, const std::string& expected_key,
|
||||
std::string* value) {
|
||||
std::string key;
|
||||
if (!split_kv(key, *value, str, '=')) {
|
||||
if (!SplitKV(str, '=', true, &key, value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -125,8 +127,8 @@ void ContentType::Init(const std::string& str) {
|
||||
other = str.substr(pos + 1);
|
||||
}
|
||||
|
||||
trim(media_type_);
|
||||
trim(other);
|
||||
boost::trim(media_type_);
|
||||
boost::trim(other);
|
||||
|
||||
if (media_type_ == "multipart/form-data") {
|
||||
multipart_ = true;
|
||||
@@ -145,12 +147,12 @@ void ContentType::Init(const std::string& str) {
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static inline void Unquote(std::string& str) {
|
||||
trim(str, "\"");
|
||||
boost::trim_if(str, boost::is_any_of("\""));
|
||||
}
|
||||
|
||||
bool ContentDisposition::Init(const std::string& str) {
|
||||
std::vector<std::string> parts;
|
||||
split(parts, str, ';');
|
||||
std::vector<boost::string_view> parts;
|
||||
Split(str, ';', false, &parts);
|
||||
|
||||
if (parts.empty()) {
|
||||
return false;
|
||||
@@ -163,7 +165,7 @@ bool ContentDisposition::Init(const std::string& str) {
|
||||
std::string key;
|
||||
std::string value;
|
||||
for (std::size_t i = 1; i < parts.size(); ++i) {
|
||||
if (!split_kv(key, value, parts[i], '=')) {
|
||||
if (!SplitKV(parts[i].to_string(), '=', true, &key, &value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user