本文整理汇总了C++中leveldb::Status::ok方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::ok方法的具体用法?C++ Status::ok怎么用?C++ Status::ok使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leveldb::Status
的用法示例。
在下文中一共展示了Status::ok方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleError
void HandleError(const leveldb::Status& status) throw(leveldb_error)
{
if (status.ok())
return;
LogPrintf("%s\n", status.ToString());
if (status.IsCorruption())
throw leveldb_error("Database corrupted");
if (status.IsIOError())
throw leveldb_error("Database I/O error");
if (status.IsNotFound())
throw leveldb_error("Database entry missing");
throw leveldb_error("Unknown database error");
}
示例2: get
bool LevelDBDatabase::get(const LevelDBSlice& key, Vector<char>& value)
{
std::string result;
leveldb::ReadOptions readOptions;
readOptions.verify_checksums = true; // FIXME: Disable this if the performance impact is too great.
const leveldb::Status s = m_db->Get(readOptions, makeSlice(key), &result);
if (s.ok()) {
value = makeVector(result);
return true;
}
if (s.IsNotFound())
return false;
LOG_ERROR("LevelDB get failed: %s", s.ToString().c_str());
return false;
}
示例3: checkDbError
void LevelDB::checkDbError(leveldb::Status aStatus) throw(DbException) {
if (aStatus.ok())
return;
if (aStatus.IsNotFound())
return;
string ret = Text::toUtf8(aStatus.ToString());
#ifdef _WIN32
if (aStatus.IsCorruption() || aStatus.IsIOError()) {
if (ret.back() != '.')
ret += ".";
ret += " " + STRING_F(DB_ERROR_HINT, STRING(HASHING));
}
#endif
throw DbException(ret);
}
示例4: CheckStatus
bool CheckStatus(leveldb::Status& status) {
if (!status.ok()) {
std::cerr << status.ToString() << std::endl;
}
return status.ok();
}
示例5: adoptPtr
PassOwnPtr<LevelDBDatabase> LevelDBDatabase::open(const String& fileName, const LevelDBComparator* comparator)
{
OwnPtr<ComparatorAdapter> comparatorAdapter = adoptPtr(new ComparatorAdapter(comparator));
leveldb::Options options;
options.comparator = comparatorAdapter.get();
options.create_if_missing = true;
options.paranoid_checks = true;
leveldb::DB* db;
const leveldb::Status s = leveldb::DB::Open(options, fileName.utf8().data(), &db);
if (!s.ok()) {
LOG_ERROR("Failed to open LevelDB database from %s: %s", fileName.ascii().data(), s.ToString().c_str());
return nullptr;
}
OwnPtr<LevelDBDatabase> result = adoptPtr(new LevelDBDatabase);
result->m_db = adoptPtr(db);
result->m_comparatorAdapter = comparatorAdapter.release();
result->m_comparator = comparator;
return result.release();
}