Skip to content

Commit

Permalink
clang format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee authored and mergify[bot] committed Dec 1, 2022
1 parent 7d10399 commit f782cb2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 44 deletions.
81 changes: 39 additions & 42 deletions storage/tianmu/common/common_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,52 +73,49 @@ enum class ColumnType : unsigned char {
UNK = 255
};

#define MYSQL_ENUM_FIELD_TYPE \
DISPOSE(MYSQL_TYPE_DECIMAL, "decimal") \
DISPOSE(MYSQL_TYPE_TINY, "tiny") \
DISPOSE(MYSQL_TYPE_SHORT, "short") \
DISPOSE(MYSQL_TYPE_LONG, "long") \
DISPOSE(MYSQL_TYPE_FLOAT, "float") \
DISPOSE(MYSQL_TYPE_DOUBLE, "double") \
DISPOSE(MYSQL_TYPE_NULL, "null") \
DISPOSE(MYSQL_TYPE_TIMESTAMP, "timestamp") \
DISPOSE(MYSQL_TYPE_LONGLONG, "longlong") \
DISPOSE(MYSQL_TYPE_INT24, "int24") \
DISPOSE(MYSQL_TYPE_DATE, "date") \
DISPOSE(MYSQL_TYPE_TIME, "time") \
DISPOSE(MYSQL_TYPE_DATETIME, "datetime") \
DISPOSE(MYSQL_TYPE_YEAR, "year") \
DISPOSE(MYSQL_TYPE_NEWDATE, "newdate") \
DISPOSE(MYSQL_TYPE_VARCHAR, "varchar") \
DISPOSE(MYSQL_TYPE_BIT, "bit") \
DISPOSE(MYSQL_TYPE_TIMESTAMP2, "timestamp2") \
DISPOSE(MYSQL_TYPE_DATETIME2, "datetime2") \
DISPOSE(MYSQL_TYPE_TIME2, "time2") \
DISPOSE(MYSQL_TYPE_JSON, "json") \
DISPOSE(MYSQL_TYPE_NEWDECIMAL, "newdecimal") \
DISPOSE(MYSQL_TYPE_ENUM, "enum") \
DISPOSE(MYSQL_TYPE_SET, "set") \
DISPOSE(MYSQL_TYPE_TINY_BLOB, "tiny_blob") \
DISPOSE(MYSQL_TYPE_MEDIUM_BLOB, "medium_blob") \
DISPOSE(MYSQL_TYPE_LONG_BLOB, "long_blob") \
DISPOSE(MYSQL_TYPE_BLOB, "blob") \
DISPOSE(MYSQL_TYPE_VAR_STRING, "var_string") \
DISPOSE(MYSQL_TYPE_STRING, "string") \
DISPOSE(MYSQL_TYPE_GEOMETRY, "geometry")
#define MYSQL_ENUM_FIELD_TYPE \
DISPOSE(MYSQL_TYPE_DECIMAL, "decimal") \
DISPOSE(MYSQL_TYPE_TINY, "tiny") \
DISPOSE(MYSQL_TYPE_SHORT, "short") \
DISPOSE(MYSQL_TYPE_LONG, "long") \
DISPOSE(MYSQL_TYPE_FLOAT, "float") \
DISPOSE(MYSQL_TYPE_DOUBLE, "double") \
DISPOSE(MYSQL_TYPE_NULL, "null") \
DISPOSE(MYSQL_TYPE_TIMESTAMP, "timestamp") \
DISPOSE(MYSQL_TYPE_LONGLONG, "longlong") \
DISPOSE(MYSQL_TYPE_INT24, "int24") \
DISPOSE(MYSQL_TYPE_DATE, "date") \
DISPOSE(MYSQL_TYPE_TIME, "time") \
DISPOSE(MYSQL_TYPE_DATETIME, "datetime") \
DISPOSE(MYSQL_TYPE_YEAR, "year") \
DISPOSE(MYSQL_TYPE_NEWDATE, "newdate") \
DISPOSE(MYSQL_TYPE_VARCHAR, "varchar") \
DISPOSE(MYSQL_TYPE_BIT, "bit") \
DISPOSE(MYSQL_TYPE_TIMESTAMP2, "timestamp2") \
DISPOSE(MYSQL_TYPE_DATETIME2, "datetime2") \
DISPOSE(MYSQL_TYPE_TIME2, "time2") \
DISPOSE(MYSQL_TYPE_JSON, "json") \
DISPOSE(MYSQL_TYPE_NEWDECIMAL, "newdecimal") \
DISPOSE(MYSQL_TYPE_ENUM, "enum") \
DISPOSE(MYSQL_TYPE_SET, "set") \
DISPOSE(MYSQL_TYPE_TINY_BLOB, "tiny_blob") \
DISPOSE(MYSQL_TYPE_MEDIUM_BLOB, "medium_blob") \
DISPOSE(MYSQL_TYPE_LONG_BLOB, "long_blob") \
DISPOSE(MYSQL_TYPE_BLOB, "blob") \
DISPOSE(MYSQL_TYPE_VAR_STRING, "var_string") \
DISPOSE(MYSQL_TYPE_STRING, "string") \
DISPOSE(MYSQL_TYPE_GEOMETRY, "geometry")

#define DISPOSE(mark, name) {mark, name},
constexpr std::pair<int, const char*> enum_field_types_name[] =
{
MYSQL_ENUM_FIELD_TYPE
};
constexpr std::pair<int, const char *> enum_field_types_name[] = {MYSQL_ENUM_FIELD_TYPE};
#undef DISPOSE

constexpr const char* get_enum_field_types_name(int type) {
for (auto type_name : enum_field_types_name) {
if (type_name.first == type)
return type_name.second;
}
return "unkonwn type";
constexpr const char *get_enum_field_types_name(int type) {
for (auto type_name : enum_field_types_name) {
if (type_name.first == type)
return type_name.second;
}
return "unkonwn type";
}

enum class PackType { INT, STR };
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@ AttributeTypeInfo Engine::GetAttrTypeInfo(const Field &field) {
}
[[fallthrough]];
default:
throw common::UnsupportedDataTypeException(
std::string("Unsupported data type[") + common::get_enum_field_types_name(field.type()) + std::string("]"));
throw common::UnsupportedDataTypeException(std::string("Unsupported data type[") +
common::get_enum_field_types_name(field.type()) + std::string("]"));
}
throw;
}
Expand Down

0 comments on commit f782cb2

Please sign in to comment.