本文整理汇总了C++中ContainerConfig::getReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerConfig::getReadOnly方法的具体用法?C++ ContainerConfig::getReadOnly怎么用?C++ ContainerConfig::getReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerConfig
的用法示例。
在下文中一共展示了ContainerConfig::getReadOnly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmlException
DictionaryDatabase::DictionaryDatabase(DB_ENV *env, Transaction *txn,
const std::string &name,
const ContainerConfig &config,
bool useMutex)
: stringCache_(true),
environment_(env),
name_(name),
primary_(new PrimaryDatabase(env, name,
dictionary_name,
DEFAULT_CONFIG)),
secondary_(new SecondaryDatabase(env, name,
dictionary_name,
DEFAULT_CONFIG)),
nidName_(0),
nidRoot_(0),
usePreloads_(false),
isTransacted_(txn ? true : false),
mutex_(useMutex ? MutexLock::createMutex() : 0)
{
cache_.setDictionaryDatabase(this);
if (!isTransacted_ && env) {
u_int32_t envFlags;
env->get_flags(env, &envFlags);
if (envFlags & DB_CDB_ALLDB)
isTransacted_ = true;
}
int err = 0;
try {
// set cache sizes low if no DB_ENV -- this is the in-memory
// dictionary for transient docs
if (!env) {
primary_->getDb()->set_cachesize(primary_->getDb(), 0, dictCacheBytes, 1);
secondary_->getDb()->set_cachesize(secondary_->getDb(), 0, dictCacheBytes, 1);
}
// Open the Db objects
err = primary_->open(txn, config);
if (err == 0)
err = secondary_->open(txn, /*duplicates*/true, config);
if (err == 0) {
// Lookup/Define the dbxml namespace names (but don't define
// if this is a read-only container)
bool rdonly = config.getReadOnly();
preloadDictionary(txn, rdonly);
}
} catch (XmlException &) {
secondary_->cleanup();
primary_->cleanup();
if (txn)
txn->abort();
throw;
}
if (err != 0) {
secondary_->cleanup();
primary_->cleanup();
if (txn)
txn->abort();
string msg = name;
if (err == EEXIST) {
msg += ": container exists";
throw XmlException(
XmlException::CONTAINER_EXISTS, msg);
} else if (err == ENOENT) {
msg += ": container file not found, or not a container";
throw XmlException(XmlException::CONTAINER_NOT_FOUND,
msg);
}
throw XmlException(err);
}
}