Commit 52f399d5 by Niels

created a header-only version (see issue #16)

parent 2443aa65
.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 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 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_CXXFLAGS = $(FLAGS) -std=c++11
json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public 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_CXXFLAGS = -O3 -std=c++11 -flto
json_parser_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/benchmark json_parser_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/benchmark
...@@ -26,4 +31,9 @@ pretty: ...@@ -26,4 +31,9 @@ pretty:
$(SOURCES) $(SOURCES)
parser: parser:
make CXXFLAGS="" json_parser make CXXFLAGS="" json_parser
\ No newline at end of file
header_only/json.h: $(CORE_SOURCES)
cat $(CORE_SOURCES) | $(SED) 's/#include "json.h"//' > header_only/json.h
BUILT_SOURCES = header_only/json.h
...@@ -26,7 +26,7 @@ Other aspects were not so important to us: ...@@ -26,7 +26,7 @@ Other aspects were not so important to us:
## Integration ## 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 ```cpp
#include "json.h" #include "json.h"
...@@ -37,6 +37,8 @@ using json = nlohmann::json; ...@@ -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). 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 ## Examples
Here are some examples to give you an idea how to use the class. Here are some examples to give you an idea how to use the class.
......
...@@ -5,6 +5,7 @@ AM_INIT_AUTOMAKE([foreign subdir-objects]) ...@@ -5,6 +5,7 @@ AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_PROG_CXX AC_PROG_CXX
AC_PROG_SED
AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(Makefile)
AC_OUTPUT AC_OUTPUT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment