Remove non standard macros (#415)

This commit is contained in:
An Tao 2020-04-25 02:12:44 +08:00 committed by GitHub
parent 269acbc477
commit 4f8290b589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 35 deletions

View File

@ -237,7 +237,9 @@ void create_model::createModelClassFromPG(
INNER JOIN pg_type ON pg_type.oid = pg_attribute.atttypid \
WHERE pg_class.relname = $1 and pg_constraint.contype='p'"
<< tableName << Mode::Blocking >>
[&](bool isNull, std::string colName, const std::string &type) {
[&](bool isNull,
const std::string &colName,
const std::string &type) {
if (isNull)
return;

View File

@ -80,8 +80,8 @@ class PivotTable
public:
PivotTable() = default;
PivotTable(const Json::Value &json)
: tableName_(json.get("table_name", "").asString())
{
tableName_ = json.get("table_name", "").asString();
if (tableName_.empty())
{
throw std::runtime_error("table_name can't be empty");

View File

@ -28,26 +28,12 @@
#define METHOD_LIST_BEGIN \
static void initPathRouting() \
{
#ifndef _MSC_VER
#define METHOD_ADD(method, pattern, filters...) \
registerMethod(&method, pattern, {filters}, true, #method)
#define ADD_METHOD_TO(method, path_pattern, filters...) \
registerMethod(&method, path_pattern, {filters}, false, #method)
#define ADD_METHOD_VIA_REGEX(method, regex, filters...) \
registerMethodViaRegex(&method, regex, {filters}, #method)
#else
#define METHOD_ADD(method, pattern, ...) \
registerMethod(&method, pattern, {##__VA_ARGS__}, true, #method)
registerMethod(&method, pattern, {__VA_ARGS__}, true, #method)
#define ADD_METHOD_TO(method, path_pattern, ...) \
registerMethod(&method, path_pattern, {##__VA_ARGS__}, false, #method)
registerMethod(&method, path_pattern, {__VA_ARGS__}, false, #method)
#define ADD_METHOD_VIA_REGEX(method, regex, ...) \
registerMethodViaRegex(&method, regex, {##__VA_ARGS__}, #method)
#endif
registerMethodViaRegex(&method, regex, {__VA_ARGS__}, #method)
#define METHOD_LIST_END \
return; \
}

View File

@ -24,12 +24,7 @@
#define PATH_LIST_BEGIN \
static void initPathRouting() \
{
#ifndef _MSC_VER
#define PATH_ADD(path, filters...) registerSelf__(path, {filters});
#else
#define PATH_ADD(path, ...) registerSelf__(path, {##__VA_ARGS__});
#endif
#define PATH_ADD(path, ...) registerSelf__(path, {__VA_ARGS__});
#define PATH_LIST_END }
namespace drogon
{

View File

@ -27,12 +27,7 @@
#define WS_PATH_LIST_BEGIN \
static void initPathRouting() \
{
#ifndef _MSC_VER
#define WS_PATH_ADD(path, filters...) registerSelf__(path, {filters});
#else
#define WS_PATH_ADD(path, ...) registerSelf__(path, {##__VA_ARGS__});
#endif
#define WS_PATH_ADD(path, ...) registerSelf__(path, {__VA_ARGS__});
#define WS_PATH_LIST_END }
namespace drogon

View File

@ -95,7 +95,7 @@ int main()
for (int i = 0; i < 100; ++i)
mapper.findByPrimaryKey(
2,
[](User u) { std::cout << "get a user by pk" << std::endl; },
[](const User &u) { std::cout << "get a user by pk" << std::endl; },
[](const DrogonDbException &e) { throw std::exception(); });
getchar();
}

View File

@ -163,7 +163,7 @@ void doPostgreTest(const drogon::orm::DbClientPtr &clientPtr)
<< Mode::Blocking >>
[&count](bool isNull,
const std::string &name,
std::string user_id,
std::string &&user_id,
int id) {
if (!isNull)
++count;
@ -793,7 +793,7 @@ void doMysqlTest(const drogon::orm::DbClientPtr &clientPtr)
<< Mode::Blocking >>
[&count](bool isNull,
const std::string &name,
std::string user_id,
std::string &&user_id,
int id) {
if (!isNull)
++count;
@ -1381,7 +1381,7 @@ void doSqliteTest(const drogon::orm::DbClientPtr &clientPtr)
<< Mode::Blocking >>
[&count](bool isNull,
const std::string &name,
std::string user_id,
std::string &&user_id,
int id) {
if (!isNull)
++count;