本文整理汇总了C++中qjson::Parser::allowSpecialNumbers方法的典型用法代码示例。如果您正苦于以下问题:C++ Parser::allowSpecialNumbers方法的具体用法?C++ Parser::allowSpecialNumbers怎么用?C++ Parser::allowSpecialNumbers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qjson::Parser
的用法示例。
在下文中一共展示了Parser::allowSpecialNumbers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
QProcess process;
process.start(prog, arguments, QIODevice::ReadOnly);
if (!process.waitForStarted(-1)) {
emit finished(QLatin1String("Could not start process"));
return;
}
/*
* Process standard output
*/
QList<QImage> thumbnails;
QVariantMap parsedJson;
trace::Profile* profile = NULL;
process.setReadChannel(QProcess::StandardOutput);
if (process.waitForReadyRead(-1)) {
BlockingIODevice io(&process);
if (m_captureState) {
/*
* Parse JSON from the output.
*
* XXX: QJSON's scanner is inneficient as it abuses single
* character QIODevice::peek (not cheap), instead of maintaining a
* lookahead character on its own.
*/
bool ok = false;
QJson::Parser jsonParser;
// Allow Nan/Infinity
jsonParser.allowSpecialNumbers(true);
#if 0
parsedJson = jsonParser.parse(&io, &ok).toMap();
#else
/*
* XXX: QJSON expects blocking IO, and it looks like
* BlockingIODevice does not work reliably in all cases.
*/
process.waitForFinished(-1);
parsedJson = jsonParser.parse(&process, &ok).toMap();
#endif
if (!ok) {
msg = QLatin1String("failed to parse JSON");
}
} else if (m_captureThumbnails) {
/*
* Parse concatenated PNM images from output.
*/
while (!io.atEnd()) {
unsigned channels = 0;
unsigned width = 0;
unsigned height = 0;
char header[512];
qint64 headerSize = 0;
int headerLines = 3; // assume no optional comment line
for (int headerLine = 0; headerLine < headerLines; ++headerLine) {
qint64 headerRead = io.readLine(&header[headerSize], sizeof(header) - headerSize);
// if header actually contains optional comment line, ...
if (headerLine == 1 && header[headerSize] == '#') {