本文整理汇总了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;
}
示例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());
}