本文整理汇总了C++中Doc::source方法的典型用法代码示例。如果您正苦于以下问题:C++ Doc::source方法的具体用法?C++ Doc::source怎么用?C++ Doc::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc::source方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setQuickDoc
void QsCodeParser::setQuickDoc(Node *quickNode,
const Doc& doc,
const QStringList& qtParams,
const QStringList& quickParams)
{
QRegExp quickifyCommand("\\\\" + COMMAND_QUICKIFY + "([^\n]*)(?:\n|$)");
if (quickNode->type() == Node::Function) {
FunctionNode *quickFunc = (FunctionNode *) quickNode;
quickFunc->setOverload(false);
}
if (doc.metaCommandsUsed().contains(COMMAND_QUICKIFY)) {
QString source = doc.source();
int pos = source.indexOf(quickifyCommand);
if (pos != -1) {
QString quickifiedSource = quickNode->doc().source();
if (!qtParams.isEmpty() && qtParams != quickParams)
renameParameters(quickifiedSource, doc, qtParams,
quickParams);
applyReplacementList(quickifiedSource, doc);
do {
QString extract = quickifiedSource;
QString arg = quickifyCommand.cap(1).simplified();
if (!arg.isEmpty()) {
if (arg.startsWith("/") && arg.endsWith("/") &&
arg.length() > 2) {
QString pattern = arg.mid(1, arg.length() - 2);
extractRegExp(QRegExp(pattern), extract, doc);
}
else {
extractTarget(arg, extract, doc);
}
}
source.replace(pos, quickifyCommand.matchedLength(), extract);
pos += extract.length();
} while ((pos = source.indexOf(quickifyCommand, pos)) != -1);
QRegExp quickcodeRegExp(
"\\\\" + COMMAND_QUICKCODE + "(.*)\\\\" +
COMMAND_ENDQUICKCODE);
quickcodeRegExp.setMinimal(true);
source.replace(quickcodeRegExp, "");
}
Doc quickDoc(doc.location(),
doc.location(),
source,
(CppCodeParser::topicCommands() + topicCommands() +
CppCodeParser::otherMetaCommands()) << COMMAND_REPLACE);
quickNode->setDoc(quickDoc, true);
processOtherMetaCommands(quickDoc, quickNode);
}
else {
quickNode->setDoc(doc, true);
processOtherMetaCommands(doc, quickNode);
}
}
示例2: setQtDoc
void QsCodeParser::setQtDoc(Node *quickNode, const Doc& doc)
{
if (!doc.isEmpty()) {
Doc quickDoc(doc.location(), doc.location(),
quickifiedDoc(doc.source()),
CppCodeParser::topicCommands() +
CppCodeParser::otherMetaCommands());
quickNode->setDoc(quickDoc, true);
}
}
示例3: applyReplacementList
void QsCodeParser::applyReplacementList(QString& source, const Doc& doc)
{
QStringList args = doc.metaCommandArgs(COMMAND_REPLACE);
QStringList::ConstIterator a = args.begin();
while (a != args.end()) {
if (replaceRegExp.exactMatch(*a)) {
QRegExp before(replaceRegExp.cap(1));
before.setMinimal(true);
QString after = replaceRegExp.cap(2);
if (before.isValid()) {
int oldLen = source.size();
source.replace(before, after);
// this condition is sufficient but not necessary
if (oldLen == source.size() && !source.contains(after))
doc.location().warning(
tr("Regular expression '%1' did not match anything")
.arg(before.pattern()));
}
else {
doc.location().warning(
tr("Invalid regular expression '%1'")
.arg(before.pattern()));
}
}
else {
doc.location().warning(tr("Bad syntax in '\\%1'")
.arg(COMMAND_REPLACE));
}
++a;
}
QRegExp codeRegExp("\\\\" + COMMAND_CODE + "(.*)\\\\" + COMMAND_ENDCODE);
codeRegExp.setMinimal(true);
QRegExp quickcodeRegExp(
"\\\\" + COMMAND_QUICKCODE + "(.*)\\\\" + COMMAND_ENDQUICKCODE);
quickcodeRegExp.setMinimal(true);
int quickcodePos = doc.source().indexOf(quickcodeRegExp);
if (quickcodePos != -1) {
int codePos = source.indexOf(codeRegExp);
if (codePos == -1) {
doc.location().warning(
tr("Cannot find any '\\%1' snippet corresponding to '\\%2'")
.arg(COMMAND_CODE).arg(COMMAND_QUICKCODE));
}
else {
source.replace(codeRegExp.pos(1), codeRegExp.cap(1).length(),
quickcodeRegExp.cap(1));
codePos = codeRegExp.pos(1) + quickcodeRegExp.cap(1).length();
if (doc.source().indexOf(quickcodeRegExp, quickcodePos + 1) != -1) {
doc.location().warning(
tr("Cannot use '\\%1' twice in a row")
.arg(COMMAND_QUICKCODE));
}
else if (source.indexOf(codeRegExp, codePos + 1) != -1) {
doc.location().warning(tr("Ambiguous '\\%1'")
.arg(COMMAND_QUICKCODE));
}
}
}
}