本文整理汇总了C++中Statement类的典型用法代码示例。如果您正苦于以下问题:C++ Statement类的具体用法?C++ Statement怎么用?C++ Statement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: indent
void Output_Nested::operator()(Media_Block* m)
{
List* q = m->media_queries();
Block* b = m->block();
bool decls = false;
indent();
ctx->source_map.add_mapping(m);
append_to_buffer("@media ");
q->perform(this);
append_to_buffer(" {\n");
Selector* e = m->enclosing_selector();
bool hoisted = false;
if (e && b->has_non_hoistable()) {
hoisted = true;
++indentation;
indent();
e->perform(this);
append_to_buffer(" {\n");
}
++indentation;
decls = true;
for (size_t i = 0, L = b->length(); i < L; ++i) {
Statement* stm = (*b)[i];
if (!stm->is_hoistable()) {
if (!stm->block()) indent();
stm->perform(this);
append_to_buffer("\n");
}
}
--indentation;
if (hoisted) {
buffer.erase(buffer.length()-1);
if (ctx) ctx->source_map.remove_line();
append_to_buffer(" }\n");
--indentation;
}
if (decls) ++indentation;
if (hoisted) ++indentation;
for (size_t i = 0, L = b->length(); i < L; ++i) {
Statement* stm = (*b)[i];
if (stm->is_hoistable()) {
stm->perform(this);
}
}
if (hoisted) --indentation;
if (decls) --indentation;
buffer.erase(buffer.length()-1);
if (ctx) ctx->source_map.remove_line();
append_to_buffer(" }\n");
}
示例2: get_fact_mgr_for_func
Statement*
Block::append_return_stmt(CGContext& cg_context)
{
FactMgr* fm = get_fact_mgr_for_func(func);
FactVec pre_facts = fm->global_facts;
cg_context.get_effect_stm().clear();
Statement* sr = Statement::make_random(cg_context, eReturn);
ERROR_GUARD(NULL);
stms.push_back(sr);
fm->makeup_new_var_facts(pre_facts, fm->global_facts);
assert(sr->visit_facts(fm->global_facts, cg_context));
fm->set_fact_in(sr, pre_facts);
fm->set_fact_out(sr, fm->global_facts);
fm->map_accum_effect[sr] = *(cg_context.get_effect_accum());
fm->map_visited[sr] = true;
//sr->post_creation_analysis(pre_facts, cg_context);
fm->map_accum_effect[this] = *(cg_context.get_effect_accum());
fm->map_stm_effect[this].add_effect(fm->map_stm_effect[sr]);
return sr;
}
示例3: Results
Results* ParentClause::addParentPairToResult(set<Statement*> containerStmts, NodeType type) {
Results* resultsObj = new Results();
for (set<Statement*>::iterator containerIter = containerStmts.begin(); containerIter != containerStmts.end(); containerIter++) {
Statement* containerStmt = *containerIter;
string containerStmtNo = boost::lexical_cast<string>(containerStmt->getStmtNum());
set<int> children;
if (type == NULL_) {
children = containerStmt->getChildren();
} else {
children = Utils::filterStatements(containerStmt->getChildren(), type);
}
if (!children.empty()) {
resultsObj->setClausePassed(true);
for (set<int>::iterator childrenIter = children.begin(); childrenIter != children.end(); childrenIter++) {
string childStmtNo = boost::lexical_cast<string>(*childrenIter);
resultsObj->addPairResult(containerStmtNo, childStmtNo);
}
}
}
return resultsObj;
}
示例4:
/**
* Find all content placeholders
*/
vector<ContentPlaceholder*> ContentPlaceholderController::GetAllContentPlaceholders()
{
Statement* stmt = conn->createStatement();
ResultSet* rs = stmt->executeQuery("SELECT * FROM cph");
delete stmt;
vector<ContentPlaceholder*> cphs;
if(rs != NULL)
{
while(rs->next())
{
//Add all content placeholders to a vector
cphs.push_back(GenerateContentPlaceholder(*rs));
}
delete rs;
}
return cphs;
}
示例5:
/**
* Find all sheets
*/
vector<Sheet*> SheetController::GetAllSheets()
{
Statement* stmt = conn->createStatement();
ResultSet* rs = stmt->executeQuery("SELECT * FROM sheets");
vector<Sheet*> sheets;
if(rs != NULL)
{
while(rs->next())
{
//Add all sheets to a vector
sheets.push_back(GenerateSheet(*rs));
}
}
delete stmt;
delete rs;
return sheets;
}
示例6: assert
void SQLiteStore::updateExpiration(const std::string &path, int64_t expires) {
assert(uv_thread_self() == thread_id);
if (!db || !*db) return;
ExpirationBaton *expiration_baton = new ExpirationBaton;
expiration_baton->db = db;
expiration_baton->path = path;
expiration_baton->expires = expires;
uv_worker_send(worker, expiration_baton, [](void *data) {
ExpirationBaton *baton = (ExpirationBaton *)data;
const std::string url = unifyMapboxURLs(baton->path);
Statement stmt = // 1 2
baton->db->prepare("UPDATE `http_cache` SET `expires` = ? WHERE `url` = ?");
stmt.bind<int64_t>(1, baton->expires);
stmt.bind(2, url.c_str());
stmt.run();
}, [](void *data) {
delete (ExpirationBaton *)data;
});
}
示例7: SQLNumParams
SQLRETURN SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt)
{
using odbc::Statement;
LOG_MSG("SQLNumParams called");
Statement *statement = reinterpret_cast<Statement*>(stmt);
if (!statement)
return SQL_INVALID_HANDLE;
if (paramCnt)
{
uint16_t paramNum = 0;
statement->GetParametersNumber(paramNum);
*paramCnt = static_cast<SQLSMALLINT>(paramNum);
}
return statement->GetDiagnosticRecords().GetReturnCode();
}
示例8: SQLFreeStmt
SQLRETURN SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option)
{
using odbc::Statement;
LOG_MSG("SQLFreeStmt called [option=" << option << ']');
Statement *statement = reinterpret_cast<Statement*>(stmt);
if (!statement)
return SQL_INVALID_HANDLE;
if (option == SQL_DROP)
{
delete statement;
return SQL_SUCCESS;
}
statement->FreeResources(option);
return statement->GetDiagnosticRecords().GetReturnCode();
}
示例9: executeStatement
/*****************************************************************************
* public method executeStatement
* - create a temporary local Statement
* - look at value of numTokens
* - if numTokens == 3, excute assignment statement
* - else if numtokens == 2, execute print statement
* - else, either execute lock, unlock or end depending on value of token
*
****************************************************************************/
void Program::executeStatement(int& semaphore)
{
Statement tempStatement = statementList.getItemVal(programCounter);
cout << "statement retrieved: " << tempStatement << endl;
if(tempStatement.getNumValues() == 3)
{
stringstream lValSS, rValSS;
char lValChar;
int lValInt, rValInt;
cout << "lValString = " << tempStatement.getLValue() << endl;
lValSS << tempStatement.getLValue(); // get left side of assignment
lValSS >> lValChar; // convert to int for array index
cout << "lValChar = " << lValChar << endl;
lValChar -= 'a';
lValInt = (int)lValChar;
cout << "lValInt = " << lValInt << endl;
rValSS << tempStatement.getRValue(); // get right side of assignment
rValSS >> rValInt; // convert to int for value
variables[lValInt] = rValInt; // assign the new value
cout << "new value = " << rValInt << endl;
}
示例10:
std::vector<std::pair<bool, Block*>> Cssize::slice_by_bubble(Statement* b)
{
std::vector<std::pair<bool, Block*>> results;
for (size_t i = 0, L = b->block()->length(); i < L; ++i) {
Statement* value = (*b->block())[i];
bool key = value->statement_type() == Statement::BUBBLE;
if (!results.empty() && results.back().first == key)
{
Block* wrapper_block = results.back().second;
*wrapper_block << value;
}
else
{
Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, value->pstate());
*wrapper_block << value;
results.push_back(std::make_pair(key, wrapper_block));
}
}
return results;
}
示例11: getOptions
bool Writer::BlockTableExists()
{
std::ostringstream oss;
std::string block_table_name = getOptions().getValueOrThrow<std::string>("block_table_name");
char szTable[OWNAME]= "";
oss << "select table_name from user_tables";
log()->get(logDEBUG) << "checking for " << block_table_name << " existence ... " ;
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
// Because of OCIGDALErrorHandler, this is going to throw if there is a
// problem. When it does, the statement should go out of scope and
// be destroyed without leaking.
statement->Define(szTable);
statement->Execute();
log()->get(logDEBUG) << "checking ... " << szTable ;
bool bDidRead(true);
while (bDidRead)
{
log()->get(logDEBUG) << ", " << szTable;
if (boost::iequals(szTable, block_table_name))
{
log()->get(logDEBUG) << " -- '" << block_table_name << "' found." <<std::endl;
return true;
}
bDidRead = statement->Fetch();
}
log()->get(logDEBUG) << " -- '" << block_table_name << "' not found." << std::endl;
return false;
}
示例12: SLOG
/*!
* \brief データベースバージョン取得
*
* \return データベースバージョン
*/
int32_t SequenceLogServiceDB::getVersion() const
{
SLOG(CLS_NAME, "getVersion");
int32_t version = 0;
Statement* stmt = nullptr;
try
{
const char* sql = "select version from version_info";
stmt = newStatement();
stmt->prepare(sql);
stmt->setIntResult(0, &version);
stmt->bind();
stmt->execute();
stmt->fetch();
}
catch (Exception e)
{
// 初回起動時などテーブルが存在しない場合もあるので、
// 例外が発生しても何もすることはない
SMSG(slog::DEBUG, "%s", e.getMessage());
}
delete stmt;
return version;
}
示例13:
bool operator == ( const Statement & s1, const Statement & s2 )
{
if( s1.type() == Statement::Word && s2.type() == Statement::Word )
return s1.word() == s2.word();
else
return s1.type() == s2.type();
}
示例14: while
std::vector<statement_output_variable_definition*>* Branch::getExposedVariableDefinitions()
{
std::vector<statement_output_variable_definition*>* vars = new std::vector<
statement_output_variable_definition*>();
for (std::map<std::string, Action*>::iterator iter = actionBranches->begin();
iter != actionBranches->end(); ++iter) {
Statement* nextStatement = iter->second->getNextStatement();
while (nextStatement) {
std::vector<statement_output_variable_definition*>* statementVars =
nextStatement->getExposedVariableDefinitions();
if (NULL != statementVars) {
vars->insert(vars->end(), statementVars->begin(), statementVars->end());
delete statementVars;
}
nextStatement = nextStatement->getNextStatement();
}
}
for (std::map<std::string, Trigger*>::iterator iter = triggerBranches->begin();
iter != triggerBranches->end(); ++iter) {
Statement* nextStatement = iter->second->getNextStatement();
while (nextStatement) {
std::vector<statement_output_variable_definition*>* statementVars =
nextStatement->getExposedVariableDefinitions();
if (NULL != statementVars) {
vars->insert(vars->end(), statementVars->begin(), statementVars->end());
delete statementVars;
}
nextStatement = nextStatement->getNextStatement();
}
}
return vars;
}
示例15: SQLDescribeCol
SQLRETURN SQLDescribeCol(SQLHSTMT stmt,
SQLUSMALLINT columnNum,
SQLCHAR* columnNameBuf,
SQLSMALLINT columnNameBufLen,
SQLSMALLINT* columnNameLen,
SQLSMALLINT* dataType,
SQLULEN* columnSize,
SQLSMALLINT* decimalDigits,
SQLSMALLINT* nullable)
{
using odbc::Statement;
using odbc::SqlLen;
LOG_MSG("SQLDescribeCol called");
Statement *statement = reinterpret_cast<Statement*>(stmt);
if (!statement)
return SQL_INVALID_HANDLE;
statement->GetColumnAttribute(columnNum, SQL_DESC_NAME,
reinterpret_cast<char*>(columnNameBuf), columnNameBufLen, columnNameLen, 0);
SqlLen dataTypeRes;
SqlLen columnSizeRes;
SqlLen decimalDigitsRes;
SqlLen nullableRes;
statement->GetColumnAttribute(columnNum, SQL_DESC_TYPE, 0, 0, 0, &dataTypeRes);
statement->GetColumnAttribute(columnNum, SQL_DESC_PRECISION, 0, 0, 0, &columnSizeRes);
statement->GetColumnAttribute(columnNum, SQL_DESC_SCALE, 0, 0, 0, &decimalDigitsRes);
statement->GetColumnAttribute(columnNum, SQL_DESC_NULLABLE, 0, 0, 0, &nullableRes);
LOG_MSG("columnNum: " << columnNum);
LOG_MSG("dataTypeRes: " << dataTypeRes);
LOG_MSG("columnSizeRes: " << columnSizeRes);
LOG_MSG("decimalDigitsRes: " << decimalDigitsRes);
LOG_MSG("nullableRes: " << nullableRes);
LOG_MSG("columnNameBuf: " << (columnNameBuf ? reinterpret_cast<const char*>(columnNameBuf) : "<null>"));
LOG_MSG("columnNameLen: " << (columnNameLen ? *columnNameLen : -1));
if (dataType)
*dataType = static_cast<SQLSMALLINT>(dataTypeRes);
if (columnSize)
*columnSize = static_cast<SQLULEN>(columnSizeRes);
if (decimalDigits)
*decimalDigits = static_cast<SQLSMALLINT>(decimalDigitsRes);
if (nullable)
*nullable = static_cast<SQLSMALLINT>(nullableRes);
return statement->GetDiagnosticRecords().GetReturnCode();
}