Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix toString function defect #345

Merged
merged 4 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/parser/AdminSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ std::string HostList::toString() const {
buf += std::to_string(host->second);
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down Expand Up @@ -82,7 +84,9 @@ std::string SpaceOptList::toString() const {
buf += item->toString();
buf += ",";
}
buf.resize(buf.size()-1);
if (!buf.empty()) {
buf.resize(buf.size()-1);
}
return buf;
}

Expand Down
8 changes: 6 additions & 2 deletions src/parser/Clauses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ std::string SourceNodeList::toString() const {
buf += std::to_string(id);
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down Expand Up @@ -80,7 +82,9 @@ std::string YieldColumns::toString() const {
}
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down
28 changes: 20 additions & 8 deletions src/parser/MaintainSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ std::string CreateTagSentence::toString() const {
buf += "CREATE TAG ";
buf += *name_;
buf += " (";
for (auto *col : columns_->columnSpecs()) {
auto colSpecs = std::move(columns_->columnSpecs());
for (auto *col : colSpecs) {
buf += *col->name();
buf += " ";
buf += columnTypeToString(col->type());
Expand All @@ -25,7 +26,9 @@ std::string CreateTagSentence::toString() const {
}
buf += ",";
}
buf.resize(buf.size() - 1);
if (!colSpecs.empty()) {
buf.resize(buf.size() - 1);
}
buf += ")";
return buf;
}
Expand All @@ -37,7 +40,8 @@ std::string CreateEdgeSentence::toString() const {
buf += "CREATE EDGE ";
buf += *name_;
buf += " (";
for (auto &col : columns_->columnSpecs()) {
auto colSpecs = std::move(columns_->columnSpecs());
for (auto &col : colSpecs) {
buf += *col->name();
buf += " ";
buf += columnTypeToString(col->type());
Expand All @@ -47,7 +51,9 @@ std::string CreateEdgeSentence::toString() const {
}
buf += ",";
}
buf.resize(buf.size() - 1);
if (!colSpecs.empty()) {
buf.resize(buf.size() - 1);
}
buf += ")";
return buf;
}
Expand All @@ -58,7 +64,8 @@ std::string AlterTagOptItem::toString() const {
buf.reserve(256);
buf += getOptTypeStr();
buf += " (";
for (auto &col : columns_->columnSpecs()) {
auto colSpecs = std::move(columns_->columnSpecs());
for (auto &col : colSpecs) {
buf += *col->name();
buf += " ";
buf += columnTypeToString(col->type());
Expand All @@ -68,7 +75,9 @@ std::string AlterTagOptItem::toString() const {
}
buf += ",";
}
buf.resize(buf.size() - 1);
if (!colSpecs.empty()) {
buf.resize(buf.size() - 1);
}
buf += ")";
return buf;
}
Expand Down Expand Up @@ -106,7 +115,8 @@ std::string AlterEdgeSentence::toString() const {
buf += "ALTER EDGE ";
buf += *name_;
buf += "(";
for (auto &col : columns_->columnSpecs()) {
auto colSpecs = std::move(columns_->columnSpecs());
for (auto &col : colSpecs) {
buf += *col->name();
buf += " ";
buf += columnTypeToString(col->type());
Expand All @@ -116,7 +126,9 @@ std::string AlterEdgeSentence::toString() const {
}
buf += ",";
}
buf.resize(buf.size() - 1);
if (!colSpecs.empty()) {
buf.resize(buf.size() - 1);
}
buf += ")";
return buf;
}
Expand Down
29 changes: 21 additions & 8 deletions src/parser/MutateSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ std::string PropertyList::toString() const {
buf += *prop;
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down Expand Up @@ -43,8 +45,9 @@ std::string VertexTagList::toString() const {
buf += item->toString();
buf += ",";
}
buf.resize(buf.size() - 1);

if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand All @@ -56,7 +59,9 @@ std::string ValueList::toString() const {
buf += expr->toString();
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand All @@ -80,7 +85,9 @@ std::string VertexRowList::toString() const {
buf += item->toString();
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down Expand Up @@ -123,7 +130,9 @@ std::string EdgeRowList::toString() const {
buf += item->toString();
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down Expand Up @@ -161,7 +170,9 @@ std::string UpdateList::toString() const {
buf += item->toString();
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down Expand Up @@ -236,7 +247,9 @@ std::string EdgeList::toString() const {
buf += std::to_string(edge.second);
buf += ",";
}
buf.resize(buf.size() - 1);
if (!buf.empty()) {
buf.resize(buf.size() - 1);
}
return buf;
}

Expand Down