/** * * Tokens.h * DO NOT EDIT. This file is generated by drogon_ctl * */ #pragma once #include #include #include #include #include #ifdef __cpp_impl_coroutine #include #endif #include #include #include #include #include #include #include #include #include namespace drogon { namespace orm { class DbClient; using DbClientPtr = std::shared_ptr; } } namespace drogon_model { namespace sqlite3 { class Tokens { public: struct Cols { static const std::string _id; static const std::string _owner_id; static const std::string _exp; }; const static int primaryKeyNumber; const static std::string tableName; const static bool hasPrimaryKey; const static std::string primaryKeyName; using PrimaryKeyType = uint64_t; const PrimaryKeyType &getPrimaryKey() const; /** * @brief constructor * @param r One row of records in the SQL query result. * @param indexOffset Set the offset to -1 to access all columns by column names, * otherwise access all columns by offsets. * @note If the SQL is not a style of 'select * from table_name ...' (select all * columns by an asterisk), please set the offset to -1. */ explicit Tokens(const drogon::orm::Row &r, const ssize_t indexOffset = 0) noexcept; /** * @brief constructor * @param pJson The json object to construct a new instance. */ explicit Tokens(const Json::Value &pJson) noexcept(false); /** * @brief constructor * @param pJson The json object to construct a new instance. * @param pMasqueradingVector The aliases of table columns. */ Tokens(const Json::Value &pJson, const std::vector &pMasqueradingVector) noexcept(false); Tokens() = default; void updateByJson(const Json::Value &pJson) noexcept(false); void updateByMasqueradedJson(const Json::Value &pJson, const std::vector &pMasqueradingVector) noexcept(false); static bool validateJsonForCreation(const Json::Value &pJson, std::string &err); static bool validateMasqueradedJsonForCreation(const Json::Value &, const std::vector &pMasqueradingVector, std::string &err); static bool validateJsonForUpdate(const Json::Value &pJson, std::string &err); static bool validateMasqueradedJsonForUpdate(const Json::Value &, const std::vector &pMasqueradingVector, std::string &err); static bool validJsonOfField(size_t index, const std::string &fieldName, const Json::Value &pJson, std::string &err, bool isForCreation); /** For column id */ ///Get the value of the column id, returns the default value if the column is null const uint64_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 const std::shared_ptr &getId() const noexcept; ///Set the value of the column id void setId(const uint64_t &pId) noexcept; /** For column owner_id */ ///Get the value of the column owner_id, returns the default value if the column is null const uint64_t &getValueOfOwnerId() const noexcept; ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null const std::shared_ptr &getOwnerId() const noexcept; ///Set the value of the column owner_id void setOwnerId(const uint64_t &pOwnerId) noexcept; /** For column exp */ ///Get the value of the column exp, returns the default value if the column is null const uint64_t &getValueOfExp() const noexcept; ///Return a shared_ptr object pointing to the column const value, or an empty shared_ptr object if the column is null const std::shared_ptr &getExp() const noexcept; ///Set the value of the column exp void setExp(const uint64_t &pExp) noexcept; static size_t getColumnNumber() noexcept { return 3; } static const std::string &getColumnName(size_t index) noexcept(false); Json::Value toJson() const; Json::Value toMasqueradedJson(const std::vector &pMasqueradingVector) const; /// Relationship interfaces private: friend drogon::orm::Mapper; #ifdef __cpp_impl_coroutine friend drogon::orm::CoroMapper; #endif static const std::vector &insertColumns() noexcept; 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 void updateId(const uint64_t id); std::shared_ptr id_; std::shared_ptr ownerId_; std::shared_ptr exp_; struct MetaData { const std::string colName_; const std::string colType_; const std::string colDatabaseType_; const ssize_t colLength_; const bool isAutoVal_; const bool isPrimaryKey_; const bool notNull_; }; static const std::vector metaData_; bool dirtyFlag_[3]={ false }; public: static const std::string &sqlForFindingByPrimaryKey() { static const std::string sql="select * from " + tableName + " where id = ?"; return sql; } static const std::string &sqlForDeletingByPrimaryKey() { static const std::string sql="delete from " + tableName + " where id = ?"; return sql; } std::string sqlForInserting(bool &needSelection) const { std::string sql="insert into " + tableName + " ("; size_t parametersCount = 0; needSelection = false; if(dirtyFlag_[1]) { sql += "owner_id,"; ++parametersCount; } if(dirtyFlag_[2]) { sql += "exp,"; ++parametersCount; } if(parametersCount > 0) { sql[sql.length()-1]=')'; sql += " values ("; } else sql += ") values ("; if(dirtyFlag_[1]) { sql.append("?,"); } if(dirtyFlag_[2]) { sql.append("?,"); } if(parametersCount > 0) { sql.resize(sql.length() - 1); } sql.append(1, ')'); LOG_TRACE << sql; return sql; } }; } // namespace sqlite3 } // namespace drogon_model