本文整理汇总了C++中Folder::findSubfolder方法的典型用法代码示例。如果您正苦于以下问题:C++ Folder::findSubfolder方法的具体用法?C++ Folder::findSubfolder怎么用?C++ Folder::findSubfolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::findSubfolder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/**
* \brief Look up the column specified by path.
*
* Path can be either relative to the current context (e.g., simply the name of
* a column in the
* current table) or absolute (relative to the project root). For backwards
* compatibility, also
* "table/column" is supported, where "table" is searched for anywhere in the
* project. This
* shouldn't be used in new projects though, since it will be problematic once
* we drop the
* requirement of project-wide unique table names.
*
* Also, it's possible to escape /'s in the path using \\. Column and folder
* names can already
* contain slashes and table names will follow in a future release.
*/
Column *MuParserScript::resolveColumnPath(const QString &path) {
Column *result = 0;
// Split path into components.
// While escape handling would be possible using a regular expression, it
// would require
// lookbehind assertions, which are currently not supported by QRegExp. Thus,
// we can't simply
// use QString::split() and have to explicitly loop over the characters in
// path.
QStringList pathComponents;
QString current;
for (int i = 0; i < path.size(); ++i) switch (path.at(i).toAscii()) {
case '/':
pathComponents << current;
current.clear();
break;
case '\\':
if (i + 1 < path.size()) current.append(path.at(++i));
break;
default:
current.append(path.at(i));
break;
}
QString columnName = current;
Table *table = 0;
if (pathComponents.isEmpty()) {
// only column name specified, read from this table
table = qobject_cast<Table *>(Context);
if (!table)
throw mu::Parser::exception_type(qPrintable(tr(
"Accessing table values is not (yet) supported in this context.")));
} else {
// look up the table containing the column
MyWidget *myContext = qobject_cast<MyWidget *>(Context);
if (!myContext)
throw mu::Parser::exception_type(qPrintable(tr(
"Accessing table values is not (yet) supported in this context.")));
QString tableName = pathComponents.takeLast();
if (pathComponents.isEmpty())
// needed for backwards compatibility, but will be problematic once we
// drop the requirement
// of project-wide unique object names
table = myContext->folder()->rootFolder()->table(tableName, true);
else {
Folder *folder;
if (pathComponents.at(0).isEmpty())
// absolute path
folder = myContext->folder()->rootFolder();
else if (pathComponents.at(0) == "..")
// relative path
folder = myContext->folder();
else
// invalid path
throw mu::Parser::exception_type(
qPrintable(tr("Couldn't find a table named %1.")
.arg(pathComponents.join("/") + "/" + tableName)));
pathComponents.removeFirst();
foreach (QString f, pathComponents) {
if (f == "..")
folder = qobject_cast<Folder *>(folder->parent());
else
folder = folder->findSubfolder(f);
if (!folder)
throw mu::Parser::exception_type(
qPrintable(tr("Couldn't find a table named %1.")
.arg(pathComponents.join("/") + "/" + tableName)));
}
table = folder->table(tableName);
}
if (!table)
throw mu::Parser::exception_type(
qPrintable(tr("Couldn't find a table named %1.")
.arg(pathComponents.join("/") + "/" + tableName)));
}
// finally, look up the column in the table
result = table->d_future_table->column(columnName, false);
if (!result)
throw mu::Parser::exception_type(
qPrintable(tr("There's no column named %1 in table %2!")
.arg(columnName)
//.........这里部分代码省略.........