当前位置: 首页>>代码示例>>C++>>正文


C++ Statement::Bind方法代码示例

本文整理汇总了C++中Statement::Bind方法的典型用法代码示例。如果您正苦于以下问题:C++ Statement::Bind方法的具体用法?C++ Statement::Bind怎么用?C++ Statement::Bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statement的用法示例。


在下文中一共展示了Statement::Bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetChatrooms

	bool Database::GetChatrooms(const Server &Host, std::vector<Chatroom> &Out)
	{
		Out.clear();
		const std::string Query = "SELECT * FROM Chatroom WHERE ServerIP = :ServerIP' AND ServerPort = :ServerPort AND ServerFamily = :ServerFamily";

		Statement s;
		if (s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":ServerIP", Host.Address.GetPrintableIP()) || !s.Bind(":ServerPort", Host.Address.Port) || !s.Bind(":ServerFamily", Host.Address.Family))
			return false;

		bool MoreData = true;
		while (MoreData)
		{
			if (!s.Step(MoreData))
				return false;

			Chatroom c;
			if (!_GetChatroom(s, c))
				return false;
			Out.push_back(c);
		}

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:26,代码来源:Database.cpp

示例2: InsertServer

	bool Database::InsertServer(const Server &Server)
	{
		const std::string Query = "INSERT OR REPLACE INTO Server VALUES (:IP, :Port, :Family, :Name)";

		Statement s;
		if (!s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":IP", Server.Address.GetPrintableIP()) || !s.Bind(":Port", Server.Address.Port) || !s.Bind(":Family", Server.Address.Family) || !s.Bind(":Name", Server.Name))
			return false;

		if (!s.Execute())
			return false;

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:16,代码来源:Database.cpp

示例3: InsertUser

	bool Database::InsertUser(const User &User)
	{
		const std::string Query = "INSERT OR REPLACE INTO User VALUES (:Username, :Password)";

		Statement s;
		if (!s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":Username", User.Username) || !s.Bind(":Password", User.Password))
			return false;

		if (!s.Execute())
			return false;

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:16,代码来源:Database.cpp

示例4: GetServer

	bool Database::GetServer(const Net::Address Address, Server &Out)
	{
		const std::string Query = "SELECT * FROM Server WHERE Family = :Family AND IP = :IP AND Port = :Port";

		Statement s;
		if (!s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":Family", Address.Family) || !s.Bind(":IP", Address.GetPrintableIP()) || !s.Bind(":Port", Address.Port))
			return false;

		if (!s.Step())
			return false;

		if (!_GetServer(s, Out))
			return false;

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:19,代码来源:Database.cpp

示例5: GetUser

	bool Database::GetUser(const std::string &Username, User &Out)
	{
		const std::string Query = "SELECT * FROM User WHERE Username = :Username";

		Statement s;
		if (!s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":Username", Username.c_str()))
			return false;

		if (!s.Step())
			return false;

		if (!_GetUser(s, Out))
			return false;

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:19,代码来源:Database.cpp

示例6: GetChatroom

	bool Database::GetChatroom(const std::string &Name, Chatroom &Out)
	{
		const std::string Query = "SELECT * FROM Chatroom WHERE Name = :Name";

		Statement s;
		if (!s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":Name", Name))
			return false;

		if (!s.Step())
			return false;

		if (!_GetChatroom(s, Out))
			return false;

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:19,代码来源:Database.cpp

示例7: IsGeographic

bool Writer::IsGeographic(boost::int32_t srid)

{
    typedef boost::shared_ptr<long> shared_long;
    typedef boost::shared_ptr<char> shared_char;

    std::ostringstream oss;
    // char* kind = (char* ) malloc (OWNAME * sizeof(char));
    shared_char kind = boost::shared_ptr<char>(new char[OWNAME]);
    oss << "SELECT COORD_REF_SYS_KIND from MDSYS.SDO_COORD_REF_SYSTEM WHERE SRID = :1";

    Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));

    shared_long p_srid = boost::shared_ptr<long>(new long);
    *p_srid = srid;

    statement->Bind(p_srid.get());
    statement->Define(kind.get());

    try
    {
        statement->Execute();
    }
    catch (pdal_error const& e)
    {
        std::ostringstream oss;
        oss << "Failed to fetch geographicness of srid " << srid << std::endl << e.what() << std::endl;
        throw std::runtime_error(oss.str());
    }

    if (boost::iequals(kind.get(), "GEOGRAPHIC2D"))
    {
        return true;
    }
    if (boost::iequals(kind.get(), "GEOGRAPHIC3D"))
    {
        return true;
    }

    return false;

}
开发者ID:xhy20070406,项目名称:PDAL,代码行数:42,代码来源:Writer.cpp

