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


C++ StringPimpl::size方法代码示例

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


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

示例1: deleteRecordRange

void DatabaseManager::deleteRecordRange(const StringPimpl &key,
										const StringPimpl &range)
{
	Dbc *cursor = NULL;

	try 
	{
		Dbt dbKey((void *)key.c_str(), key.size() + 1);
		Dbt dbData((void *) range.c_str(), range.size() + 1);

		m_pimpl->checkTSSInit();
		m_pimpl->m_database->cursor(&(**m_pimpl->m_transaction), &cursor, m_pimpl->m_cursorFlags);
		int ret = cursor->get(&dbKey, &dbData, DB_GET_BOTH_RANGE);
		
		while(ret != DB_NOTFOUND)
		{
			cursor->del(0);
			ret = cursor->get(&dbKey, &dbData, DB_NEXT);
		}
		cursor->close();
	}
	catch (DbException &e) 
	{
            std::cerr << "Error in addRecord: "
                       << e.what() << e.get_errno() << std::endl;
			if(cursor != NULL)
			{
				cursor->close();
			}
    }
}
开发者ID:Tiger66639,项目名称:librebecca,代码行数:31,代码来源:DatabaseManager.cpp

示例2: getRecord

bool DatabaseManager::getRecord(const StringPimpl &key, 
                                StringPimpl &data,
								bool caseSensitive)
{
	Dbt dbKey, dbData;
	StringPimpl caseInsensitive;
	if(!caseSensitive)
	{
		caseInsensitive = key;
		caseInsensitive.transformToUpperCase();
		dbKey.set_data((void *)caseInsensitive.c_str());
		dbKey.set_size((caseInsensitive.size() + 1) * sizeof(char));
	}
	else
	{
		dbKey.set_data((void *)key.c_str());
		dbKey.set_size((key.size() + 1) * sizeof(char));
	}

	Dbc *cursor = NULL;

	try
	{
		m_pimpl->checkTSSInit();
		m_pimpl->m_database->cursor(&(**m_pimpl->m_transaction), &cursor, m_pimpl->m_cursorFlags);
		int ret = cursor->get(&dbKey, &dbData, DB_SET);
		cursor->close();
		if(ret != DB_NOTFOUND)
		{
			data = StringPimpl((char *) dbData.get_data());
			return true;
		}
		else
		{
			return false;
		}
	}
	catch (DbException &e) 
	{
        std::cerr << "Error in getDatabaseRecord transaction: "
                   << e.what() << e.get_errno() << std::endl;
		if(cursor != NULL)
		{
			cursor->close();
		}
		return false;
    }
}
开发者ID:Tiger66639,项目名称:librebecca,代码行数:48,代码来源:DatabaseManager.cpp

示例3: recordExists

bool DatabaseManager::recordExists(const StringPimpl &key)
{
	Dbt dbKey, dbData;
	dbKey.set_data((void *)key.c_str());
	dbKey.set_size((key.size() + 1) * sizeof(char));
	Dbc *cursor = NULL;

	try
	{
		m_pimpl->checkTSSInit();
		m_pimpl->m_database->cursor(&(**m_pimpl->m_transaction), &cursor, m_pimpl->m_cursorFlags);
		int ret = cursor->get(&dbKey, &dbData, DB_SET);
		cursor->close();
		if(ret != DB_NOTFOUND)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	catch (DbException &e) 
	{
        std::cerr << "Error in databse recordExists"
			<< e.what() << e.get_errno() <<  std::endl;
		if(cursor != NULL)
		{
			cursor->close();
		}
		return false;
    }
}
开发者ID:Tiger66639,项目名称:librebecca,代码行数:33,代码来源:DatabaseManager.cpp

示例4: addRecord

void DatabaseManager::addRecord(const StringPimpl &key,
								const StringPimpl &value)
{
	//Set up the key
	Dbt dbKey;
	dbKey.set_data((void *)key.c_str());
	dbKey.set_size((key.size() + 1) * sizeof(char));

	//Set up the data to insert
	Dbt dbData;
	dbData.set_data((void *)value.c_str());
	dbData.set_size((value.size() + 1) * sizeof(char));
	
	try 
	{
		m_pimpl->checkTSSInit();
		int ret = m_pimpl->m_database->put(&(**m_pimpl->m_transaction), &dbKey, &dbData, 0);
	}
	catch (DbException &e) 
	{
            std::cerr << "Error in addRecord: "
                       << e.what() << e.get_errno() << std::endl;
    }
}
开发者ID:Tiger66639,项目名称:librebecca,代码行数:24,代码来源:DatabaseManager.cpp

示例5: recordRangeExists

bool DatabaseManager::recordRangeExists(const StringPimpl &key)
{
	//Go through the range of the existence keys and 
	//add them to the list
	Dbc *cursor = NULL;
	try 
	{
		Dbt dbKey((void *)key.c_str(), key.size() + 1);
		Dbt dbData;

		m_pimpl->checkTSSInit();
		m_pimpl->m_database->cursor(&(**m_pimpl->m_transaction), &cursor, m_pimpl->m_cursorFlags);
		int ret = cursor->get(&dbKey, &dbData, DB_SET_RANGE);
		while(ret != DB_NOTFOUND)
		{
			StringPimpl dataString = StringPimpl((char *) dbData.get_data());
			StringPimpl keyString = StringPimpl((char *) dbKey.get_data());
			if(!keyString.startsWith(key) || keyString == key) {
				//We are at the end of the range
				break;
			}
			else 
			{
				cursor->close();
				return true;
			}
		}
		cursor->close();
		return false;
	}
	catch (DbException &e) 
	{
		std::cerr << "Error in deleteRecordRange: "
				   << e.what() << e.get_errno() << std::endl;
		if(cursor != NULL)
		{
			cursor->close();
		}
		return false;
	}
}
开发者ID:Tiger66639,项目名称:librebecca,代码行数:41,代码来源:DatabaseManager.cpp


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