Fix bugs in default return values of functions (#220)

This commit is contained in:
An Tao 2019-08-22 22:23:50 +08:00 committed by GitHub
parent db99ef84ee
commit b5a142a10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 237 additions and 234 deletions

View File

@ -37,7 +37,7 @@ for(size_t i=0;i<pkName.size();i++)
}
%>};
<%c++}%>
<%c++ if(@@.get<int>("hasPrimaryKey",0)>0){%>
<%c++ if(@@.get<int>("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 "<<col._colType<<" &"<<className<<"::getValueOf"<<col._colTypeName<<"(const "<<col._colType<<" &defaultValue) const noexcept\n";
$$<<"const "<<col._colType<<" &"<<className<<"::getValueOf"<<col._colTypeName<<"() const noexcept\n";
$$<<"{\n";
$$<<" const static "<<col._colType<<" defaultValue = "<<col._colType<<"();\n";
$$<<" if(_"<<col._colValName<<")\n";
$$<<" return *_"<<col._colValName<<";\n";
$$<<" return defaultValue;\n";
$$<<"}\n";
if(col._colType=="std::vector<char>")
{
$$<<"std::string "<<className<<"::getValueOf"<<col._colTypeName<<"AsString(const std::string &defaultValue) const noexcept\n";
$$<<"std::string "<<className<<"::getValueOf"<<col._colTypeName<<"AsString() const noexcept\n";
$$<<"{\n";
$$<<" const static std::string defaultValue = std::string();\n";
$$<<" if(_"<<col._colValName<<")\n";
$$<<" return std::string(_"<<col._colValName<<"->data(),_"<<col._colValName<<"->size());\n";
$$<<" return defaultValue;\n";

View File

@ -88,11 +88,11 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
if(!col._colType.empty())
{
$$<<" ///Get the value of the column "<<col._colName<<", returns the default value if the column is null\n";
$$<<" const "<<col._colType<<" &getValueOf"<<col._colTypeName<<"(const "<<col._colType<<" &defaultValue="<<col._colType<<"()) const noexcept;\n";
$$<<" const "<<col._colType<<" &getValueOf"<<col._colTypeName<<"() const noexcept;\n";
if(col._colType=="std::vector<char>")
{
$$<<" ///Return the column value by std::string with binary data\n";
$$<<" std::string getValueOf"<<col._colTypeName<<"AsString(const std::string &defaultValue=\"\") const noexcept;\n";
$$<<" std::string getValueOf"<<col._colTypeName<<"AsString() const noexcept;\n";
}
$$<<" ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null\n";
$$<<" std::shared_ptr<const "<<col._colType<<"> get"<<col._colTypeName<<"() const noexcept;\n";

View File

@ -55,21 +55,15 @@ class HttpRequest
}
/// Get the header string identified by the @param field
virtual const std::string &getHeader(
const std::string &field,
const std::string &defaultVal = std::string()) const = 0;
virtual const std::string &getHeader(
std::string &&field,
const std::string &defaultVal = std::string()) const = 0;
virtual const std::string &getHeader(const std::string &field) const = 0;
virtual const std::string &getHeader(std::string &&field) const = 0;
/// Set the header string identified by the @param field
virtual void addHeader(const std::string &field,
const std::string &value) = 0;
/// Get the cookie string identified by the @param field
virtual const std::string &getCookie(
const std::string &field,
const std::string &defaultVal = std::string()) const = 0;
virtual const std::string &getCookie(const std::string &field) const = 0;
/// Get all headers of the request
virtual const std::unordered_map<std::string, std::string> &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;

View File

@ -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;

View File

@ -33,8 +33,9 @@ class HttpViewData
/// The function template is used to get an item in the data set by the
/// @param key.
template <typename T>
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())
{

View File

@ -26,8 +26,9 @@ class Session
{
public:
template <typename T>
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<std::mutex> lck(_mutex);
auto it = _sessionMap.find(key);
if (it != _sessionMap.end())

View File

@ -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())
{

View File

@ -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())
{

View File

@ -25,17 +25,16 @@ const std::string Users::primaryKeyName = "id";
const bool Users::hasPrimaryKey = true;
const std::string Users::tableName = "users";
const std::vector<typename Users::MetaData> 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<typename Users::MetaData> 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<std::string>(r["user_id"].as<std::string>());
}
if(!r["user_name"].isNull())
{
_userName=std::make_shared<std::string>(r["user_name"].as<std::string>());
}
if(!r["password"].isNull())
{
_password=std::make_shared<std::string>(r["password"].as<std::string>());
}
if(!r["org_name"].isNull())
{
_orgName=std::make_shared<std::string>(r["org_name"].as<std::string>());
}
if(!r["signature"].isNull())
{
_signature=std::make_shared<std::string>(r["signature"].as<std::string>());
}
if(!r["avatar_id"].isNull())
{
_avatarId=std::make_shared<std::string>(r["avatar_id"].as<std::string>());
}
if(!r["id"].isNull())
{
_id=std::make_shared<int32_t>(r["id"].as<int32_t>());
}
if(!r["salt"].isNull())
{
_salt=std::make_shared<std::string>(r["salt"].as<std::string>());
}
if(!r["admin"].isNull())
{
_admin=std::make_shared<bool>(r["admin"].as<bool>());
}
if (!r["user_id"].isNull())
{
_userId = std::make_shared<std::string>(r["user_id"].as<std::string>());
}
if (!r["user_name"].isNull())
{
_userName =
std::make_shared<std::string>(r["user_name"].as<std::string>());
}
if (!r["password"].isNull())
{
_password =
std::make_shared<std::string>(r["password"].as<std::string>());
}
if (!r["org_name"].isNull())
{
_orgName =
std::make_shared<std::string>(r["org_name"].as<std::string>());
}
if (!r["signature"].isNull())
{
_signature =
std::make_shared<std::string>(r["signature"].as<std::string>());
}
if (!r["avatar_id"].isNull())
{
_avatarId =
std::make_shared<std::string>(r["avatar_id"].as<std::string>());
}
if (!r["id"].isNull())
{
_id = std::make_shared<int32_t>(r["id"].as<int32_t>());
}
if (!r["salt"].isNull())
{
_salt = std::make_shared<std::string>(r["salt"].as<std::string>());
}
if (!r["admin"].isNull())
{
_admin = std::make_shared<bool>(r["admin"].as<bool>());
}
}
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<const int32_t> 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<std::string> &Users::insertColumns() noexcept
{
static const std::vector<std::string> _inCols={
"user_id",
"user_name",
"password",
"org_name",
"signature",
"avatar_id",
"salt",
"admin"
};
static const std::vector<std::string> _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<std::string> Users::updateColumns() const
{
std::vector<std::string> ret;
for(size_t i=0;i<sizeof(_dirtyFlag);i++)
for (size_t i = 0; i < sizeof(_dirtyFlag); i++)
{
if(_dirtyFlag[i])
if (_dirtyFlag[i])
{
ret.push_back(getColumnName(i));
}
@ -369,9 +372,9 @@ const std::vector<std::string> 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;
}

View File

@ -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<const std::string> 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<const std::string> 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<const std::string> 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<const std::string> 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<const std::string> 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<const std::string> 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<const int32_t> 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<const std::string> 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<const bool> 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<std::string> 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<std::string> _userId;
std::shared_ptr<std::string> _userName;
@ -163,8 +182,8 @@ class Users
const bool _notNull;
};
static const std::vector<MetaData> _metaData;
bool _dirtyFlag[9]={ false };
bool _dirtyFlag[9] = {false};
};
} // namespace postgres
} // namespace drogon_model
} // namespace postgres
} // namespace drogon_model