Fix converting between optional string and char

This commit is contained in:
Lixia Chen 2021-03-12 09:19:52 -05:00
parent 9add98350e
commit 72da42a3a6
1 changed files with 4 additions and 2 deletions

View File

@ -32,13 +32,15 @@ inline std::vector<char> StringToChar(const std::string &s) { return std::vector
inline std::string CharToString(const std::vector<char> &c) { return std::string(c.begin(), c.end()); }
inline std::optional<std::vector<char>> OptionalStringToChar(const std::optional<std::string> &s) {
if (s == std::nullopt) return std::nullopt;
std::optional<std::vector<char>> ret = std::vector<char>(s->begin(), s->end());
return (s == std::nullopt) ? std::nullopt : ret;
return ret;
}
inline std::optional<std::string> OptionalCharToString(const std::optional<std::vector<char>> &c) {
if (c == std::nullopt) return std::nullopt;
std::optional<std::string> ret = std::string(c->begin(), c->end());
return (c == std::nullopt) ? std::nullopt : ret;
return ret;
}
inline std::pair<std::vector<char>, int32_t> PairStringToChar(const std::pair<std::string, int32_t> &s) {