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


C++ ParserResult::emit方法代码示例

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


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

示例1: tmpfile

SAWYER_EXPORT std::string
PodFormatter::toNroff(const ParserResult &parsed) {
    // Generate POD documentation into a temporary file
    TempFile tmpfile(tempFileName(".pod"));
    parsed.emit(tmpfile.stream, sharedFromThis());
    tmpfile.stream.close();

    std::string cmd = "pod2man"
                      " --center='" + escapeSingleQuoted(chapterName_) + "'"
                      " --date='" + escapeSingleQuoted(dateString_) + "'"
                      " --name='" + escapeSingleQuoted(pageName_) + "'"
                      " --release='" + escapeSingleQuoted(versionString_) + "'"
                      " --section='" + escapeSingleQuoted(chapterNumber_) + "'"
                      " " + tmpfile.name;

    FILE *f = popen(cmd.c_str(), "r");
    if (!f) {
#include <Sawyer/WarningsOff.h>                         // suppress strerror unsafe warning from Microsoft C++
        throw std::runtime_error(std::string("cannot run command: ") + strerror(errno) + "\ncommand: " + cmd);
#include <Sawyer/WarningsRestore.h>
    }
    
    std::string result;
    while (1) {
        std::string line = readOneLine(f);
        if (line.empty())
            break;
        result += line;
    }

    if (-1 == Sawyer::pclose(f))
        throw std::runtime_error("command failed: " + cmd);

    return result;
}
开发者ID:GoblinInventor,项目名称:rose-develop,代码行数:35,代码来源:MarkupPod.C

示例2: tmpdir

SAWYER_EXPORT void
PodFormatter::emit(const ParserResult &parsed) {
    // Generate POD documentation into a temporary file.  Since perldoc doesn't support the "name" property, but rather
    // uses the file name, we create a temporary directory and place a POD file inside with the name we want.
    TempDir tmpdir(tempFileName());
    std::string fileName = tmpdir.name + pageName_ + ".pod";
    {
        std::ofstream stream(fileName.c_str());
        parsed.emit(stream, sharedFromThis());
    }

    std::string cmd = "perldoc "
                      " -o man"
                      " -w 'center:" + escapeSingleQuoted(chapterName_) + "'"
                      " -w 'date:" + escapeSingleQuoted(dateString_) + "'"
                      // " -w 'name:" + escapeSingleQuoted(pageName_) + "'"
                      " -w 'release:" + escapeSingleQuoted(versionString_) + "'"
                      " -w 'section:" + escapeSingleQuoted(chapterNumber_) + "'"
                      " " + fileName;
    system(cmd.c_str());
}
开发者ID:GoblinInventor,项目名称:rose-develop,代码行数:21,代码来源:MarkupPod.C


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