当前位置: 首页>>代码示例>>C++>>正文


C++ DocumentData::text方法代码示例

本文整理汇总了C++中DocumentData::text方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentData::text方法的具体用法?C++ DocumentData::text怎么用?C++ DocumentData::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentData的用法示例。


在下文中一共展示了DocumentData::text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

/** This method starts by pushing a DocumentData object created from the index
    document to the _documentStack. Then the iteration loop is started which ends
    when all DocumentData objects are popped from the _documentStack. Each
    DocumentData object contains a well-formed XML representaion of the underlying
    input document. Additionally it provides a pointer to the node of the
    application's internal tree structure to which the document will be added to.
    This XML representation is passed to a QDomDocument object which validates it
    and retrieves the root element. Then the _readElement() method processes the
    document with the given root element.
    @author Bjoern
  */
Node* DocumentReader::read(QString indexfilepath,
                           DocumentData::FileType filetype)
{
    if (_translationMapper == 0)
    {
        if (Settings::DEBUG)
            std::cerr << tr("DocumentReader.read() : _translationMapper is 0").toStdString() << std::endl;
        return 0;
    }
    Settings settings;
    _includeSubDocuments = (bool)settings.getValue("includesubdocuments").toInt();
    _fileType = filetype;
    _indexFileInfo = QFileInfo(indexfilepath);
    // start reading the whole document tree
    Node* root = new Node(0, "html", 0);
    // add the index document to the stack of documents
    _documentStack.push(new DocumentData(_indexFileInfo, root, _fileType));
    // begin processing the documents stored on the document stack
    while(!_documentStack.isEmpty())
    {
        DocumentData* documentdata = _documentStack.pop();
        QDomDocument doc;
        QString errorStr = "";
        int errorLine = -1;
        int errorColumn = -1;
        if (doc.setContent(documentdata->text().toLatin1(),
                           false,
                           &errorStr,
                           &errorLine,
                           &errorColumn))
        {
            if (doc.documentElement().tagName().toLower() == "html")
                _readElement(doc.documentElement(), documentdata->node());
            else
            {
                std::cerr << tr("Error in DocumentReader::read()").toStdString()
                        << std::endl << tr("\tat \"if (doc.setContent())\" returned false;").toStdString()
                        << std::endl << tr("\tFile name: ").toStdString()
                        << documentdata->fileInfo().filePath().toStdString()
                        << std::endl << tr("\tError message: <html>-tag not found").toStdString()
                        << std::endl;
            }
        }
        else
        {
            std::cerr << "Error in CDocumentReader::read()"
                    << std::endl << "\tat doc.setContent() returned false;"
                    << std::endl << "\tFile name: "
                    << documentdata->fileInfo().filePath().toStdString()
                    << std::endl << "\tError message: "
                    << std::endl << errorStr.toStdString() << " line="
                    << std::endl << QString::number(errorLine).toStdString()
                    << std::endl << "\tColumn=" << QString::number(errorColumn).toStdString()
                    << std::endl;
        }
        delete documentdata;
    }
    return root;
};
开发者ID:opus4711,项目名称:htmlatex,代码行数:70,代码来源:documentreader.cpp


注:本文中的DocumentData::text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。