Allowed automerge

This commit is contained in:
Raphael Isemann 2015-01-10 17:33:18 +01:00
commit 6105ce5484
5 changed files with 2732 additions and 6 deletions

View file

@ -1,12 +1,17 @@
.PHONY: header_only
# the order is important: header before other sources
CORE_SOURCES = src/json.h src/json.cc
noinst_PROGRAMS = json_unit json_parser
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder
json_unit_SOURCES = src/json.cc src/json.h test/catch.hpp test/json_unit.cc
json_unit_SOURCES = $(CORE_SOURCES) test/catch.hpp test/json_unit.cc
json_unit_CXXFLAGS = $(FLAGS) -std=c++11
json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public
json_parser_SOURCES = src/json.cc src/json.h benchmark/parse.cc
json_parser_SOURCES = $(CORE_SOURCES) benchmark/parse.cc
json_parser_CXXFLAGS = -O3 -std=c++11 -flto
json_parser_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/benchmark
@ -26,4 +31,9 @@ pretty:
$(SOURCES)
parser:
make CXXFLAGS="" json_parser
make CXXFLAGS="" json_parser
header_only/json.h: $(CORE_SOURCES)
cat $(CORE_SOURCES) | $(SED) 's/#include "json.h"//' > header_only/json.h
BUILT_SOURCES = header_only/json.h

View file

@ -26,7 +26,7 @@ Other aspects were not so important to us:
## Integration
All you need to do is add
The two required source files are in the `src` directory. All you need to do is add
```cpp
#include "json.h"
@ -37,6 +37,8 @@ using json = nlohmann::json;
to the files you want to use JSON objects. Furthermore, you need to compile the file `json.cc` and link it to your binaries. Do not forget to set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
If you want a single header file, use the `json.h` file from the `header_only` directory.
## Examples
Here are some examples to give you an idea how to use the class.
@ -254,6 +256,16 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Thanks
I deeply appreciate the help of the following people.
- [Teemperor](https://github.com/Teemperor) implemented CMake support and lcov integration and realized escape handling in the string parser.
- [elliotgoodrich](https://github.com/elliotgoodrich) fixed an issue with double deletion in the iterator classes.
- [kirkshoop](https://github.com/kirkshoop) made the iterators of the class composable to other libraries.
Thanks a lot for helping out!
## Execute unit tests with CMake
To compile and run the tests, you need to execute
@ -289,7 +301,7 @@ The unit tests can then be executed with
$ ./json_unit
===============================================================================
All tests passed (863 assertions in 10 test cases)
All tests passed (887 assertions in 10 test cases)
```
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).

View file

@ -5,6 +5,7 @@ AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_PROG_CXX
AC_PROG_SED
AC_CONFIG_FILES(Makefile)
AC_OUTPUT

2701
header_only/json.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -2039,6 +2039,9 @@ Parses a string after opening quotes (\p ") where read.
@post The character after the closing quote \p " is the current character @ref
current_. Whitespace is skipped.
@todo Unicode escapes such as \uxxxx are missing - see
https://github.com/nlohmann/json/issues/12
*/
std::string json::parser::parseString()
{
@ -2106,7 +2109,6 @@ std::string json::parser::parseString()
{
// currentChar is a quote, so we found the end of the string
// set pos_ behind the trailing quote
pos_++;
// find next char to parse