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


C++ DbReference类代码示例

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


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

示例1: AssertOnWorkQueue

void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
{
	AssertOnWorkQueue();

	if (!GetConnected())
		return;

	DbReference dbref = GetObjectID(dbobj);
	std::ostringstream qbuf;

	if (!dbref.IsValid()) {
		if (!dbobj->GetName2().IsEmpty()) {
			qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
			      << static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
			      << "E'" << Escape(dbobj->GetName1()) << "', E'" << Escape(dbobj->GetName2()) << "', 1)";
		} else {
			qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, is_active) VALUES ("
			     << static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
			     << "E'" << Escape(dbobj->GetName1()) << "', 1)";
		}

		Query(qbuf.str());
		SetObjectID(dbobj, GetSequenceValue(GetTablePrefix() + "objects", "object_id"));
	} else {
		qbuf << "UPDATE " + GetTablePrefix() + "objects SET is_active = 1 WHERE object_id = " << static_cast<long>(dbref);
		Query(qbuf.str());
	}
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:28,代码来源:idopgsqlconnection.cpp

示例2: SetInsertID

void DbConnection::SetInsertID(const DbType::Ptr& type, const DbReference& objid, const DbReference& dbref)
{
	if (!objid.IsValid())
		return;

	if (dbref.IsValid())
		m_InsertIDs[std::make_pair(type, objid)] = dbref;
	else
		m_InsertIDs.erase(std::make_pair(type, objid));
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:10,代码来源:dbconnection.cpp

示例3: SetObjectID

void DbConnection::SetObjectID(const DbObject::Ptr& dbobj, const DbReference& dbref)
{
	if (dbref.IsValid())
		m_ObjectIDs[dbobj] = dbref;
	else
		m_ObjectIDs.erase(dbobj);
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:7,代码来源:dbconnection.cpp

示例4: SetNotificationInsertID

void DbConnection::SetNotificationInsertID(const CustomVarObject::Ptr& obj, const DbReference& dbref)
{
	if (dbref.IsValid())
		m_NotificationInsertIDs[obj] = dbref;
	else
		m_NotificationInsertIDs.erase(obj);
}
开发者ID:ogg1980,项目名称:icinga2,代码行数:7,代码来源:dbconnection.cpp

示例5: SetConfigHash

void DbConnection::SetConfigHash(const DbType::Ptr& type, const DbReference& objid, const String& hash)
{
	if (!objid.IsValid())
		return;

	if (!hash.IsEmpty())
		m_ConfigHashes[std::make_pair(type, objid)] = hash;
	else
		m_ConfigHashes.erase(std::make_pair(type, objid));
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:10,代码来源:dbconnection.cpp

示例6: DbReference

DbReference DbConnection::GetInsertID(const DbType::Ptr& type, const DbReference& objid) const
{
	if (!objid.IsValid())
		return DbReference();

	auto it = m_InsertIDs.find(std::make_pair(type, objid));

	if (it == m_InsertIDs.end())
		return DbReference();

	return it->second;
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:12,代码来源:dbconnection.cpp

示例7: GetConfigHash

String DbConnection::GetConfigHash(const DbType::Ptr& type, const DbReference& objid) const
{
	if (!objid.IsValid())
		return String();

	auto it = m_ConfigHashes.find(std::make_pair(type, objid));

	if (it == m_ConfigHashes.end())
		return String();

	return it->second;
}
开发者ID:spjmurray,项目名称:icinga2,代码行数:12,代码来源:dbconnection.cpp

示例8: DbReference

DbReference DbConnection::GetInsertID(const DbType::Ptr& type, const DbReference& objid) const
{
	if (!objid.IsValid())
		return DbReference();

	std::map<std::pair<DbType::Ptr, DbReference>, DbReference>::const_iterator it;

	it = m_InsertIDs.find(std::make_pair(type, objid));

	if (it == m_InsertIDs.end())
		return DbReference();

	return it->second;
}
开发者ID:ogg1980,项目名称:icinga2,代码行数:14,代码来源:dbconnection.cpp

示例9: if

bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& value, Value *result)
{
	if (key == "instance_id") {
		*result = static_cast<long>(m_InstanceID);
		return true;
	} else if (key == "session_token") {
		*result = GetSessionToken();
		return true;
	}

	Value rawvalue = DbValue::ExtractValue(value);

	if (rawvalue.IsObjectType<ConfigObject>()) {
		DbObject::Ptr dbobjcol = DbObject::GetOrCreateByObject(rawvalue);

		if (!dbobjcol) {
			*result = 0;
			return true;
		}

		if (!IsIDCacheValid())
			return false;

		DbReference dbrefcol;

		if (DbValue::IsObjectInsertID(value)) {
			dbrefcol = GetInsertID(dbobjcol);

			if (!dbrefcol.IsValid())
				return false;
		} else {
			dbrefcol = GetObjectID(dbobjcol);

			if (!dbrefcol.IsValid()) {
				InternalActivateObject(dbobjcol);

				dbrefcol = GetObjectID(dbobjcol);

				if (!dbrefcol.IsValid())
					return false;
			}
		}

		*result = static_cast<long>(dbrefcol);
	} else if (DbValue::IsTimestamp(value)) {
		long ts = rawvalue;
		std::ostringstream msgbuf;
		msgbuf << "TO_TIMESTAMP(" << ts << ")";
		*result = Value(msgbuf.str());
	} else if (DbValue::IsTimestampNow(value)) {
		*result = "NOW()";
	} else if (DbValue::IsObjectInsertID(value)) {
		long id = static_cast<long>(rawvalue);

		if (id <= 0)
			return false;

		*result = id;
		return true;
	} else {
		Value fvalue;

		if (rawvalue.IsBoolean())
			fvalue = Convert::ToLong(rawvalue);
		else
			fvalue = rawvalue;

		*result = "E'" + Escape(fvalue) + "'";
	}

	return true;
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:72,代码来源:idopgsqlconnection.cpp


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