示例8: InsertChatroom

	bool Database::InsertChatroom(const Chatroom &Chatroom)
	{
		const std::string Query = "INSERT OR REPLACE INTO Chatroom VALUES (:Name, :OwnerUsername, :ServerIP, :ServerPort, :ServerFamily, :Password, :Description)";

		Statement s;
		if (!s.Prepare(Inner, Query))
			return false;

		if (!s.Bind(":Name", Chatroom.Name) || !s.Bind(":OwnerUsername", Chatroom.OwnerUsername) || !s.Bind(":ServerIP", Chatroom.ServerAddress.GetPrintableIP()) ||
				!s.Bind(":ServerPort", Chatroom.ServerAddress.Port) || !s.Bind(":ServerFamily", Chatroom.ServerAddress.Family))
			return false;

		if (!Chatroom.Password.Null)
		{
			if (!s.Bind(":Password", Chatroom.Password.Value))
				return false;
		}
		else
		{
			if (!s.BindNull(":Password"))
				return false;
		}

		if (!Chatroom.Description.Null)
		{
			if (!s.Bind(":Description", Chatroom.Description.Value))
				return false;
		}
		else
		{
			if (!s.BindNull(":Description"))
				return false;
		}

		if (!s.Execute())
			return false;

		return true;
	}
开发者ID:hnefatl,项目名称:Chatroom,代码行数:39,代码来源:Database.cpp

示例9: CreatePCEntry

