本文整理汇总了C++中StringPimpl::startsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ StringPimpl::startsWith方法的具体用法?C++ StringPimpl::startsWith怎么用?C++ StringPimpl::startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringPimpl
的用法示例。
在下文中一共展示了StringPimpl::startsWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: deleteRecordRange
void DatabaseManager::deleteRecordRange(const StringPimpl &key)
{
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)) {
//We are at the end of the range
break;
}
cursor->del(0);
ret = cursor->get(&dbKey, &dbData, DB_NEXT);
}
cursor->close();
}
catch (DbException &e)
{
std::cerr << "Error in deleteRecordRange: "
<< e.what() << e.get_errno() << std::endl;
if(cursor != NULL)
{
cursor->close();
}
}
}