Skip to content

Commit c4e8ed5

Browse files
committed
Add support for QJsonDocument, from Qt 5.0. Use QTDIR=/path/to/qt on bjam command line to add it to targets.
1 parent c684c4a commit c4e8ed5

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

Jamroot

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ if $(JSON_SPIRIT_ROOT)
2424

2525
local RAPIDJSON_ROOT = [ os.environ RAPIDJSON_ROOT ] ;
2626

27+
local QT_ROOT = [ os.environ QTDIR ] ;
28+
if $(QT_ROOT)
29+
{
30+
using qt5 : $(QT_ROOT) ;
31+
}
32+
2733
# Declare targets for dependencies
2834
lib jsoncpplib : : <name>jsoncpp : : <include>/usr/include/jsoncpp ;
2935

@@ -52,6 +58,11 @@ bexe benchmark_spirit.cpp /json_spirit//json ;
5258
bexe benchmark_rapidjson.cpp : <include>$(RAPIDJSON_ROOT)/include ;
5359
bexe benchmark_jsoncpp.cpp jsoncpplib ;
5460

61+
if $(QT_ROOT)
62+
{
63+
exe benchmark_qjsondoc : benchmark_qjsondoc.cpp /qt5//QtCore ;
64+
}
65+
5566
# TODO: find out how to run all programs after build
5667
#actions run-benchmark { $(>[1]) ; }
5768
#notfile benchmark_rapidjson-run : @run-benchmark : benchmark_rapidjson ;

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ List of currently measured libraries:
1010
* [jsoncpp](http://jsoncpp.sourceforge.net/)
1111
* [libjson](http://sourceforge.net/projects/libjson/)
1212
* [rapidjson](http://code.google.com/p/rapidjson/)
13+
* [QJsonDocument](http://qt-project.org/doc/qt-5.0/qtcore/qjsondocument.html)
1314

1415
Disclaimer
1516
----------

benchmark_qjsondoc.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Copyright (C) 2013 Jeff Trull <[email protected]>
3+
//
4+
// Distributed under the Boost Software License, Version 1.0.
5+
// (See accompanying file LICENSE_1_0.txt or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
9+
10+
#include "json_benchmark.hpp"
11+
12+
#include <QJsonDocument>
13+
14+
15+
int main() {
16+
try
17+
{
18+
jsonbench::run_benchmark("QJsonDocument", [](std::string const& s) {
19+
QJsonParseError err;
20+
return !QJsonDocument::fromJson(s.c_str(), &err).isNull() && (err.error == QJsonParseError::NoError);
21+
});
22+
23+
return EXIT_SUCCESS;
24+
}
25+
catch (std::exception const& e)
26+
{
27+
std::cerr << e.what() <<std::endl;
28+
}
29+
return EXIT_FAILURE;
30+
31+
}
32+

0 commit comments

Comments
 (0)