utils: Support std::basic_string with allocators

Reviewers: mtomic, mferencevic, msantl

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2102
This commit is contained in:
Teon Banek
2019-05-29 13:37:11 +02:00
parent c0dc37fe34
commit 38c6625e2c
9 changed files with 338 additions and 260 deletions

View File

@@ -344,7 +344,7 @@ static std::optional<std::string> GetQuery() {
PrintHelp();
return "";
} else {
EchoFailure("Unsupported command", trimmed_line);
EchoFailure("Unsupported command", std::string(trimmed_line));
PrintHelp();
return "";
}

View File

@@ -258,7 +258,7 @@ communication::bolt::Value StringToValue(const std::string &str,
std::vector<communication::bolt::Value> array;
array.reserve(elems.size());
for (const auto &elem : elems) {
array.push_back(convert(utils::Trim(elem), elem_type));
array.push_back(convert(std::string(utils::Trim(elem)), elem_type));
}
return array;
}
@@ -279,7 +279,7 @@ void WriteNodeRow(
std::map<std::string, communication::bolt::Value> properties;
for (int i = 0; i < row.size(); ++i) {
const auto &field = fields[i];
auto value = utils::Trim(row[i]);
std::string value(utils::Trim(row[i]));
if (utils::StartsWith(field.type, "id")) {
CHECK(!id) << "Only one node ID must be specified";
NodeId node_id{value, GetIdSpace(field.type)};
@@ -340,7 +340,7 @@ void WriteRelationshipsRow(
std::map<std::string, communication::bolt::Value> properties;
for (int i = 0; i < row.size(); ++i) {
const auto &field = fields[i];
auto value = utils::Trim(row[i]);
std::string value(utils::Trim(row[i]));
if (utils::StartsWith(field.type, "start_id")) {
CHECK(!start_id) << "Only one node ID must be specified";
NodeId node_id{value, GetIdSpace(field.type)};
@@ -460,7 +460,7 @@ std::string GetOutputPath() {
// other flags which are defined in this file.
LoadConfig();
// Without durability_directory, we have to require 'out' flag.
auto durability_dir = utils::Trim(FLAGS_durability_directory);
std::string durability_dir(utils::Trim(FLAGS_durability_directory));
if (durability_dir.empty())
LOG(FATAL) << "Unable to determine snapshot output location. Please, "
"provide the 'out' flag";