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


C++ value::clear方法代码示例

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


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

示例1: decode

// ========================================================================
// METHOD ::decode
// ========================================================================
void dbfile::decode (const string &outof, value &v)
{
	value tmp;
	string l, r;
	v.clear ();
	
	switch (encoding)
	{
		case shox:
			v.fromshox (outof);
			break;
		
		case attriblist: // fallthrough to valuelist
		case valuelist:
			v = strutil::splitquoted (outof, sep);
			break;
		
		case courierdb:
			tmp = strutil::split (outof, '|');
			foreach (word, tmp)
			{
				r = word;
				l = r.cutat ('=');
				v[l] = r;
			}
			break;
		
		default:
			v = outof;
			break;
	}
开发者ID:CloudVPS,项目名称:openpanel-grace,代码行数:34,代码来源:dbfile.cpp

示例2: query

bool sqlitehandle::query (const string &sql, value &into,
						  const statstring &indexby)
{
	sqlite3_stmt *qhandle;
	int qres;
	int rowcount=0;
	int colcount;
	int i;
	statstring curidx;
	bool done = false;
	
	into.clear ();
	
	if (sqlite3_prepare (hdl, sql.str(), sql.strlen(), &qhandle, 0) != SQLITE_OK)
	{
		errcode = 1;
		errstr = "Could not prepare: %s" %format (sqlite3_errmsg(hdl));
		return false;
	}
	
	if (! (qres = sqlite3_step (qhandle)))
	{
		errcode = 1;
		errstr = "Error making first step: %s" %format (sqlite3_errmsg(hdl));
		sqlite3_finalize (qhandle);
		return false;
	}
	
	colcount = sqlite3_column_count (qhandle);
	if (colcount == 0)
	{
		into("rowschanged") = sqlite3_changes (hdl);
		sqlite3_finalize (qhandle);
		return true;
	}
	
	statstring colnames[colcount];
	value colidx;
	
	for (i=0; i<colcount; ++i)
	{
		colnames[i] = sqlite3_column_name (qhandle, i);
		colidx[colnames[i]] = i;
	}
	
	int indexfield = -1;
	if (colidx.exists (indexby)) indexfield = colidx[indexby];
	
	if (! done) do
	{
		switch (qres)
		{
			case SQLITE_BUSY:
				sleep (1);
				sqlite3_reset(qhandle);
				continue;
			
			case SQLITE_MISUSE: // achtung, fallthrough
			case SQLITE_ERROR:
				errcode = 1;
				errstr = "Error in sqlite3_step: %s" %format (sqlite3_errmsg(hdl));
				done = true;
				break;

			case SQLITE_DONE:
				done = true;
				break;
				
			case SQLITE_ROW:
				{
					if (indexfield>=0)
					{
						curidx = sqlite3_column_text (qhandle, indexfield);
					}
					
					value &myrow = (indexfield<0) ? into.newval() : into[curidx];
					
					for (int i=0; i<colcount; i++)
					{
						int ctype = sqlite3_column_type (qhandle, i);
						statstring &curcol = colnames[i];
						
						switch (ctype)
						{
							case SQLITE_INTEGER:
								myrow[curcol] = sqlite3_column_int (qhandle, i);
								break;
							
							case SQLITE_FLOAT:
								myrow[curcol] = sqlite3_column_double (qhandle, i);
								break;
							
							case SQLITE_BLOB:
								// FIXME: use sqlite3_column_blob
							case SQLITE_TEXT:
								myrow[curcol] = sqlite3_column_text (qhandle, i);
								break;
							
							default:
								break;
//.........这里部分代码省略.........
开发者ID:CloudVPS,项目名称:openpanel-grace,代码行数:101,代码来源:sqlite.cpp


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