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


C++ DataTable::addRow方法代码示例

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


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

示例1: bind

void IDbResult::bind(DataTable &table)
{
	init(table);
	while(end() == false)
	{
	    DataTableRow row = table.addRow();
		bind(row);
		moveNext();
	}
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例2: razorUpgrade

bool CompatibilityManager::razorUpgrade(const String &folder)
{
	try
	{
		if(FileSystem::instance()->directoryExists(folder))
		{
			StringList portals;
			FileSystem::instance()->getDirectories(folder, portals, false);
			for(StringList::const_iterator i = portals.begin(); i != portals.end(); ++i)
			{
				// 000000018F94C9554C8B227CF000C6E30EB281AEAE1A77E7
				String name = *i;
				if(name.length() == 48)
				{
					// Portal < Razor
					std::string oldID = name.to_ascii();

					// Options
					String oldPath = utils::standardisePath(folder + oldID);
					shared_ptr<PortalOptions> options(OS_NEW PortalOptions());
					// Carica le impostazioni del portale
					if(options->readFromPath(oldPath) == false)
						return false;
					
					shared_ptr<IDbDriver> driver = DatabasesSystem::instance()->getDriver("sqlite");

					// Query Database
					shared_ptr<IDbConnection> connection = driver->createConnection(oldID, driver->createOptions());

					connection->open();
					
					String portalName = options->getName();
					//String portalDescription = static_cast<String>(options->getOptionValue("description"));


					NotificationsManager::instance()->notify(_S("Migration of '") + portalName + _S("' to 1.0 series"));
					PlatformManager::instance()->sleep(500);

					//ObjectID userID = static_cast<String>(m_portalOptions.getOption(options::users_reference)).to_ascii();
					ObjectID userID = static_cast<String>(options->getOptionValue("users.reference")).to_ascii();

					//bool monarchic = (options->getPortalID().getPortalType() == portalTypeMonarchic);
					ID oldPortalID(oldID);
					uint8 portalType = OS_UINT8_LO(oldPortalID.getHeader().getFirst());
					bool monarchic = (portalType == 1);

					// Calcolo UserID.
					// Se non lo posso dedurre, uso il primo che trovo loggato.					
					if(userID.empty())
					{
						if(monarchic)
						{
							//userID = options->getPortalID().getAdministratorID();
#ifdef OS_NOOBJECTID
							userID = oldPortalID.getHash();
#else
							userID = ObjectID::generate(portalObjectTypeUser, oldPortalID.getHash());
#endif
						}
						else
						{
							String sql = String::EMPTY;
							sql += _S(" select tp.profile, tu.reference ");
							sql += _S(" from ");
							sql += _S(" os_snapshot_profiles tp, ");
							sql += _S(" os_snapshot_users tu ");
							sql += _S(" where  ");
							sql += _S(" tp.profile=tu.profile and ");
							sql += _S(" tu.score=1 and ");
							sql += _S(" tu.follow=1 and ");
							sql += _S(" tu.description='Auto valutation'");

							shared_ptr<IDbResult> result = connection->query(sql);
							DataTable table;
							result->init(table);
							DataTableRow row = table.addRow();

							while(result->end() == false)
							{
								result->bind(row);
								String objectID = static_cast<String>(*row[1]);

								userID = objectID.to_ascii();

								result->moveNext();

								break;
							}
						}
					}
					
#ifdef OS_NOOBJECTID
					PovID povID = userID;
#else
					PovID povID = userID.getHash();
#endif
					
					if(userID.empty() == false)
					{
						// Clean old snapshot
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: upgradeContentOML

bool CompatibilityManager::upgradeContentOML(const shared_ptr<IPortalDatabase> &database, const String &tableName, const String& fieldName, bool xmlEncoded)
{
	NotificationsManager::instance()->notify(_S("Migration (OML texts) of '") + database->getPortal()->getName() + _S("' to 1.0 series"));

	DataTable result;
	String sql = _S("select id,") + fieldName + _S(" as oml from ") + tableName;
	//database->execute(sql,result);

	shared_ptr<IDbResult> result2 = database->getConnection()->query(sql);
	result2->init(result);
	DataTableRow row = result.addRow();

	//String patch;

	//for(uint32 r=0;r<result.rows();r++)
	while(result2->end() == false)
	{
		result2->bind(row);

		//String id = result.get(r,_S("id"));
		//String oml = result.get(r,_S("oml"));
		String id = *row[_S("id")];
		String omlOrig = *row[_S("oml")];

		String oldOml = omlOrig;

		// portal=0D2C4E505C1D98B221E222CABE4E167BECB2D669
		
#ifdef OS_NOOBJECTID
		omlOrig = RegexManager::instance()->replace(omlOrig, _S("[0-1][0-9]0[0-1]000[0-4]([0-9A-F]{40})"), _S("$1"), false);
#else
		omlOrig = RegexManager::instance()->replace(omlOrig, _S("[0-1][0-9]0[0-1]000[2-4]([0-9A-F]{40})"), _S("$1"), false);
#endif

		String oml = omlOrig;

		/*
		bool xmlEncoded = false;

		if(oml.starts_with(_S("<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\" ?>")))
		{
			oml = HtmlParser::instance()->decode(omlOrig);
			xmlEncoded = true;
		}*/
		if(xmlEncoded)
			oml = HtmlParser::instance()->decode(omlOrig);

		int nReplace = 0;
		String::size_type lastPosLink = 0;
		for(;;)
		{
			nReplace++;
			String::size_type posLink = oml.find(_S("osiris://"),lastPosLink);
			if(posLink == String::npos)
				break;

			String::size_type posEnd = String::npos;

			{
				String::size_type posEndC = oml.find(_S("\""), posLink+1);
				if( (posEndC != String::npos) && ( (posEndC<posEnd) || (posEnd == String::npos) ) ) posEnd = posEndC;
			}
			{
				String::size_type posEndC = oml.find(_S("'"), posLink+1);
				if( (posEndC != String::npos) && ( (posEndC<posEnd) || (posEnd == String::npos) ) ) posEnd = posEndC;
			}
			{
				String::size_type posEndC = oml.find(_S("["), posLink+1);
				if( (posEndC != String::npos) && ( (posEndC<posEnd) || (posEnd == String::npos) ) ) posEnd = posEndC;
			}
			{
				String::size_type posEndC = oml.find(_S("]"), posLink+1);
				if( (posEndC != String::npos) && ( (posEndC<posEnd) || (posEnd == String::npos) ) ) posEnd = posEndC;
			}

			String linkEx = oml.substr(posLink);

			bool valid = true;
			bool warning = true;

			if(posEnd == String::npos)
				valid = false;
			
			if(valid)
			{			
				String link = oml.substr(posLink, posEnd-posLink);

				if( (link == _S("osiris://")) )
				{
					valid = false;
					warning = false;
				}
				else if( (link == _S("osiris://.")) )
				{
					valid = false;
					warning = false;
				}
				else
				{
					OsirisLink osirisLink(link.to_ascii());
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: executeSqlQuery

	int SqliteClient::executeSqlQuery(const string& sql, DataTable& table)
	{
		Locker locker(&_sqliteDbMutex);

#if DEBUG
		Stopwatch sw("executeSqlQuery", 100);
#endif
		sqlite3_stmt *stmt;
		int result = sqlite3_prepare_v2(_sqliteDb, sql.c_str(),  sql.length(), &stmt, 0);  
		if(result != SQLITE_OK)
		{
			printErrorInfo("sqlite3_prepare_v2", sql);
			return result;
		}

		//const char* name = sqlite3_column_table_name(stmt, 0);
		//table.setName(name != NULL ? name : "temp");
        // todo: linke error for sqlite3_column_table_name.
        table.setName("temp");

#if DEBUG
		sw.setInfo(Convert::convertStr("executeSqlQuery, the table name is '%s'", table.getName().c_str()));
#endif

		int columnCount = sqlite3_column_count(stmt);
		for (int i = 0; i < columnCount; i++)
		{
			char* nameStr = (char*)sqlite3_column_name(stmt, i);
			string name;
			if(nameStr != NULL)
			{
				name = nameStr;
			}
			else
			{
				char temp[32];
				sprintf(temp, "tempCol%d", i);
				name = temp;
			}
			const char* typeStr = sqlite3_column_decltype(stmt, i);
			string type = typeStr != NULL ? typeStr : "int";
			DataColumn* column = new DataColumn(name, type);
			table.addColumn(column);
		}

		while(sqlite3_step(stmt) == SQLITE_ROW)
		{
			DataRow* row = new DataRow();
			for (int i = 0; i < columnCount; i++)
			{
				DataColumn* column = table.getColumns()->at(i);
				DataCell* cell = NULL;
				Value value;
				memset(&value, 0, sizeof(value));
				ValueTypes type = column->getType();
				switch (type)
				{
				case Null:
					break;
				case Integer:
					value.nValue = sqlite3_column_int(stmt, i);
					break;
				case String:
				case DateTime:
					{
						char* str = (char*)sqlite3_column_text(stmt, i);
						DataCell::setStringValue(value, str);
					}
					break;
				case Float:
					value.dValue = sqlite3_column_double(stmt, i);
					break;
				default:
					assert(false);
					break;
				}

				cell = new DataCell(column, value);
				row->addCell(cell);
			}
			table.addRow(row);
		}
		result = sqlite3_finalize(stmt);
		if(result != SQLITE_OK)
		{
			printErrorInfo("sqlite3_finalize", sql);
			return result;
		}

		return SQLITE_OK;
	}
开发者ID:davidbao,项目名称:SmartTimer,代码行数:91,代码来源:SqliteClient.cpp


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