28 #include "graphar/result.h"
36 static Result<std::shared_ptr<const InfoVersion>>
Parse(
37 const std::string& str) noexcept;
43 if (version2types.find(
version) == version2types.end()) {
44 throw std::invalid_argument(
"Unsupported version: " +
52 if (version2types.find(
version) == version2types.end()) {
53 throw std::invalid_argument(
"Unsupported version: " +
64 return version_ == other.version_ &&
65 user_define_types_ == other.user_define_types_;
73 return user_define_types_;
78 std::string str =
"gar/v" + std::to_string(version_);
79 if (!user_define_types_.empty()) {
81 for (
auto& type : user_define_types_) {
90 inline bool CheckType(
const std::string& type_str)
const {
91 auto& types = version2types.at(version_);
93 if (std::find(types.begin(), types.end(), type_str) != types.end()) {
97 if (std::find(user_define_types_.begin(), user_define_types_.end(),
98 type_str) != user_define_types_.end()) {
105 inline static const std::map<int, std::vector<std::string>> version2types{
106 {1, {
"bool",
"int32",
"int64",
"float",
"double",
"string"}},
109 std::vector<std::string> user_define_types_;
InfoVersion(const InfoVersion &other)=default
InfoVersion(int version, const std::vector< std::string > &user_define_types)
InfoVersion & operator=(const InfoVersion &other)=default
std::string ToString() const
static Result< std::shared_ptr< const InfoVersion > > Parse(const std::string &str) noexcept
const std::vector< std::string > & user_define_types() const
bool operator==(const InfoVersion &other) const
bool CheckType(const std::string &type_str) const