void Writer::CreatePCEntry(Schema const& buffer_schema)
{


    boost::uint32_t precision = getDefaultedOption<boost::uint32_t>("stream_output_precision");
    boost::uint32_t capacity = getDefaultedOption<boost::uint32_t>("capacity");




    std::ostringstream oss;


    oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
    oss.precision(precision);

    std::ostringstream columns;
    std::ostringstream values;

    if (!m_base_table_aux_columns.empty())
    {
        columns << m_cloud_column_name << "," << m_base_table_aux_columns;

        values << "pc," << m_base_table_aux_values;
    }
    else
    {
        columns << m_cloud_column_name;
        values << "pc";
    }

    int nPCPos = 1;
    int nSchemaPos = 1;
    nSchemaPos++;

    int nPos = nSchemaPos; // Bind column position

    if (!m_base_table_boundary_column.empty())
    {
        columns << "," << m_base_table_boundary_column;
        nPos++;
        values <<", SDO_GEOMETRY(:"<<nPos;
        nPos++;
        values <<", :"<<nPos<<")";
    }



    std::ostringstream s_srid;
    std::ostringstream s_geom;
    std::ostringstream s_schema;


    // IsGeographic(srid);

    if (m_srid == 0)
    {
        s_srid << "NULL";
    }
    else
    {
        s_srid << m_srid;
    }

    s_schema << "xmltype(:"<<nSchemaPos<<")";



    std::string eleminfo = CreatePCElemInfo();

    pdal::Bounds<double> base_table_bounds = getDefaultedOption<pdal::Bounds<double> >("base_table_bounds");

    if (base_table_bounds.empty())
    {
        if (IsGeographic(m_srid))
        {
            base_table_bounds.setMinimum(0, -179.99);
            base_table_bounds.setMinimum(1, -89.99);
            base_table_bounds.setMinimum(2, 0.0);
            base_table_bounds.setMaximum(0, 179.99);
            base_table_bounds.setMaximum(1, 89.99);
            base_table_bounds.setMaximum(2, 20000.0);
        }
        else
        {
            base_table_bounds.setMinimum(0, 0.0);
            base_table_bounds.setMinimum(1, 0.0);
            base_table_bounds.setMinimum(2, 0.0);
            base_table_bounds.setMaximum(0, 100.0);
            base_table_bounds.setMaximum(1, 100.0);
            base_table_bounds.setMaximum(2, 20000.0);
        }
    }
    s_geom << "           mdsys.sdo_geometry("<< m_gtype <<", "<<s_srid.str()<<", null,\n"
           "              mdsys.sdo_elem_info_array"<< eleminfo <<",\n"
           "              mdsys.sdo_ordinate_array(\n";

    s_geom << base_table_bounds.getMinimum(0) << "," << base_table_bounds.getMinimum(1) << ",";

    if (m_is3d)
//.........这里部分代码省略.........
开发者ID:xhy20070406,项目名称:PDAL,代码行数:101,代码来源:Writer.cpp

示例10: WriteBlock

bool Writer::WriteBlock(PointBuffer const& buffer)
{
    bool bUsePartition = m_block_table_partition_column.size() != 0;

    // Pluck the block id out of the first point in the buffer
    pdal::Schema const& schema = buffer.getSchema();
    Dimension const& blockDim = schema.getDimension("BlockID");

    boost::int32_t block_id  = buffer.getField<boost::int32_t>(blockDim, 0);

    std::ostringstream oss;
    std::ostringstream partition;

    if (bUsePartition)
    {
        partition << "," << m_block_table_partition_column;
    }

    oss << "INSERT INTO "<< m_block_table_name <<
        "(OBJ_ID, BLK_ID, NUM_POINTS, POINTS,   "
        "PCBLK_MIN_RES, BLK_EXTENT, PCBLK_MAX_RES, NUM_UNSORTED_POINTS, PT_SORT_DIM";
    if (bUsePartition)
        oss << partition.str();
    oss << ") "
        "VALUES ( :1, :2, :3, :4, 1, mdsys.sdo_geometry(:5, :6, null,:7, :8)"
        ", 1, 0, 1";
    if (bUsePartition)
        oss << ", :9";

    oss <<")";

    // TODO: If gotdata == false below, this memory probably leaks --mloskot
    OCILobLocator** locator =(OCILobLocator**) VSIMalloc(sizeof(OCILobLocator*) * 1);

    Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));


    long* p_pc_id = (long*) malloc(1 * sizeof(long));
    p_pc_id[0] = m_pc_id;

    long* p_result_id = (long*) malloc(1 * sizeof(long));
    p_result_id[0] = (long)block_id;

    long* p_num_points = (long*) malloc(1 * sizeof(long));
    p_num_points[0] = (long)buffer.getNumPoints();

    // std::cout << "point count on write: " << buffer.getNumPoints() << std::endl;


    // :1
    statement->Bind(&m_pc_id);

    // :2
    statement->Bind(p_result_id);

    // :3
    statement->Bind(p_num_points);

    // :4
    statement->Define(locator, 1);


    // std::vector<liblas::uint8_t> data;
    // bool gotdata = GetResultData(result, reader, data, 3);
    // if (! gotdata) throw std::runtime_error("unable to fetch point data byte array");
    // boost::uint8_t* point_data = buffer.getData(0);
    boost::uint8_t* point_data;
    boost::uint32_t point_data_length;
    boost::uint32_t schema_byte_size;
    
    bool pack = getOptions().getValueOrDefault<bool>("pack_ignored_fields", true);
    if (pack)
        PackPointData(buffer, &point_data, point_data_length, schema_byte_size);
    else
    {
        point_data = buffer.getData(0);
        point_data_length = buffer.getSchema().getByteSize() * buffer.getNumPoints();
    }

    // statement->Bind((char*)point_data,(long)(buffer.getSchema().getByteSize()*buffer.getNumPoints()));
    statement->Bind((char*)point_data,(long)(point_data_length));

    // :5
    long* p_gtype = (long*) malloc(1 * sizeof(long));
    p_gtype[0] = m_gtype;

    statement->Bind(p_gtype);

    // :6
    long* p_srid  = 0;


    if (m_srid != 0)
    {
        p_srid = (long*) malloc(1 * sizeof(long));
        p_srid[0] = m_srid;
    }
    statement->Bind(p_srid);

    // :7
//.........这里部分代码省略.........
开发者ID:xhy20070406,项目名称:PDAL,代码行数:101,代码来源:Writer.cpp


注:本文中的Statement::Bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。