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


C++ Ptr::GetVars方法代码示例

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


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

示例1: OnConfigUpdate

void UserDbObject::OnConfigUpdate(void)
{
	Dictionary::Ptr fields = make_shared<Dictionary>();
	User::Ptr user = static_pointer_cast<User>(GetObject());

	/* contact addresses */
	Log(LogDebug, "UserDbObject", "contact addresses for '" + user->GetName() + "'");

	Dictionary::Ptr vars = user->GetVars();

	if (vars) { /* This is sparta. */
		for (int i = 1; i <= 6; i++) {
			String key = "address" + Convert::ToString(i);
			String val = vars->Get(key);

			if (val.IsEmpty())
				continue;

			fields->Set("contact_id", DbValue::FromObjectInsertID(user));
			fields->Set("address_number", i);
			fields->Set("address", val);
			fields->Set("instance_id", 0); /* DbConnection class fills in real ID */

			DbQuery query;
			query.Type = DbQueryInsert;
			query.Table = "contact_addresses";
			query.Fields = fields;
			OnQuery(query);
		}
	}
}
开发者ID:3v,项目名称:icinga2,代码行数:31,代码来源:userdbobject.cpp

示例2: OnConfigUpdateHeavy

void UserDbObject::OnConfigUpdateHeavy(void)
{
	User::Ptr user = static_pointer_cast<User>(GetObject());

	/* groups */
	Array::Ptr groups = user->GetGroups();

	std::vector<DbQuery> queries;

	DbQuery query1;
	query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
	query1.Type = DbQueryDelete;
	query1.Category = DbCatConfig;
	query1.WhereCriteria = new Dictionary();
	query1.WhereCriteria->Set("contact_object_id", user);

	queries.push_back(query1);

	if (groups) {
		ObjectLock olock(groups);
		for (const String& groupName : groups) {
			UserGroup::Ptr group = UserGroup::GetByName(groupName);

			DbQuery query2;
			query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
			query2.Type = DbQueryInsert | DbQueryUpdate;
			query2.Category = DbCatConfig;
			query2.Fields = new Dictionary();
			query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
			query2.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
			query2.Fields->Set("contact_object_id", user);
			query2.WhereCriteria = new Dictionary();
			query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
			query2.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
			query2.WhereCriteria->Set("contact_object_id", user);

			queries.push_back(query2);
		}
	}

	DbObject::OnMultipleQueries(queries);

	queries.clear();

	DbQuery query2;
	query2.Table = "contact_addresses";
	query2.Type = DbQueryDelete;
	query2.Category = DbCatConfig;
	query2.WhereCriteria = new Dictionary();
	query2.WhereCriteria->Set("contact_id", DbValue::FromObjectInsertID(user));

	queries.push_back(query2);

	Dictionary::Ptr vars = user->GetVars();

	if (vars) { /* This is sparta. */
		for (int i = 1; i <= 6; i++) {
			Dictionary::Ptr fields = new Dictionary();

			String key = "address" + Convert::ToString(i);

			if (!vars->Contains(key))
				continue;

			String val = vars->Get(key);

			fields->Set("contact_id", DbValue::FromObjectInsertID(user));
			fields->Set("address_number", i);
			fields->Set("address", val);
			fields->Set("instance_id", 0); /* DbConnection class fills in real ID */

			DbQuery query;
			query.Type = DbQueryInsert;
			query.Table = "contact_addresses";
			query.Category = DbCatConfig;
			query.Fields = fields;

			queries.push_back(query);
		}
	}

	DbObject::OnMultipleQueries(queries);
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:83,代码来源:userdbobject.cpp


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