本文整理汇总了C++中SqlStatementID::init方法的典型用法代码示例。如果您正苦于以下问题:C++ SqlStatementID::init方法的具体用法?C++ SqlStatementID::init怎么用?C++ SqlStatementID::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlStatementID
的用法示例。
在下文中一共展示了SqlStatementID::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateStatement
SqlStatement Database::CreateStatement(SqlStatementID& index, const char* fmt)
{
int nId = -1;
//check if statement ID is initialized
if (!index.initialized())
{
//convert to lower register
std::string szFmt(fmt);
//count input parameters
int nParams = std::count(szFmt.begin(), szFmt.end(), '?');
//find existing or add a new record in registry
LOCK_GUARD _guard(m_stmtGuard);
PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.find(szFmt);
if (iter == m_stmtRegistry.end())
{
nId = ++m_iStmtIndex;
m_stmtRegistry[szFmt] = nId;
}
else
nId = iter->second;
//save initialized statement index info
index.init(nId, nParams);
}
return SqlStatement(index, *this);
}
示例2: if
unique_ptr<SqlStatement> ConcreteDatabase::makeStatement( SqlStatementID& index, std::string sqlText )
{
//initialize the statement if its not (or missing in the registry)
if(!index.isInitialized())
{
//count input parameters
size_t nParams = std::count(sqlText.begin(), sqlText.end(), '?');
UInt32 nId = _prepStmtRegistry.getStmtId(std::move(sqlText));
//save initialized statement index info
index.init(nId, nParams);
}
else if (!_prepStmtRegistry.idDefined(index.getId()))
_prepStmtRegistry.insertStmt(index.getId(),std::move(sqlText));
return unique_ptr<SqlStatement>(new SqlStatementImpl(index, *this));
}