本文整理汇总了C++中Environment::childTransaction方法的典型用法代码示例。如果您正苦于以下问题:C++ Environment::childTransaction方法的具体用法?C++ Environment::childTransaction怎么用?C++ Environment::childTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::childTransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void DeleteDocumentCommand::execute(Args &args, Environment &env)
{
if(args.size() != 2) {
throw CommandException("Wrong number of arguments");
}
env.testContainer();
if(env.txn()) {
XmlTransaction myTxn = env.childTransaction();
env.container()->deleteDocument(myTxn, args[1], env.uc());
myTxn.commit();
} else {
env.container()->deleteDocument(args[1], env.uc());
}
if(env.verbose()) cout << "Document deleted, name = " << args[1] << endl;
}
示例2: execute
void DeleteIndexCommand::execute(Args &args, Environment &env)
{
if(args.size() != 2 && args.size() != 4) {
throw CommandException("Wrong number of arguments");
}
env.testContainer();
if(env.verbose()) {
if(args.size() == 2) cout << "Deleting default index type: " << args[1] << endl;
else cout << "Deleting index type: " << args[3] << " from node: {" << args[1] << "}:" << args[2] << endl;
}
if(env.txn()) {
XmlTransaction myTxn = env.childTransaction();
if(args.size() == 2) env.container()->deleteDefaultIndex(myTxn, args[1], env.uc());
else env.container()->deleteIndex(myTxn, args[1], args[2], args[3], env.uc());
myTxn.commit();
} else {
if(args.size() == 2) env.container()->deleteDefaultIndex(args[1], env.uc());
else env.container()->deleteIndex(args[1], args[2], args[3], env.uc());
}
}
示例3: execute
void AddDocumentCommand::execute(Args &args, Environment &env)
{
if ((args.size() < 3) || (args.size() > 4)){
throw CommandException("Wrong number of arguments");
}
env.testContainer();
env.deleteResults();
if ((args.size() == 4) && (args[3] == "q")) {
if(env.txn()) {
XmlTransaction myTxn = env.childTransaction();
env.results() = new XmlResults(
env.db().query(myTxn, args[2], env.context()));
XmlValue value;
while(env.results()->next(value)) {
string v = value.asString();
string name = env.container()->
putDocument(myTxn, args[1], v, env.uc(),
DBXML_GEN_NAME);
if(env.verbose())
cout << "Document added, name = " << name << endl;
}
myTxn.commit();
} else {
env.results() = new XmlResults(env.db().query(args[2],
env.context()));
XmlValue value;
while(env.results()->next(value)) {
string v = value.asString();
string name = env.container()->
putDocument(args[1], v, env.uc(), DBXML_GEN_NAME);
if(env.verbose())
cout << "Document added, name = " << name << endl;
}
}
} else {
// by string or by file
bool byString = true;
if (args.size() == 4 && args[3] == "f")
byString = false;
XmlDocument doc = env.db().createDocument();
doc.setName(args[1]);
if (byString)
doc.setContent(args[2]);
else {
XmlInputStream *is = env.db().createLocalFileInputStream(args[2]);
doc.setContentAsXmlInputStream(is);
}
if(env.txn()) {
XmlTransaction myTxn = env.childTransaction();
env.container()->putDocument(myTxn, doc, env.uc());
myTxn.commit();
} else {
env.container()->putDocument(doc, env.uc());
}
// put doc content in last results
XmlResults res = env.db().createResults();
res.add(XmlValue(doc));
env.results() = new XmlResults(res);
if(env.verbose())
cout << "Document added, name = " << args[1] << endl;
}
}