From 5ae2babf616ef0e49e9dd9e829ef1f009b362b2d Mon Sep 17 00:00:00 2001 From: Niels Date: Mon, 29 Jun 2015 23:02:41 +0200 Subject: [PATCH] add online examples --- README.md | 1 + doc/Doxyfile | 2 +- doc/Makefile | 11 ++ doc/examples/README.cpp | 31 +++++ doc/examples/README.link | 1 + doc/examples/array.link | 1 + doc/examples/at__object_t_key_type.link | 1 + doc/examples/at__object_t_key_type_const.link | 1 + doc/examples/at__size_type.link | 1 + doc/examples/at__size_type_const.link | 1 + doc/examples/back.link | 1 + doc/examples/basic_json.link | 1 + .../basic_json__CompatibleArrayType.link | 1 + ...sic_json__CompatibleIntegerNumberType.link | 1 + ...basic_json__CompatibleNumberFloatType.link | 1 + .../basic_json__CompatibleObjectType.link | 1 + .../basic_json__CompatibleStringType.link | 1 + doc/examples/basic_json__InputIt_InputIt.link | 1 + doc/examples/basic_json__array_t.link | 1 + doc/examples/basic_json__basic_json.link | 1 + doc/examples/basic_json__boolean_t.link | 1 + doc/examples/basic_json__const_int.link | 1 + doc/examples/basic_json__copyassignment.link | 1 + doc/examples/basic_json__list_init_t.link | 1 + doc/examples/basic_json__moveconstructor.link | 1 + doc/examples/basic_json__nullptr_t.link | 1 + doc/examples/basic_json__number_float_t.link | 1 + .../basic_json__number_integer_t.link | 1 + doc/examples/basic_json__object_t.link | 1 + .../basic_json__size_type_basic_json.link | 1 + doc/examples/basic_json__string_t.link | 1 + .../basic_json__string_t_value_type.link | 1 + doc/examples/basic_json__value_t.link | 1 + doc/examples/begin.link | 1 + doc/examples/cbegin.link | 1 + doc/examples/cend.link | 1 + doc/examples/clear.link | 1 + doc/examples/count.link | 1 + doc/examples/crbegin.link | 1 + doc/examples/crend.link | 1 + doc/examples/dump.link | 1 + doc/examples/empty.link | 1 + doc/examples/end.link | 1 + doc/examples/erase__IteratorType.link | 1 + .../erase__IteratorType_IteratorType.link | 1 + doc/examples/erase__key_type.link | 1 + doc/examples/erase__size_type.link | 1 + doc/examples/find__key_type.link | 1 + doc/examples/front.link | 1 + doc/examples/get__PointerType.link | 1 + doc/examples/get__ValueType_const.link | 1 + doc/examples/get_ptr.link | 1 + doc/examples/is_array.link | 1 + doc/examples/is_boolean.link | 1 + doc/examples/is_null.link | 1 + doc/examples/is_number.link | 1 + doc/examples/is_number_float.link | 1 + doc/examples/is_number_integer.link | 1 + doc/examples/is_object.link | 1 + doc/examples/is_primitive.link | 1 + doc/examples/is_string.link | 1 + doc/examples/is_structured.link | 1 + doc/examples/max_size.link | 1 + doc/examples/object.link | 1 + doc/examples/operator__ValueType.link | 1 + doc/examples/operator__value_t.link | 1 + doc/examples/operator_deserialize.link | 1 + doc/examples/operator_serialize.link | 1 + doc/examples/operatorarray__key_type.link | 1 + .../operatorarray__key_type_const.link | 1 + doc/examples/operatorarray__size_type.link | 1 + .../operatorarray__size_type_const.link | 1 + .../parse__istream__parser_callback_t.link | 1 + .../parse__string__parser_callback_t.link | 1 + doc/examples/rbegin.link | 1 + doc/examples/rend.link | 1 + doc/examples/size.link | 1 + doc/examples/swap__array_t.link | 1 + doc/examples/swap__reference.link | 1 + doc/examples/type.link | 1 + doc/send_to_wandbox.py | 119 ++++++++++++++++++ 81 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 doc/examples/README.cpp create mode 100644 doc/examples/README.link create mode 100644 doc/examples/array.link create mode 100644 doc/examples/at__object_t_key_type.link create mode 100644 doc/examples/at__object_t_key_type_const.link create mode 100644 doc/examples/at__size_type.link create mode 100644 doc/examples/at__size_type_const.link create mode 100644 doc/examples/back.link create mode 100644 doc/examples/basic_json.link create mode 100644 doc/examples/basic_json__CompatibleArrayType.link create mode 100644 doc/examples/basic_json__CompatibleIntegerNumberType.link create mode 100644 doc/examples/basic_json__CompatibleNumberFloatType.link create mode 100644 doc/examples/basic_json__CompatibleObjectType.link create mode 100644 doc/examples/basic_json__CompatibleStringType.link create mode 100644 doc/examples/basic_json__InputIt_InputIt.link create mode 100644 doc/examples/basic_json__array_t.link create mode 100644 doc/examples/basic_json__basic_json.link create mode 100644 doc/examples/basic_json__boolean_t.link create mode 100644 doc/examples/basic_json__const_int.link create mode 100644 doc/examples/basic_json__copyassignment.link create mode 100644 doc/examples/basic_json__list_init_t.link create mode 100644 doc/examples/basic_json__moveconstructor.link create mode 100644 doc/examples/basic_json__nullptr_t.link create mode 100644 doc/examples/basic_json__number_float_t.link create mode 100644 doc/examples/basic_json__number_integer_t.link create mode 100644 doc/examples/basic_json__object_t.link create mode 100644 doc/examples/basic_json__size_type_basic_json.link create mode 100644 doc/examples/basic_json__string_t.link create mode 100644 doc/examples/basic_json__string_t_value_type.link create mode 100644 doc/examples/basic_json__value_t.link create mode 100644 doc/examples/begin.link create mode 100644 doc/examples/cbegin.link create mode 100644 doc/examples/cend.link create mode 100644 doc/examples/clear.link create mode 100644 doc/examples/count.link create mode 100644 doc/examples/crbegin.link create mode 100644 doc/examples/crend.link create mode 100644 doc/examples/dump.link create mode 100644 doc/examples/empty.link create mode 100644 doc/examples/end.link create mode 100644 doc/examples/erase__IteratorType.link create mode 100644 doc/examples/erase__IteratorType_IteratorType.link create mode 100644 doc/examples/erase__key_type.link create mode 100644 doc/examples/erase__size_type.link create mode 100644 doc/examples/find__key_type.link create mode 100644 doc/examples/front.link create mode 100644 doc/examples/get__PointerType.link create mode 100644 doc/examples/get__ValueType_const.link create mode 100644 doc/examples/get_ptr.link create mode 100644 doc/examples/is_array.link create mode 100644 doc/examples/is_boolean.link create mode 100644 doc/examples/is_null.link create mode 100644 doc/examples/is_number.link create mode 100644 doc/examples/is_number_float.link create mode 100644 doc/examples/is_number_integer.link create mode 100644 doc/examples/is_object.link create mode 100644 doc/examples/is_primitive.link create mode 100644 doc/examples/is_string.link create mode 100644 doc/examples/is_structured.link create mode 100644 doc/examples/max_size.link create mode 100644 doc/examples/object.link create mode 100644 doc/examples/operator__ValueType.link create mode 100644 doc/examples/operator__value_t.link create mode 100644 doc/examples/operator_deserialize.link create mode 100644 doc/examples/operator_serialize.link create mode 100644 doc/examples/operatorarray__key_type.link create mode 100644 doc/examples/operatorarray__key_type_const.link create mode 100644 doc/examples/operatorarray__size_type.link create mode 100644 doc/examples/operatorarray__size_type_const.link create mode 100644 doc/examples/parse__istream__parser_callback_t.link create mode 100644 doc/examples/parse__string__parser_callback_t.link create mode 100644 doc/examples/rbegin.link create mode 100644 doc/examples/rend.link create mode 100644 doc/examples/size.link create mode 100644 doc/examples/swap__array_t.link create mode 100644 doc/examples/swap__reference.link create mode 100644 doc/examples/type.link create mode 100755 doc/send_to_wandbox.py diff --git a/README.md b/README.md index 85c8b8d5a..c32ddf914 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json) [![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/GnGKwji06WeVonlI) [![Documentation Status](https://img.shields.io/badge/documentation-doxygen-blue.svg)](http://nlohmann.github.io/json) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT) [![Github Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](http://github.com/nlohmann/json/issues) diff --git a/doc/Doxyfile b/doc/Doxyfile index d880366b4..033f84840 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -28,7 +28,7 @@ INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = YES TAB_SIZE = 4 ALIASES = "complexity=@par Complexity\n" -ALIASES += liveexample{2}="@par Example\n \1 \n @includelineno \2.cpp \n Output:\n @verbinclude \2.output \n The example code above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim." +ALIASES += liveexample{2}="@par Example\n \1 \n @includelineno \2.cpp \n Output (play with this example @htmlinclude \2.link):\n @verbinclude \2.output \n The example code above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim" ALIASES += requirement="@par Requirements\n" TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = NO diff --git a/doc/Makefile b/doc/Makefile index 20c65fe52..21e15a57d 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -24,9 +24,20 @@ EXAMPLES = $(wildcard examples/*.cpp) diff $@ $(<:.cpp=.output) rm $(<:.cpp=) $@ +# create links to try the code online +%.link: %.cpp + rm -fr tmp + mkdir tmp + cp $(SRCDIR)/json.hpp tmp + ./send_to_wandbox.py tmp $< > $@.tmp + /bin/echo -n "online" > $@ + rm -fr tmp $@.tmp + # create output from all stand-alone example files create_output: $(EXAMPLES:.cpp=.output) +create_links: $(EXAMPLES:.cpp=.link) + # check output of all stand-alone example files check_output: $(EXAMPLES:.cpp=.test) diff --git a/doc/examples/README.cpp b/doc/examples/README.cpp new file mode 100644 index 000000000..f396096b5 --- /dev/null +++ b/doc/examples/README.cpp @@ -0,0 +1,31 @@ +#include + +using namespace nlohmann; + +int main() +{ + // create a JSON object + json j = { + {"pi", 3.141}, + {"happy", true}, + {"name", "Niels"}, + {"nothing", nullptr}, + {"answer", { + {"everything", 42} + }}, + {"list", {1, 0, 2}}, + {"object", { + {"currency", "USD"}, + {"value", 42.99} + }} + }; + + // add new values + j["new"]["key"]["value"] = {"another", "list"}; + + // count elements + j["size"] = j.size(); + + // pretty print with indent of 4 spaces + std::cout << std::setw(4) << j << '\n'; +} diff --git a/doc/examples/README.link b/doc/examples/README.link new file mode 100644 index 000000000..017a2d006 --- /dev/null +++ b/doc/examples/README.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/array.link b/doc/examples/array.link new file mode 100644 index 000000000..2fa5d1dc2 --- /dev/null +++ b/doc/examples/array.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/at__object_t_key_type.link b/doc/examples/at__object_t_key_type.link new file mode 100644 index 000000000..1f4956378 --- /dev/null +++ b/doc/examples/at__object_t_key_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/at__object_t_key_type_const.link b/doc/examples/at__object_t_key_type_const.link new file mode 100644 index 000000000..59ff8a90a --- /dev/null +++ b/doc/examples/at__object_t_key_type_const.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/at__size_type.link b/doc/examples/at__size_type.link new file mode 100644 index 000000000..49830f7b0 --- /dev/null +++ b/doc/examples/at__size_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/at__size_type_const.link b/doc/examples/at__size_type_const.link new file mode 100644 index 000000000..663ee72e3 --- /dev/null +++ b/doc/examples/at__size_type_const.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/back.link b/doc/examples/back.link new file mode 100644 index 000000000..98bca5fe6 --- /dev/null +++ b/doc/examples/back.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json.link b/doc/examples/basic_json.link new file mode 100644 index 000000000..f623a3cfa --- /dev/null +++ b/doc/examples/basic_json.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__CompatibleArrayType.link b/doc/examples/basic_json__CompatibleArrayType.link new file mode 100644 index 000000000..52e8cae9a --- /dev/null +++ b/doc/examples/basic_json__CompatibleArrayType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__CompatibleIntegerNumberType.link b/doc/examples/basic_json__CompatibleIntegerNumberType.link new file mode 100644 index 000000000..c1dba478f --- /dev/null +++ b/doc/examples/basic_json__CompatibleIntegerNumberType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__CompatibleNumberFloatType.link b/doc/examples/basic_json__CompatibleNumberFloatType.link new file mode 100644 index 000000000..aa10ad21a --- /dev/null +++ b/doc/examples/basic_json__CompatibleNumberFloatType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__CompatibleObjectType.link b/doc/examples/basic_json__CompatibleObjectType.link new file mode 100644 index 000000000..3fe8de3a4 --- /dev/null +++ b/doc/examples/basic_json__CompatibleObjectType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__CompatibleStringType.link b/doc/examples/basic_json__CompatibleStringType.link new file mode 100644 index 000000000..88406aed3 --- /dev/null +++ b/doc/examples/basic_json__CompatibleStringType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__InputIt_InputIt.link b/doc/examples/basic_json__InputIt_InputIt.link new file mode 100644 index 000000000..6945986e0 --- /dev/null +++ b/doc/examples/basic_json__InputIt_InputIt.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__array_t.link b/doc/examples/basic_json__array_t.link new file mode 100644 index 000000000..6ea8193b6 --- /dev/null +++ b/doc/examples/basic_json__array_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__basic_json.link b/doc/examples/basic_json__basic_json.link new file mode 100644 index 000000000..4853dde83 --- /dev/null +++ b/doc/examples/basic_json__basic_json.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__boolean_t.link b/doc/examples/basic_json__boolean_t.link new file mode 100644 index 000000000..656069902 --- /dev/null +++ b/doc/examples/basic_json__boolean_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__const_int.link b/doc/examples/basic_json__const_int.link new file mode 100644 index 000000000..8df3800a7 --- /dev/null +++ b/doc/examples/basic_json__const_int.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__copyassignment.link b/doc/examples/basic_json__copyassignment.link new file mode 100644 index 000000000..363e8ff6d --- /dev/null +++ b/doc/examples/basic_json__copyassignment.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__list_init_t.link b/doc/examples/basic_json__list_init_t.link new file mode 100644 index 000000000..36a902280 --- /dev/null +++ b/doc/examples/basic_json__list_init_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__moveconstructor.link b/doc/examples/basic_json__moveconstructor.link new file mode 100644 index 000000000..8fe8910c9 --- /dev/null +++ b/doc/examples/basic_json__moveconstructor.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__nullptr_t.link b/doc/examples/basic_json__nullptr_t.link new file mode 100644 index 000000000..3587d6020 --- /dev/null +++ b/doc/examples/basic_json__nullptr_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__number_float_t.link b/doc/examples/basic_json__number_float_t.link new file mode 100644 index 000000000..c5a320a74 --- /dev/null +++ b/doc/examples/basic_json__number_float_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__number_integer_t.link b/doc/examples/basic_json__number_integer_t.link new file mode 100644 index 000000000..eb89983a3 --- /dev/null +++ b/doc/examples/basic_json__number_integer_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__object_t.link b/doc/examples/basic_json__object_t.link new file mode 100644 index 000000000..dbe9e78ec --- /dev/null +++ b/doc/examples/basic_json__object_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__size_type_basic_json.link b/doc/examples/basic_json__size_type_basic_json.link new file mode 100644 index 000000000..349d423d5 --- /dev/null +++ b/doc/examples/basic_json__size_type_basic_json.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__string_t.link b/doc/examples/basic_json__string_t.link new file mode 100644 index 000000000..e3f988fcb --- /dev/null +++ b/doc/examples/basic_json__string_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__string_t_value_type.link b/doc/examples/basic_json__string_t_value_type.link new file mode 100644 index 000000000..f85b8236d --- /dev/null +++ b/doc/examples/basic_json__string_t_value_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/basic_json__value_t.link b/doc/examples/basic_json__value_t.link new file mode 100644 index 000000000..9d8b06335 --- /dev/null +++ b/doc/examples/basic_json__value_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/begin.link b/doc/examples/begin.link new file mode 100644 index 000000000..5db4ca8d2 --- /dev/null +++ b/doc/examples/begin.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/cbegin.link b/doc/examples/cbegin.link new file mode 100644 index 000000000..fcbe5f2b6 --- /dev/null +++ b/doc/examples/cbegin.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/cend.link b/doc/examples/cend.link new file mode 100644 index 000000000..60ba84418 --- /dev/null +++ b/doc/examples/cend.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/clear.link b/doc/examples/clear.link new file mode 100644 index 000000000..5a34bf9f8 --- /dev/null +++ b/doc/examples/clear.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/count.link b/doc/examples/count.link new file mode 100644 index 000000000..ef8835391 --- /dev/null +++ b/doc/examples/count.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/crbegin.link b/doc/examples/crbegin.link new file mode 100644 index 000000000..ad4fbeb9f --- /dev/null +++ b/doc/examples/crbegin.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/crend.link b/doc/examples/crend.link new file mode 100644 index 000000000..a691504ae --- /dev/null +++ b/doc/examples/crend.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/dump.link b/doc/examples/dump.link new file mode 100644 index 000000000..d6470d44a --- /dev/null +++ b/doc/examples/dump.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/empty.link b/doc/examples/empty.link new file mode 100644 index 000000000..8b885b037 --- /dev/null +++ b/doc/examples/empty.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/end.link b/doc/examples/end.link new file mode 100644 index 000000000..4f9ce01dc --- /dev/null +++ b/doc/examples/end.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/erase__IteratorType.link b/doc/examples/erase__IteratorType.link new file mode 100644 index 000000000..e1a133a0d --- /dev/null +++ b/doc/examples/erase__IteratorType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/erase__IteratorType_IteratorType.link b/doc/examples/erase__IteratorType_IteratorType.link new file mode 100644 index 000000000..c1479769c --- /dev/null +++ b/doc/examples/erase__IteratorType_IteratorType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/erase__key_type.link b/doc/examples/erase__key_type.link new file mode 100644 index 000000000..4ab5bb614 --- /dev/null +++ b/doc/examples/erase__key_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/erase__size_type.link b/doc/examples/erase__size_type.link new file mode 100644 index 000000000..1a4bbfdde --- /dev/null +++ b/doc/examples/erase__size_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/find__key_type.link b/doc/examples/find__key_type.link new file mode 100644 index 000000000..68beedbe3 --- /dev/null +++ b/doc/examples/find__key_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/front.link b/doc/examples/front.link new file mode 100644 index 000000000..2821f00d3 --- /dev/null +++ b/doc/examples/front.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/get__PointerType.link b/doc/examples/get__PointerType.link new file mode 100644 index 000000000..f9411820b --- /dev/null +++ b/doc/examples/get__PointerType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/get__ValueType_const.link b/doc/examples/get__ValueType_const.link new file mode 100644 index 000000000..0969939c2 --- /dev/null +++ b/doc/examples/get__ValueType_const.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/get_ptr.link b/doc/examples/get_ptr.link new file mode 100644 index 000000000..aeaf460db --- /dev/null +++ b/doc/examples/get_ptr.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_array.link b/doc/examples/is_array.link new file mode 100644 index 000000000..e1aa234e7 --- /dev/null +++ b/doc/examples/is_array.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_boolean.link b/doc/examples/is_boolean.link new file mode 100644 index 000000000..3972af75b --- /dev/null +++ b/doc/examples/is_boolean.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_null.link b/doc/examples/is_null.link new file mode 100644 index 000000000..a2fb14074 --- /dev/null +++ b/doc/examples/is_null.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_number.link b/doc/examples/is_number.link new file mode 100644 index 000000000..1fc0fc866 --- /dev/null +++ b/doc/examples/is_number.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_number_float.link b/doc/examples/is_number_float.link new file mode 100644 index 000000000..ef3aaf331 --- /dev/null +++ b/doc/examples/is_number_float.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_number_integer.link b/doc/examples/is_number_integer.link new file mode 100644 index 000000000..bbd368f04 --- /dev/null +++ b/doc/examples/is_number_integer.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_object.link b/doc/examples/is_object.link new file mode 100644 index 000000000..5ab6384fc --- /dev/null +++ b/doc/examples/is_object.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_primitive.link b/doc/examples/is_primitive.link new file mode 100644 index 000000000..f6918a96d --- /dev/null +++ b/doc/examples/is_primitive.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_string.link b/doc/examples/is_string.link new file mode 100644 index 000000000..7ba95c364 --- /dev/null +++ b/doc/examples/is_string.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/is_structured.link b/doc/examples/is_structured.link new file mode 100644 index 000000000..9b5abfdf3 --- /dev/null +++ b/doc/examples/is_structured.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/max_size.link b/doc/examples/max_size.link new file mode 100644 index 000000000..88752ae72 --- /dev/null +++ b/doc/examples/max_size.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/object.link b/doc/examples/object.link new file mode 100644 index 000000000..048be3882 --- /dev/null +++ b/doc/examples/object.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operator__ValueType.link b/doc/examples/operator__ValueType.link new file mode 100644 index 000000000..cc28e01f1 --- /dev/null +++ b/doc/examples/operator__ValueType.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operator__value_t.link b/doc/examples/operator__value_t.link new file mode 100644 index 000000000..36b32318a --- /dev/null +++ b/doc/examples/operator__value_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operator_deserialize.link b/doc/examples/operator_deserialize.link new file mode 100644 index 000000000..3b6051510 --- /dev/null +++ b/doc/examples/operator_deserialize.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operator_serialize.link b/doc/examples/operator_serialize.link new file mode 100644 index 000000000..558c0738f --- /dev/null +++ b/doc/examples/operator_serialize.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operatorarray__key_type.link b/doc/examples/operatorarray__key_type.link new file mode 100644 index 000000000..1dfa0cc08 --- /dev/null +++ b/doc/examples/operatorarray__key_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operatorarray__key_type_const.link b/doc/examples/operatorarray__key_type_const.link new file mode 100644 index 000000000..0f03498a9 --- /dev/null +++ b/doc/examples/operatorarray__key_type_const.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operatorarray__size_type.link b/doc/examples/operatorarray__size_type.link new file mode 100644 index 000000000..050f86f60 --- /dev/null +++ b/doc/examples/operatorarray__size_type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/operatorarray__size_type_const.link b/doc/examples/operatorarray__size_type_const.link new file mode 100644 index 000000000..ef0eec4f7 --- /dev/null +++ b/doc/examples/operatorarray__size_type_const.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/parse__istream__parser_callback_t.link b/doc/examples/parse__istream__parser_callback_t.link new file mode 100644 index 000000000..36aee856f --- /dev/null +++ b/doc/examples/parse__istream__parser_callback_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/parse__string__parser_callback_t.link b/doc/examples/parse__string__parser_callback_t.link new file mode 100644 index 000000000..f92ef4b67 --- /dev/null +++ b/doc/examples/parse__string__parser_callback_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/rbegin.link b/doc/examples/rbegin.link new file mode 100644 index 000000000..69e5aaa20 --- /dev/null +++ b/doc/examples/rbegin.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/rend.link b/doc/examples/rend.link new file mode 100644 index 000000000..e8c43daf3 --- /dev/null +++ b/doc/examples/rend.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/size.link b/doc/examples/size.link new file mode 100644 index 000000000..e82246040 --- /dev/null +++ b/doc/examples/size.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/swap__array_t.link b/doc/examples/swap__array_t.link new file mode 100644 index 000000000..5afa09c95 --- /dev/null +++ b/doc/examples/swap__array_t.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/swap__reference.link b/doc/examples/swap__reference.link new file mode 100644 index 000000000..7f834590f --- /dev/null +++ b/doc/examples/swap__reference.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/type.link b/doc/examples/type.link new file mode 100644 index 000000000..acd8cbfb1 --- /dev/null +++ b/doc/examples/type.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/send_to_wandbox.py b/doc/send_to_wandbox.py new file mode 100755 index 000000000..77c1f157f --- /dev/null +++ b/doc/send_to_wandbox.py @@ -0,0 +1,119 @@ +#! /usr/bin/env python + +# This script uploads a directory to Wandbox (http://melpon.org/wandbox), +# which is an online compiler environment, and prints a permalink to the +# uploaded code. We use this to provide a "Try it online" version of the +# library to make the barrier to entry as low as possible. +# +# This script was adapted from the script proposed in +# https://github.com/melpon/wandbox/issues/153. +# +# To know how to use this script: ./wandbox.py --help +# +# Copyright Louis Dionne 2015 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +import argparse +import fnmatch +import json +import os +import re +import urllib2 + + +# Strips C and C++ comments from the given string. +# +# Copied from http://stackoverflow.com/a/241506/627587. +def strip_comments(text): + def replacer(match): + s = match.group(0) + if s.startswith('/'): + return " " # note: a space and not an empty string + else: + return s + pattern = re.compile( + r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', + re.DOTALL | re.MULTILINE + ) + return re.sub(pattern, replacer, text) + + +# Post the given JSON data to Wandbox's API, and return the result +# as a JSON object. +def upload(options): + request = urllib2.Request('http://melpon.org/wandbox/api/compile.json') + request.add_header('Content-Type', 'application/json') + response = urllib2.urlopen(request, json.dumps(options)) + return json.loads(response.read()) + + +# Returns a list of the '.hpp' headers in the given directory and in +# subdirectories. +# +# The path must be absolute, and the returned paths are all absolute too. +def headers(path): + return [ + os.path.join(dir, file) + for (dir, _, files) in os.walk(path) + for file in fnmatch.filter(files, "*.hpp") + ] + + +def main(): + parser = argparse.ArgumentParser(description= + """Upload a directory to Wandbox (http://melpon.org/wandbox). + + On success, the program prints a permalink to the uploaded + directory on Wandbox and returns 0. On error, it prints the + response from the Wandbox API and returns 1. + + Note that the comments are stripped from all the headers in the + uploaded directory. + """ + ) + parser.add_argument('directory', type=str, help= + """A directory to upload to Wandbox. + + The path may be either absolute or relative to the current directory. + However, the names of the files uploaded to Wandbox will all be + relative to this directory. This way, one can easily specify the + directory to be '/some/project/include', and the uploaded files + will be uploaded as-if they were rooted at '/some/project/include' + """) + parser.add_argument('main', type=str, help= + """The main source file. + + The path may be either absolute or relative to the current directory. + """ + ) + args = parser.parse_args() + directory = os.path.abspath(args.directory) + if not os.path.exists(directory): + raise Exception("'%s' is not a valid directory" % args.directory) + + cpp = os.path.abspath(args.main) + if not os.path.exists(cpp): + raise Exception("'%s' is not a valid file name" % args.main) + + response = upload({ + 'code': open(cpp).read(), + 'codes': [{ + 'file': os.path.relpath(header, directory), + 'code': strip_comments(open(header).read()) + } for header in headers(directory)], + 'options': 'boost-nothing,c++11', + 'compiler': 'gcc-4.9.2', + 'save': True, + 'compiler-option-raw': '-I.' + }) + + if 'status' in response and response['status'] == '0': + print response['url'] + return 0 + else: + print response + return 1 + + +exit(main()) -- GitLab