diff --git a/drogon_ctl/templates/model_cc.csp b/drogon_ctl/templates/model_cc.csp index df4ff729..4c32ed8f 100644 --- a/drogon_ctl/templates/model_cc.csp +++ b/drogon_ctl/templates/model_cc.csp @@ -37,7 +37,7 @@ for(size_t i=0;i}; <%c++}%> -<%c++ if(@@.get("hasPrimaryKey",0)>0){%> +<%c++ if(@@.get("hasPrimaryKey")>0){%> const bool [[className]]::hasPrimaryKey = true; <%c++ }else{%> const bool [[className]]::hasPrimaryKey = false; @@ -128,16 +128,18 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false) auto & col = cols[i]; if(!col._colType.empty()) { - $$<<"const "<") { - $$<<"std::string "<data(),_"<size());\n"; $$<<" return defaultValue;\n"; diff --git a/drogon_ctl/templates/model_h.csp b/drogon_ctl/templates/model_h.csp index 416b4e29..6ce00661 100644 --- a/drogon_ctl/templates/model_h.csp +++ b/drogon_ctl/templates/model_h.csp @@ -88,11 +88,11 @@ auto cols=@@.get>("columns"); if(!col._colType.empty()) { $$<<" ///Get the value of the column "<") { $$<<" ///Return the column value by std::string with binary data\n"; - $$<<" std::string getValueOf"< get"< &headers() @@ -160,9 +154,7 @@ class HttpRequest } /// Get a parameter identified by the @param key - virtual const std::string &getParameter( - const std::string &key, - const std::string &defaultVal = std::string()) const = 0; + virtual const std::string &getParameter(const std::string &key) const = 0; /// Return the remote IP address and port virtual const trantor::InetAddress &peerAddr() const = 0; diff --git a/lib/inc/drogon/HttpResponse.h b/lib/inc/drogon/HttpResponse.h index 44eb1dd8..e2e62675 100644 --- a/lib/inc/drogon/HttpResponse.h +++ b/lib/inc/drogon/HttpResponse.h @@ -100,14 +100,10 @@ class HttpResponse } /// Get the header string identified by the @param key. - /// If there is no the header, the @param defaultVal is retured. + /// If there is no the header, a empty string is retured. /// The @param key is case insensitive - virtual const std::string &getHeader( - const std::string &key, - const std::string &defaultVal = std::string()) const = 0; - virtual const std::string &getHeader( - std::string &&key, - const std::string &defaultVal = std::string()) const = 0; + virtual const std::string &getHeader(const std::string &key) const = 0; + virtual const std::string &getHeader(std::string &&key) const = 0; /// Remove the header identified by the @param key. virtual void removeHeader(const std::string &key) = 0; diff --git a/lib/inc/drogon/HttpViewData.h b/lib/inc/drogon/HttpViewData.h index 641addf0..9994ce6c 100644 --- a/lib/inc/drogon/HttpViewData.h +++ b/lib/inc/drogon/HttpViewData.h @@ -33,8 +33,9 @@ class HttpViewData /// The function template is used to get an item in the data set by the /// @param key. template - const T &get(const std::string &key, T &&nullVal = T()) const + const T &get(const std::string &key) const { + const static T nullVal = T(); auto it = _viewData.find(key); if (it != _viewData.end()) { diff --git a/lib/inc/drogon/Session.h b/lib/inc/drogon/Session.h index 0539ac55..c96f17b4 100644 --- a/lib/inc/drogon/Session.h +++ b/lib/inc/drogon/Session.h @@ -26,8 +26,9 @@ class Session { public: template - const T &get(const std::string &key, T &&nullVal = T()) const + const T &get(const std::string &key) const { + const static T nullVal = T(); std::lock_guard lck(_mutex); auto it = _sessionMap.find(key); if (it != _sessionMap.end()) diff --git a/lib/src/HttpRequestImpl.h b/lib/src/HttpRequestImpl.h index 6d41561e..41973e38 100644 --- a/lib/src/HttpRequestImpl.h +++ b/lib/src/HttpRequestImpl.h @@ -95,9 +95,9 @@ class HttpRequestImpl : public HttpRequest } virtual const std::string &getParameter( - const std::string &key, - const std::string &defaultVal = std::string()) const override + const std::string &key) const override { + const static std::string defaultVal; parseParametersOnce(); auto iter = _parameters.find(key); if (iter != _parameters.end()) @@ -209,30 +209,25 @@ class HttpRequestImpl : public HttpRequest void addHeader(const char *start, const char *colon, const char *end); - const std::string &getHeader( - const std::string &field, - const std::string &defaultVal = std::string()) const override + const std::string &getHeader(const std::string &field) const override { auto lowField = field; std::transform(lowField.begin(), lowField.end(), lowField.begin(), tolower); - return getHeaderBy(lowField, defaultVal); + return getHeaderBy(lowField); } - const std::string &getHeader( - std::string &&field, - const std::string &defaultVal = std::string()) const override + const std::string &getHeader(std::string &&field) const override { std::transform(field.begin(), field.end(), field.begin(), tolower); - return getHeaderBy(field, defaultVal); + return getHeaderBy(field); } - const std::string &getHeaderBy( - const std::string &lowerField, - const std::string &defaultVal = std::string()) const + const std::string &getHeaderBy(const std::string &lowerField) const { + const static std::string defaultVal; auto it = _headers.find(lowerField); if (it != _headers.end()) { @@ -241,10 +236,9 @@ class HttpRequestImpl : public HttpRequest return defaultVal; } - const std::string &getCookie( - const std::string &field, - const std::string &defaultVal = std::string()) const override + const std::string &getCookie(const std::string &field) const override { + const static std::string defaultVal; auto it = _cookies.find(field); if (it != _cookies.end()) { diff --git a/lib/src/HttpResponseImpl.h b/lib/src/HttpResponseImpl.h index 7623a517..da76dbed 100644 --- a/lib/src/HttpResponseImpl.h +++ b/lib/src/HttpResponseImpl.h @@ -119,21 +119,17 @@ class HttpResponseImpl : public HttpResponse return _contentType; } - virtual const std::string &getHeader( - const std::string &key, - const std::string &defaultVal = std::string()) const override + virtual const std::string &getHeader(const std::string &key) const override { auto field = key; transform(field.begin(), field.end(), field.begin(), ::tolower); - return getHeaderBy(field, defaultVal); + return getHeaderBy(field); } - virtual const std::string &getHeader( - std::string &&key, - const std::string &defaultVal = std::string()) const override + virtual const std::string &getHeader(std::string &&key) const override { transform(key.begin(), key.end(), key.begin(), ::tolower); - return getHeaderBy(key, defaultVal); + return getHeaderBy(key); } virtual void removeHeader(const std::string &key) override @@ -155,10 +151,9 @@ class HttpResponseImpl : public HttpResponse return _headers; } - const std::string &getHeaderBy( - const std::string &lowerKey, - const std::string &defaultVal = std::string()) const + const std::string &getHeaderBy(const std::string &lowerKey) const { + const static std::string defaultVal; auto iter = _headers.find(lowerKey); if (iter == _headers.end()) { diff --git a/orm_lib/tests/Users.cc b/orm_lib/tests/Users.cc index fb3d60c3..d1e3bd26 100644 --- a/orm_lib/tests/Users.cc +++ b/orm_lib/tests/Users.cc @@ -25,17 +25,16 @@ const std::string Users::primaryKeyName = "id"; const bool Users::hasPrimaryKey = true; const std::string Users::tableName = "users"; -const std::vector Users::_metaData={ -{"user_id","std::string","character varying",32,0,0,0}, -{"user_name","std::string","character varying",64,0,0,0}, -{"password","std::string","character varying",64,0,0,0}, -{"org_name","std::string","character varying",20,0,0,0}, -{"signature","std::string","character varying",50,0,0,0}, -{"avatar_id","std::string","character varying",32,0,0,0}, -{"id","int32_t","integer",4,1,1,1}, -{"salt","std::string","character varying",20,0,0,0}, -{"admin","bool","boolean",1,0,0,0} -}; +const std::vector Users::_metaData = { + {"user_id", "std::string", "character varying", 32, 0, 0, 0}, + {"user_name", "std::string", "character varying", 64, 0, 0, 0}, + {"password", "std::string", "character varying", 64, 0, 0, 0}, + {"org_name", "std::string", "character varying", 20, 0, 0, 0}, + {"signature", "std::string", "character varying", 50, 0, 0, 0}, + {"avatar_id", "std::string", "character varying", 32, 0, 0, 0}, + {"id", "int32_t", "integer", 4, 1, 1, 1}, + {"salt", "std::string", "character varying", 20, 0, 0, 0}, + {"admin", "bool", "boolean", 1, 0, 0, 0}}; const std::string &Users::getColumnName(size_t index) noexcept(false) { assert(index < _metaData.size()); @@ -43,46 +42,52 @@ const std::string &Users::getColumnName(size_t index) noexcept(false) } Users::Users(const Row &r) noexcept { - if(!r["user_id"].isNull()) - { - _userId=std::make_shared(r["user_id"].as()); - } - if(!r["user_name"].isNull()) - { - _userName=std::make_shared(r["user_name"].as()); - } - if(!r["password"].isNull()) - { - _password=std::make_shared(r["password"].as()); - } - if(!r["org_name"].isNull()) - { - _orgName=std::make_shared(r["org_name"].as()); - } - if(!r["signature"].isNull()) - { - _signature=std::make_shared(r["signature"].as()); - } - if(!r["avatar_id"].isNull()) - { - _avatarId=std::make_shared(r["avatar_id"].as()); - } - if(!r["id"].isNull()) - { - _id=std::make_shared(r["id"].as()); - } - if(!r["salt"].isNull()) - { - _salt=std::make_shared(r["salt"].as()); - } - if(!r["admin"].isNull()) - { - _admin=std::make_shared(r["admin"].as()); - } + if (!r["user_id"].isNull()) + { + _userId = std::make_shared(r["user_id"].as()); + } + if (!r["user_name"].isNull()) + { + _userName = + std::make_shared(r["user_name"].as()); + } + if (!r["password"].isNull()) + { + _password = + std::make_shared(r["password"].as()); + } + if (!r["org_name"].isNull()) + { + _orgName = + std::make_shared(r["org_name"].as()); + } + if (!r["signature"].isNull()) + { + _signature = + std::make_shared(r["signature"].as()); + } + if (!r["avatar_id"].isNull()) + { + _avatarId = + std::make_shared(r["avatar_id"].as()); + } + if (!r["id"].isNull()) + { + _id = std::make_shared(r["id"].as()); + } + if (!r["salt"].isNull()) + { + _salt = std::make_shared(r["salt"].as()); + } + if (!r["admin"].isNull()) + { + _admin = std::make_shared(r["admin"].as()); + } } -const std::string &Users::getValueOfUserId(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfUserId() const noexcept { - if(_userId) + const static std::string defaultValue = std::string(); + if (_userId) return *_userId; return defaultValue; } @@ -101,10 +106,10 @@ void Users::setUserId(std::string &&userId) noexcept _dirtyFlag[0] = true; } - -const std::string &Users::getValueOfUserName(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfUserName() const noexcept { - if(_userName) + const static std::string defaultValue = std::string(); + if (_userName) return *_userName; return defaultValue; } @@ -123,10 +128,10 @@ void Users::setUserName(std::string &&userName) noexcept _dirtyFlag[1] = true; } - -const std::string &Users::getValueOfPassword(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfPassword() const noexcept { - if(_password) + const static std::string defaultValue = std::string(); + if (_password) return *_password; return defaultValue; } @@ -145,10 +150,10 @@ void Users::setPassword(std::string &&password) noexcept _dirtyFlag[2] = true; } - -const std::string &Users::getValueOfOrgName(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfOrgName() const noexcept { - if(_orgName) + const static std::string defaultValue = std::string(); + if (_orgName) return *_orgName; return defaultValue; } @@ -167,10 +172,10 @@ void Users::setOrgName(std::string &&orgName) noexcept _dirtyFlag[3] = true; } - -const std::string &Users::getValueOfSignature(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfSignature() const noexcept { - if(_signature) + const static std::string defaultValue = std::string(); + if (_signature) return *_signature; return defaultValue; } @@ -189,10 +194,10 @@ void Users::setSignature(std::string &&signature) noexcept _dirtyFlag[4] = true; } - -const std::string &Users::getValueOfAvatarId(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfAvatarId() const noexcept { - if(_avatarId) + const static std::string defaultValue = std::string(); + if (_avatarId) return *_avatarId; return defaultValue; } @@ -211,10 +216,10 @@ void Users::setAvatarId(std::string &&avatarId) noexcept _dirtyFlag[5] = true; } - -const int32_t &Users::getValueOfId(const int32_t &defaultValue) const noexcept +const int32_t &Users::getValueOfId() const noexcept { - if(_id) + const static int32_t defaultValue = int32_t(); + if (_id) return *_id; return defaultValue; } @@ -222,15 +227,16 @@ std::shared_ptr Users::getId() const noexcept { return _id; } -const typename Users::PrimaryKeyType & Users::getPrimaryKey() const +const typename Users::PrimaryKeyType &Users::getPrimaryKey() const { assert(_id); return *_id; } -const std::string &Users::getValueOfSalt(const std::string &defaultValue) const noexcept +const std::string &Users::getValueOfSalt() const noexcept { - if(_salt) + const static std::string defaultValue = std::string(); + if (_salt) return *_salt; return defaultValue; } @@ -249,10 +255,10 @@ void Users::setSalt(std::string &&salt) noexcept _dirtyFlag[7] = true; } - -const bool &Users::getValueOfAdmin(const bool &defaultValue) const noexcept +const bool &Users::getValueOfAdmin() const noexcept { - if(_admin) + const static bool defaultValue = bool(); + if (_admin) return *_admin; return defaultValue; } @@ -266,29 +272,26 @@ void Users::setAdmin(const bool &admin) noexcept _dirtyFlag[8] = true; } - void Users::updateId(const uint64_t id) { } const std::vector &Users::insertColumns() noexcept { - static const std::vector _inCols={ - "user_id", - "user_name", - "password", - "org_name", - "signature", - "avatar_id", - "salt", - "admin" - }; + static const std::vector _inCols = {"user_id", + "user_name", + "password", + "org_name", + "signature", + "avatar_id", + "salt", + "admin"}; return _inCols; } void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { - if(getUserId()) + if (getUserId()) { binder << getValueOfUserId(); } @@ -296,7 +299,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getUserName()) + if (getUserName()) { binder << getValueOfUserName(); } @@ -304,7 +307,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getPassword()) + if (getPassword()) { binder << getValueOfPassword(); } @@ -312,7 +315,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getOrgName()) + if (getOrgName()) { binder << getValueOfOrgName(); } @@ -320,7 +323,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getSignature()) + if (getSignature()) { binder << getValueOfSignature(); } @@ -328,7 +331,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getAvatarId()) + if (getAvatarId()) { binder << getValueOfAvatarId(); } @@ -336,7 +339,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getSalt()) + if (getSalt()) { binder << getValueOfSalt(); } @@ -344,7 +347,7 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const { binder << nullptr; } - if(getAdmin()) + if (getAdmin()) { binder << getValueOfAdmin(); } @@ -357,9 +360,9 @@ void Users::outputArgs(drogon::orm::internal::SqlBinder &binder) const const std::vector Users::updateColumns() const { std::vector ret; - for(size_t i=0;i Users::updateColumns() const void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const { - if(_dirtyFlag[0]) + if (_dirtyFlag[0]) { - if(getUserId()) + if (getUserId()) { binder << getValueOfUserId(); } @@ -380,9 +383,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[1]) + if (_dirtyFlag[1]) { - if(getUserName()) + if (getUserName()) { binder << getValueOfUserName(); } @@ -391,9 +394,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[2]) + if (_dirtyFlag[2]) { - if(getPassword()) + if (getPassword()) { binder << getValueOfPassword(); } @@ -402,9 +405,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[3]) + if (_dirtyFlag[3]) { - if(getOrgName()) + if (getOrgName()) { binder << getValueOfOrgName(); } @@ -413,9 +416,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[4]) + if (_dirtyFlag[4]) { - if(getSignature()) + if (getSignature()) { binder << getValueOfSignature(); } @@ -424,9 +427,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[5]) + if (_dirtyFlag[5]) { - if(getAvatarId()) + if (getAvatarId()) { binder << getValueOfAvatarId(); } @@ -435,9 +438,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[7]) + if (_dirtyFlag[7]) { - if(getSalt()) + if (getSalt()) { binder << getValueOfSalt(); } @@ -446,9 +449,9 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const binder << nullptr; } } - if(_dirtyFlag[8]) + if (_dirtyFlag[8]) { - if(getAdmin()) + if (getAdmin()) { binder << getValueOfAdmin(); } @@ -461,77 +464,77 @@ void Users::updateArgs(drogon::orm::internal::SqlBinder &binder) const Json::Value Users::toJson() const { Json::Value ret; - if(getUserId()) + if (getUserId()) { - ret["user_id"]=getValueOfUserId(); + ret["user_id"] = getValueOfUserId(); } else { - ret["user_id"]=Json::Value(); + ret["user_id"] = Json::Value(); } - if(getUserName()) + if (getUserName()) { - ret["user_name"]=getValueOfUserName(); + ret["user_name"] = getValueOfUserName(); } else { - ret["user_name"]=Json::Value(); + ret["user_name"] = Json::Value(); } - if(getPassword()) + if (getPassword()) { - ret["password"]=getValueOfPassword(); + ret["password"] = getValueOfPassword(); } else { - ret["password"]=Json::Value(); + ret["password"] = Json::Value(); } - if(getOrgName()) + if (getOrgName()) { - ret["org_name"]=getValueOfOrgName(); + ret["org_name"] = getValueOfOrgName(); } else { - ret["org_name"]=Json::Value(); + ret["org_name"] = Json::Value(); } - if(getSignature()) + if (getSignature()) { - ret["signature"]=getValueOfSignature(); + ret["signature"] = getValueOfSignature(); } else { - ret["signature"]=Json::Value(); + ret["signature"] = Json::Value(); } - if(getAvatarId()) + if (getAvatarId()) { - ret["avatar_id"]=getValueOfAvatarId(); + ret["avatar_id"] = getValueOfAvatarId(); } else { - ret["avatar_id"]=Json::Value(); + ret["avatar_id"] = Json::Value(); } - if(getId()) + if (getId()) { - ret["id"]=getValueOfId(); + ret["id"] = getValueOfId(); } else { - ret["id"]=Json::Value(); + ret["id"] = Json::Value(); } - if(getSalt()) + if (getSalt()) { - ret["salt"]=getValueOfSalt(); + ret["salt"] = getValueOfSalt(); } else { - ret["salt"]=Json::Value(); + ret["salt"] = Json::Value(); } - if(getAdmin()) + if (getAdmin()) { - ret["admin"]=getValueOfAdmin(); + ret["admin"] = getValueOfAdmin(); } else { - ret["admin"]=Json::Value(); + ret["admin"] = Json::Value(); } return ret; } diff --git a/orm_lib/tests/Users.h b/orm_lib/tests/Users.h index 0395c002..9dfdb280 100644 --- a/orm_lib/tests/Users.h +++ b/orm_lib/tests/Users.h @@ -24,9 +24,8 @@ using namespace drogon::orm; namespace drogon_model { -namespace postgres +namespace postgres { - class Users { public: @@ -51,86 +50,106 @@ class Users const PrimaryKeyType &getPrimaryKey() const; explicit Users(const Row &r) noexcept; Users() = default; - + /** For column user_id */ - ///Get the value of the column user_id, returns the default value if the column is null - const std::string &getValueOfUserId(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column user_id, returns the default value if the + /// column is null + const std::string &getValueOfUserId() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getUserId() const noexcept; - ///Set the value of the column user_id + /// Set the value of the column user_id void setUserId(const std::string &userId) noexcept; void setUserId(std::string &&userId) noexcept; /** For column user_name */ - ///Get the value of the column user_name, returns the default value if the column is null - const std::string &getValueOfUserName(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column user_name, returns the default value if the + /// column is null + const std::string &getValueOfUserName() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getUserName() const noexcept; - ///Set the value of the column user_name + /// Set the value of the column user_name void setUserName(const std::string &userName) noexcept; void setUserName(std::string &&userName) noexcept; /** For column password */ - ///Get the value of the column password, returns the default value if the column is null - const std::string &getValueOfPassword(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column password, returns the default value if the + /// column is null + const std::string &getValueOfPassword() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getPassword() const noexcept; - ///Set the value of the column password + /// Set the value of the column password void setPassword(const std::string &password) noexcept; void setPassword(std::string &&password) noexcept; /** For column org_name */ - ///Get the value of the column org_name, returns the default value if the column is null - const std::string &getValueOfOrgName(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column org_name, returns the default value if the + /// column is null + const std::string &getValueOfOrgName() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getOrgName() const noexcept; - ///Set the value of the column org_name + /// Set the value of the column org_name void setOrgName(const std::string &orgName) noexcept; void setOrgName(std::string &&orgName) noexcept; /** For column signature */ - ///Get the value of the column signature, returns the default value if the column is null - const std::string &getValueOfSignature(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column signature, returns the default value if the + /// column is null + const std::string &getValueOfSignature() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getSignature() const noexcept; - ///Set the value of the column signature + /// Set the value of the column signature void setSignature(const std::string &signature) noexcept; void setSignature(std::string &&signature) noexcept; /** For column avatar_id */ - ///Get the value of the column avatar_id, returns the default value if the column is null - const std::string &getValueOfAvatarId(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column avatar_id, returns the default value if the + /// column is null + const std::string &getValueOfAvatarId() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getAvatarId() const noexcept; - ///Set the value of the column avatar_id + /// Set the value of the column avatar_id void setAvatarId(const std::string &avatarId) noexcept; void setAvatarId(std::string &&avatarId) noexcept; /** For column id */ - ///Get the value of the column id, returns the default value if the column is null - const int32_t &getValueOfId(const int32_t &defaultValue=int32_t()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column id, returns the default value if the column + /// is null + const int32_t &getValueOfId() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getId() const noexcept; /** For column salt */ - ///Get the value of the column salt, returns the default value if the column is null - const std::string &getValueOfSalt(const std::string &defaultValue=std::string()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column salt, returns the default value if the + /// column is null + const std::string &getValueOfSalt() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getSalt() const noexcept; - ///Set the value of the column salt + /// Set the value of the column salt void setSalt(const std::string &salt) noexcept; void setSalt(std::string &&salt) noexcept; /** For column admin */ - ///Get the value of the column admin, returns the default value if the column is null - const bool &getValueOfAdmin(const bool &defaultValue=bool()) const noexcept; - ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null + /// Get the value of the column admin, returns the default value if the + /// column is null + const bool &getValueOfAdmin() const noexcept; + /// Return a shared_ptr object pointing to the column const value, or an + /// empty shared_ptr object if the column is null std::shared_ptr getAdmin() const noexcept; - ///Set the value of the column admin + /// Set the value of the column admin void setAdmin(const bool &admin) noexcept; - - static size_t getColumnNumber() noexcept { return 9; } + static size_t getColumnNumber() noexcept + { + return 9; + } static const std::string &getColumnName(size_t index) noexcept(false); Json::Value toJson() const; @@ -141,7 +160,7 @@ class Users void outputArgs(drogon::orm::internal::SqlBinder &binder) const; const std::vector updateColumns() const; void updateArgs(drogon::orm::internal::SqlBinder &binder) const; - ///For mysql or sqlite3 + /// For mysql or sqlite3 void updateId(const uint64_t id); std::shared_ptr _userId; std::shared_ptr _userName; @@ -163,8 +182,8 @@ class Users const bool _notNull; }; static const std::vector _metaData; - bool _dirtyFlag[9]={ false }; + bool _dirtyFlag[9] = {false}; }; -} // namespace postgres -} // namespace drogon_model +} // namespace postgres +} // namespace drogon_model