Better command builder format output like ts3 expects it
This commit is contained in:
parent
d13c1e6d68
commit
4aec154ff1
|
@ -143,7 +143,7 @@ namespace ts {
|
||||||
return command_builder_impl<std::vector<std::string>>{this->expected_bulk_size, this->_identifier, this->bulks.begin(), this->bulks.end()};
|
return command_builder_impl<std::vector<std::string>>{this->expected_bulk_size, this->_identifier, this->bulks.begin(), this->bulks.end()};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string build() const {
|
inline std::string build(bool with_empty = false) const {
|
||||||
if(this->builded.has_value())
|
if(this->builded.has_value())
|
||||||
return this->builded.value();
|
return this->builded.value();
|
||||||
|
|
||||||
|
@ -154,13 +154,17 @@ namespace ts {
|
||||||
|
|
||||||
result.append(this->_identifier);
|
result.append(this->_identifier);
|
||||||
for(auto it = this->bulks.begin(); it != this->bulks.end(); it++) {
|
for(auto it = this->bulks.begin(); it != this->bulks.end(); it++) {
|
||||||
result.append(*it);
|
if(it->empty() && !with_empty) continue;
|
||||||
|
|
||||||
|
result.append(*it, 0, it->length() - 1);
|
||||||
if(it + 1 != this->bulks.end())
|
if(it + 1 != this->bulks.end())
|
||||||
result.append("|");
|
result.append("|");
|
||||||
}
|
}
|
||||||
|
if(!with_empty && result.ends_with('|'))
|
||||||
|
this->builded = result.substr(0, result.length() - 1);
|
||||||
|
else
|
||||||
this->builded = result;
|
this->builded = result;
|
||||||
return result;
|
return this->builded.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void reserve_bulks(size_t count) { this->bulks.reserve(count); }
|
inline void reserve_bulks(size_t count) { this->bulks.reserve(count); }
|
||||||
|
@ -217,8 +221,10 @@ namespace ts {
|
||||||
|
|
||||||
data.reserve(data.length() + key.size() + escaped_value.size() + 2);
|
data.reserve(data.length() + key.size() + escaped_value.size() + 2);
|
||||||
data.append(key);
|
data.append(key);
|
||||||
|
if(!escaped_value.empty()) {
|
||||||
data.append("=");
|
data.append("=");
|
||||||
data.append(escaped_value);
|
data.append(escaped_value);
|
||||||
|
}
|
||||||
data.append(" ");
|
data.append(" ");
|
||||||
|
|
||||||
this->builded.reset();
|
this->builded.reset();
|
||||||
|
|
Loading…
Reference in New Issue