コード例 #1
0
ファイル: VisitorInfo.cpp プロジェクト: Nightaway/dragon
void VisitorInfo::Stuff(sql::Connection *conn, int id, int type)
{
  this->id = id;
  const char *strQuery = NULL;
  
  if (type == kFilterTypeCampaign) {
    strQuery = strQueryVisitorFilterInfoByCId;
  } else if (type == kFilterTypeBanner) {
    strQuery = strQueryVisitorFilterInfoByBId;
  } else {
    UNREACHABLE();
  }

  boost::scoped_ptr<sql::PreparedStatement> prep_stmt(conn->prepareStatement(strQuery));
  prep_stmt->setInt(1, id);	
  boost::scoped_ptr<sql::ResultSet> rs(prep_stmt->executeQuery());
  while (rs->next()) {
    Visitor info = {rs->getString("type"), rs->getInt("count"), rs->getInt("time"), rs->getString("activate_time")};
    infos.push_back(info);
  }

  if (infos.size() == 0) {
    this->id = -1;
  }
}
コード例 #2
0
template<class TImage> typename TImage::Pointer ttt::JSONTissueTrackingProject::readImage(const std::string & table, int frame) {
		typedef itk::ImageFileReader<TImage> ReaderType;
		typename ReaderType::Pointer reader = ReaderType::New();

		std::stringstream ssQuery, ssFileName;

		try {
			ssQuery << "SELECT fileName FROM " << table << " WHERE " << table
					<< ".idProject=? AND " << table << ".t=?";

			std::auto_ptr<sql::PreparedStatement> prep_stmt(
					m_DB->prepareStatement(ssQuery.str()));

			prep_stmt->setInt(1, m_ProjectID); //IDproject==2
			prep_stmt->setInt(2, frame); //IDproject==2
			prep_stmt->execute();

			std::auto_ptr<sql::ResultSet> res(prep_stmt->getResultSet());

			assert(res->next());

			std::string fileName = res->getString("fileName");

			ssFileName << m_WorkingDirectory << "/" << fileName;

			reader->SetFileName(ssFileName.str());
			;
			reader->Update();
			reader->GetOutput()->SetSpacing(m_Spacing);
			return reader->GetOutput();

		} catch (sql::SQLException &e) {
			/*
			 The MySQL Connector/C++ throws three different exceptions:

			 - sql::MethodNotImplementedException (derived from sql::SQLException)
			 - sql::InvalidArgumentException (derived from sql::SQLException)
			 - sql::SQLException (derived from std::runtime_error)
			 */
			cout << "# ERR: SQLException in " << __FILE__;
			//    cout << "(" << EXAMPLE_FUNCTION << ") on line " << __LINE__ << endl;
			/* Use what() (derived from std::runtime_error) to fetch the error message */
			cout << "# ERR: " << e.what();
			cout << " (MySQL error code: " << e.getErrorCode();
			cout << ", SQLState: " << e.getSQLState() << " )" << endl;

		}
		return NULL;
	}
コード例 #3
0
template<class TImage> void ttt::JSONTissueTrackingProject::storeImage(const typename TImage::Pointer & image, const std::string & table,unsigned int frame) {

		std::stringstream ssQuery, ssFileName, ssPath;

		typedef itk::ImageFileWriter<TImage> WriterType;

		typename WriterType::Pointer writer = WriterType::New();

		ssFileName << table << "-" << frame << ".tif";
		ssPath << this->m_ProjectPath << "/" << ssFileName.str();
		writer->SetFileName(ssPath.str());
		writer->SetInput(image);
		writer->Update();

		try {

			ssQuery << "INSERT into " << table
					<< " (idProject, t, fileName) values (?, ?, ?) on duplicate key UPDATE fileName=VALUES(fileName)";

			std::auto_ptr<sql::PreparedStatement> prep_stmt(
					m_DB->prepareStatement(ssQuery.str()));

			prep_stmt->setInt(1, m_ProjectID); //IDproject==2
			prep_stmt->setInt(2, frame); //t==0
			prep_stmt->setString(3, ssFileName.str());

			prep_stmt->execute();
		} catch (sql::SQLException &e) {
			/*
			 The MySQL Connector/C++ throws three different exceptions:

			 - sql::MethodNotImplementedException (derived from sql::SQLException)
			 - sql::InvalidArgumentException (derived from sql::SQLException)
			 - sql::SQLException (derived from std::runtime_error)
			 */
			cout << "# ERR: SQLException in " << __FILE__;
			//    cout << "(" << EXAMPLE_FUNCTION << ") on line " << __LINE__ << endl;
			/* Use what() (derived from std::runtime_error) to fetch the error message */
			cout << "# ERR: " << e.what();
			cout << " (MySQL error code: " << e.getErrorCode();
			cout << ", SQLState: " << e.getSQLState() << " )" << endl;

		}

	}
コード例 #4
0
void
expand_stmt (tree t)
{
    while (t && t != error_mark_node)
    {
        int saved_stmts_are_full_exprs_p;

        /* Set up context appropriately for handling this statement.  */
        saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
        prep_stmt (t);

        switch (TREE_CODE (t))
        {
        case FILE_STMT:
            input_filename = FILE_STMT_FILENAME (t);
            break;

        case RETURN_STMT:
            genrtl_return_stmt (t);
            t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
            goto process_t;

        case EXPR_STMT:
            genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t),
                                    TREE_CHAIN (t) == NULL
                                    || (TREE_CODE (TREE_CHAIN (t)) == SCOPE_STMT
                                        && TREE_CHAIN (TREE_CHAIN (t)) == NULL));
            break;

        case DECL_STMT:
            genrtl_decl_stmt (t);
            break;

        case FOR_STMT:
            genrtl_for_stmt (t);
            break;

        case WHILE_STMT:
            genrtl_while_stmt (t);
            break;

        case DO_STMT:
            genrtl_do_stmt (t);
            break;

        case IF_STMT:
            genrtl_if_stmt (t);
            break;

        case COMPOUND_STMT:
            genrtl_compound_stmt (t);
            break;

        case BREAK_STMT:
            genrtl_break_stmt ();
            t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
            goto process_t;

        case CONTINUE_STMT:
            genrtl_continue_stmt ();
            t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
            goto process_t;

        case SWITCH_STMT:
            genrtl_switch_stmt (t);
            break;

        case CASE_LABEL:
            genrtl_case_label (t);
            break;

        case LABEL_STMT:
            expand_label (LABEL_STMT_LABEL (t));
            break;

        case GOTO_STMT:
            /* Emit information for branch prediction.  */
            if (!GOTO_FAKE_P (t)
                    && TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL
                    && flag_guess_branch_prob)
            {
                rtx note = emit_note (NOTE_INSN_PREDICTION);

                NOTE_PREDICTION (note) = NOTE_PREDICT (PRED_GOTO, NOT_TAKEN);
            }
            genrtl_goto_stmt (GOTO_DESTINATION (t));
            t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
            goto process_t;

        case ASM_STMT:
            genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t),
                             ASM_OUTPUTS (t), ASM_INPUTS (t),
                             ASM_CLOBBERS (t), ASM_INPUT_P (t));
            break;

        case SCOPE_STMT:
            genrtl_scope_stmt (t);
            break;

        case CLEANUP_STMT:
            genrtl_cleanup_stmt (t);
            break;

        default:
            if (lang_expand_stmt)
                (*lang_expand_stmt) (t);
            else
                abort ();
            break;
        }

        /* Go on to the next statement in this scope.  */
        t = TREE_CHAIN (t);

process_t:
        /* Restore saved state.  */
        current_stmt_tree ()->stmts_are_full_exprs_p
            = saved_stmts_are_full_exprs_p;
    }
}