Merge branch 'develop' into feature/rfc7396

This commit is contained in:
Niels Lohmann 2018-01-14 10:28:09 +01:00
commit 0e8f01a963
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
134 changed files with 20390 additions and 1770 deletions

View file

@ -1,17 +1,18 @@
# Doxyfile 1.8.14
# Doxyfile 1.8.15
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "JSON for Modern C++"
PROJECT_NUMBER = 2.1.1
PROJECT_NUMBER = 3.0.1
PROJECT_BRIEF =
PROJECT_LOGO =
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
OUTPUT_TEXT_DIRECTION = None
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = NO
ABBREVIATE_BRIEF =
@ -27,11 +28,11 @@ MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = YES
TAB_SIZE = 4
ALIASES = "complexity=@par Complexity\n" \
"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 <a href= https://github.com/nlohmann/json/blob/develop/doc/examples/\2.cpp>example code</a> above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim" \
"requirement=@par Requirements\n" \
"exceptionsafety=@par Exception safety\n" \
"iterators=@par Iterator validity\n"
ALIASES = "complexity=@par Complexity^^" \
"liveexample{2}=@par Example^^ \1 ^^ @includelineno \2.cpp \n Output (play with this example @htmlinclude \2.link):^^ @verbinclude \2.output ^^ The <a href= https://github.com/nlohmann/json/blob/develop/doc/examples/\2.cpp>example code</a> above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim" \
"requirement=@par Requirements^^" \
"exceptionsafety=@par Exception safety^^" \
"iterators=@par Iterator validity^^"
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
@ -107,7 +108,8 @@ WARN_LOGFILE =
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src/json.hpp \
index.md faq.md
index.md \
faq.md
INPUT_ENCODING = UTF-8
FILE_PATTERNS =
RECURSIVE = NO
@ -138,6 +140,7 @@ USE_HTAGS = NO
VERBATIM_HEADERS = NO
CLANG_ASSISTED_PARSING = YES
CLANG_OPTIONS = -std=c++11
CLANG_COMPILATION_DATABASE_PATH = 0
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------

View file

@ -63,7 +63,7 @@ doxygen: create_output create_links
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberUnsignedType,&#160;NumberFloatType,&#160;AllocatorType,&#160;JSONSerializer&#160;&gt;@@g' html/*.html
upload: clean doxygen check_output
cd html ; ../scripts/git-update-ghpages nlohmann/json
scripts/git-update-ghpages nlohmann/json html
rm -fr html
open http://nlohmann.github.io/json/

BIN
doc/avatars.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/yCTCvQi0ZVxGuL3L"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/Op57X0V7fTf2tdwl"><b>online</b></a>

View file

@ -79,6 +79,17 @@ int main()
std::cout << e.what() << '\n';
}
// out_of_range.403
try
{
// try to use a JSON pointer to an nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.404
try
{

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/mlj2WqOtwBidvuJx"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/3RO0naQeY3cWXNAz"><b>online</b></a>

View file

@ -8,4 +8,5 @@
[json.exception.parse_error.109] parse error: array index 'one' is not a number
[json.exception.out_of_range.401] array index 4 is out of range
[json.exception.out_of_range.402] array index '-' (2) is out of range
[json.exception.out_of_range.403] key 'foo' not found
[json.exception.out_of_range.404] unresolved reference token 'foo'

View file

@ -55,6 +55,17 @@ int main()
std::cout << e.what() << '\n';
}
// out_of_range.403
try
{
// try to use a JSON pointer to an nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.404
try
{

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/vHKlyYl9DwaUO9UN"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/LwtGNqrGgjcWey3P"><b>online</b></a>

View file

@ -5,4 +5,5 @@
[json.exception.parse_error.109] parse error: array index 'one' is not a number
[json.exception.out_of_range.401] array index 4 is out of range
[json.exception.out_of_range.402] array index '-' (2) is out of range
[json.exception.out_of_range.403] key 'foo' not found
[json.exception.out_of_range.404] unresolved reference token 'foo'

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/DKPu3VnNVgsQbaSX"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/QJlGaO7RqgvibCbR"><b>online</b></a>

View file

@ -28,4 +28,15 @@ int main()
std::cout << "strings:" << '\n'
<< j_string.dump() << '\n'
<< j_string.dump(-1, ' ', true) << '\n';
// create JSON value with invalid UTF-8 byte sequence
json j_invalid = "\xF0\xA4\xAD\xC0";
try
{
std::cout << j_invalid.dump() << std::endl;
}
catch (json::type_error& e)
{
std::cout << e.what() << std::endl;
}
}

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/UnV6etCOZZRZpYyB"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/mHH9TibITCYPpLwy"><b>online</b></a>

View file

@ -50,3 +50,4 @@ arrays:
strings:
"Hellö 😀!"
"Hell\u00f6 \ud83d\ude00!"
[json.exception.type_error.316] invalid UTF-8 byte at index 3: 0xC0

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/TpEB8tou7Wuyprkm"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/EBqdb2uhXyKTbr9f"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/X9wSCDZNg82T3oix"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/NkSIj6G89DXRXX9u"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/9MjZO7niLtZaJIIx"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/DlKRo80ESI428gH8"><b>online</b></a>

23
doc/examples/items.cpp Normal file
View file

@ -0,0 +1,23 @@
#include <iostream>
#include "json.hpp"
using json = nlohmann::json;
int main()
{
// create JSON values
json j_object = {{"one", 1}, {"two", 2}};
json j_array = {1, 2, 4, 8, 16};
// example for an object
for (auto& x : j_object.items())
{
std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
}
// example for an array
for (auto& x : j_array.items())
{
std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
}
}

1
doc/examples/items.link Normal file
View file

@ -0,0 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/E7h0HOuw778Ski8S"><b>online</b></a>

View file

@ -0,0 +1,7 @@
key: one, value: 1
key: two, value: 2
key: 0, value: 1
key: 1, value: 2
key: 2, value: 4
key: 3, value: 8
key: 4, value: 16

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/M9jbzex4Xj2l25ce"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/mtnyQGVjmAoHVvaP"><b>online</b></a>

View file

@ -2,16 +2,16 @@
"compiler": {
"c++": "201103",
"family": "clang",
"version": "8.1.0 (clang-802.0.42)"
"version": "9.0.0 (clang-900.0.39.2)"
},
"copyright": "(C) 2013-2017 Niels Lohmann",
"name": "JSON for Modern C++",
"platform": "apple",
"url": "https://github.com/nlohmann/json",
"version": {
"major": 2,
"minor": 1,
"major": 3,
"minor": 0,
"patch": 1,
"string": "2.1.1"
"string": "3.0.1"
}
}

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/atomVJKVgMTIh1iT"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/qrMPH8rv4FBqE2Ri"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/0Ec7N50CDWAWPWEE"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/9j30rS3lws0iiHPd"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/iG5QR4oqgCLaEedf"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/bYLh2weuTo9jkR5V"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/fs7n9Xh41pSIxK4g"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/12CMBHX694yrt0i9"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/2cJ6aEoQItmXOyEe"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/YDBQGKfyJUePDpRe"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/IvIGk03HXpuyv271"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/DhwTP8AtK5UoeF55"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/a8XRIpnVOQp3zYKV"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/c4K2s7QuFNfXd3j7"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/JZ8P4ruGJTLfOFHJ"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/GKABhikWJQTHeX7z"><b>online</b></a>

View file

@ -1,6 +1,5 @@
#include <iostream>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/U9n8nunch9ti8XlQ"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/QVr68rXTR2kztpbl"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/m6XKVQBrhB6jXGOe"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/ze9XofH6xAKtIha1"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/b66iY9hOdCHEG8FV"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/k8bMpRumLfsA8ylM"><b>online</b></a>

View file

@ -1,5 +1,4 @@
#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;

View file

@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/WKkNkEuGbsxPknyT"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/hvj393WgvjIaiUZe"><b>online</b></a>

View file

@ -28,6 +28,12 @@ These pages contain the API documentation of JSON for Modern C++, a C++11 header
- @link nlohmann::basic_json::get_ref get_ref @endlink -- get a value reference
- @link nlohmann::basic_json::operator ValueType() const operator ValueType @endlink -- get a value (implicit conversion)
- @link nlohmann::basic_json::value value @endlink -- get a value from an object and return default value if key is not present
- exceptions
- @link nlohmann::basic_json::parse_error parse_error @endlink for exceptions indicating a parse error
- @link nlohmann::basic_json::invalid_iterator invalid_iterator @endlink for exceptions indicating errors with iterators
- @link nlohmann::basic_json::type_error type_error @endlink for exceptions indicating executing a member function with a wrong type
- @link nlohmann::basic_json::out_of_range out_of_range @endlink for exceptions indicating access out of the defined range
- @link nlohmann::basic_json::other_error other_error @endlink for exceptions indicating other library errors
- lexicographical comparison operators
- serialization
- deserialization
@ -45,6 +51,8 @@ These pages contain the API documentation of JSON for Modern C++, a C++11 header
The container functions known from STL have been extended to support the different value types from JSON. However, not all functions can be applied to all value types. Note that the signature of some functions differ between the types; for instance, `at` may be called with either a string to address a key in an object or with an integer to address a value in an array.
Note that this table only lists those exceptions thrown due to the type. For instance, the @link nlohmann::basic_json::at(const typename object_t::key_type & key) `at` @endlink function will always throw a @link nlohmann::basic_json::type_error `json::type_error` @endlink exception when called for a string type. When called for an array, it *may* throw an @link nlohmann::basic_json::out_of_range `json::out_of_range` @endlink exception if the passed index is invalid.
<table>
<tr>
<th rowspan="2">group</td>
@ -137,18 +145,18 @@ The container functions known from STL have been extended to support the differe
<td>`at`</td>
<td class="ok_green">@link nlohmann::basic_json::at(const typename object_t::key_type & key) `at` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::at(size_type) `at` @endlink</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (304)</td>
</tr>
<tr>
<td>`operator[]`</td>
<td class="ok_green">@link nlohmann::basic_json::operator[](const typename object_t::key_type &key) `operator[]` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::operator[](size_type) `operator[]` @endlink</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (305)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (305)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (305)</td>
<td class="ok_green">@link nlohmann::basic_json::operator[](const typename object_t::key_type & key) `operator[]` @endlink (creates object)<br>@link nlohmann::basic_json::operator[](size_type) `operator[]` @endlink (creates array)</td>
</tr>
<tr>
@ -158,7 +166,7 @@ The container functions known from STL have been extended to support the differe
<td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
<td class="nok_throws">throws `std::out_of_range`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::invalid_iterator `json::invalid_iterator` @endlink (214)</td>
</tr>
<tr>
<td>`back`</td>
@ -167,7 +175,7 @@ The container functions known from STL have been extended to support the differe
<td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
<td class="nok_throws">throws `std::out_of_range`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::invalid_iterator `json::invalid_iterator` @endlink (214)</td>
</tr>
<tr>
<td rowspan="3">capacity</td>
@ -198,7 +206,7 @@ The container functions known from STL have been extended to support the differe
<td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink (returns `0`)</td>
</tr>
<tr>
<td rowspan="6">modifiers</td>
<td rowspan="7">modifiers</td>
<td>`clear`</td>
<td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
@ -209,12 +217,12 @@ The container functions known from STL have been extended to support the differe
</tr>
<tr>
<td>`insert`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)</td>
<td class="ok_green">@link nlohmann::basic_json::insert `insert` @endlink</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (309)</td>
</tr>
<tr>
<td>`erase`</td>
@ -223,26 +231,35 @@ The container functions known from STL have been extended to support the differe
<td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink (converts to null)</td>
<td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink (converts to null)</td>
<td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink (converts to null)</td>
<td class="nok_throws">throws</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (307)</td>
</tr>
<tr>
<td>`push_back`</td>
<td class="ok_green">@link nlohmann::basic_json::push_back(const typename object_t::value_type & val) `push_back` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::push_back(const nlohmann::basic_json &) `push_back` @endlink</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (308)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (308)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (308)</td>
<td class="ok_green">@link nlohmann::basic_json::push_back(const typename object_t::value_type & val) `push_back` @endlink (creates object)<br>@link nlohmann::basic_json::push_back(const nlohmann::basic_json &) `push_back` @endlink (creates array)</td>
</tr>
<tr>
<td>`emplace` / `emplace_back`</td>
<td class="ok_green">@link nlohmann::basic_json::emplace() `emplace` @endlink</td>
<td class="ok_green">@link nlohmann::basic_json::emplace_back() `emplace_back` @endlink</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws `std::domain_error`</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (311)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (311)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (311)</td>
<td class="ok_green">@link nlohmann::basic_json::emplace() `emplace` @endlink (creates object)<br>@link nlohmann::basic_json::emplace_back() `emplace_back` @endlink (creates array)</td>
</tr>
<tr>
<td>`update`</td>
<td class="ok_green">@link nlohmann::basic_json::update() `update` @endlink</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)</td>
<td class="nok_throws">throws @link nlohmann::basic_json::type_error `json::type_error` @endlink (312)</td>
</tr>
<tr>
<td>`swap`</td>
<td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
@ -278,4 +295,4 @@ The container functions known from STL have been extended to support the differe
@author [Niels Lohmann](http://nlohmann.me)
@see https://github.com/nlohmann/json to download the source code
@version 2.1.1
@version 3.0.1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 4.2 MiB

Before After
Before After

View file

@ -1,221 +1,193 @@
#!/usr/bin/env ruby
# git update-ghpages user/repo -b gh-pages -p manual/ -i
#!/usr/bin/env bash
set -o errexit
require 'fileutils'
require 'tmpdir'
copy_contents() {
local source="$1"
status "Copying contents from $source"
if [[ ! "$dryrun" == "1" ]]; then
(cd "$source" >/dev/null && tar c .) | tar xv
else
_ "(cd \"$source\" >/dev/null && tar c .) | tar xv"
fi
}
module Params
def extract(what) i = index(what) and slice!(i, 2)[1] end;
def first_is(what) shift if what.include?(self.first); end
def self.[](*what) what.extend Params; end
def ===(argv) argv.first_is(self); end
end
# Sets git config
set_config() {
if [ -n "$GIT_NAME" ]; then _ git config user.name "$GIT_NAME"; fi
if [ -n "$GIT_EMAIL" ]; then _ git config user.email "$GIT_EMAIL"; fi
}
# ============================================================================
# Runs the deployment
run() {
if [ ! -d "$source" ]; then
echo "Source is not a directory: $source"
exit 1
fi
ARGV.extend Params
local tmpdir="$(mktemp -d)"
class CLI
# CLI options
attr_reader :prefix #=> "doc/"
attr_reader :input #=> "/home/me/projects/foo"
attr_reader :message #=> "Updated"
attr_reader :repo #=> "git@github.com:me/project.git"
attr_reader :url #=> "http://me.github.com/project"
attr_reader :branch #=> "gh-pages"
if [[ "$force" == "1" ]]; then
_ cd "$tmpdir"
_ git init
_ git checkout -b "$branch"
copy_contents "$source"
if [[ "$useenv" == "1" ]]; then set_config; fi
_ git add -A .
git_commit
git_push --force
else
_ cd "$tmpdir"
_ git clone "$repo" . -b "$branch" || ( \
_ git init && \
_ git checkout -b "$branch")
if [[ "$keep" == "0" ]]; then _ rm -rf ./*; fi
copy_contents "$source"
if [[ "$useenv" == "1" ]]; then set_config; fi
_ git add -A .
git_commit || true
git_push
fi
_ rm -rf "$tmpdir"
status_ "Done"
}
def verbose?() @verbose; end
def force?() @force; end
def simulate?() @simulate; end
git_commit() {
if [ -z "$author" ]; then
_ git commit -m "$message"
else
_ git commit -m "$message" --author "$author"
fi
}
def initialize
# Switches
@verbose = !! (ARGV.extract('--verbose') || ARGV.delete('-v'))
@simulate = !! (ARGV.extract('--simulate') || ARGV.delete('-s'))
@force = !! (ARGV.delete('--force') || ARGV.delete('-f'))
git_push() {
if [ -z "$GITHUB_TOKEN" ]; then
_ git push "${repo}" "$branch" "$@"
else
status "Pushing via \$GITHUB_TOKEN $@"
_ git push "https://${GITHUB_TOKEN}@github.com/${repospec}.git" "$branch" "$@" \
--quiet >/dev/null 2>&1 || \
( status_ "Failed to push"; exit 1 )
fi
}
# Stuff
@prefix = ARGV.extract('--prefix') || ARGV.extract('-p') || ''
@input = File.expand_path(ARGV.extract('--input') || ARGV.extract('-i') || '.')
@message = ARGV.extract('--message') || ARGV.extract('-m') || 'Update'
status() {
echo -e "\n\033[34m==>\033[0;1m" "$@\033[0m"
}
status_() {
echo -e "\033[33;1m==>\033[0m" "$@"
}
# Github info
branch = ARGV.extract('--branch') || ARGV.extract('-b') || nil
@repo, @url, @branch = get_github_info(ARGV.shift, branch)
end
_() {
echo ""
status_ "$@"
if [[ ! "$dryrun" == "1" ]]; then "$@"; fi
}
def git_current_branch
`git rev-parse --abbrev-ref HEAD`.strip
end
help() {
local cmd="$(basename $0)"
echo 'Usage:'
echo " $cmd <REPO> <SOURCE>"
echo ''
echo 'Parameters:'
echo " REPO repository to push to in 'user/repo' form"
echo " SOURCE path to upload to repository's gh-pages branch"
echo ''
echo 'Options:'
echo ' -h, --help show help screen'
echo ' -f, --force force push'
echo ' -n, --dry-run run in simulation mode'
echo ' -e, --use-env pick up arguments from environment variables'
echo ' -b, --branch use this branch name (default: gh-pages)'
echo ' -a, --author set the author'
echo ' -k, --keep keep existing files in the repo'
echo ''
echo 'Env var options:'
echo ' GITHUB_TOKEN if set, use this to push to the repo'
echo ''
echo 'Optional env vars:'
echo " Run with '-e' to enable the use of these variables."
echo " GIT_NAME set this as the repos user.name"
echo ' GIT_EMAIL set this as the repos user.email'
echo ' GITHUB_REPO substitute as the REPO (1st argument)'
echo ' GIT_SOURCE substitute as the SOURCE (2nd argument)'
echo ' GIT_BRANCH use this branch name (--branch)'
echo ''
echo 'Example:'
echo " $cmd rstacruz/myproject doc"
echo " # pushes './doc' into the gh-pages branch of rstacruz/myproject"
echo ''
echo " export GITHUB_REPO='xyz/abc'"
echo " export GIT_SOURCE='docs'"
echo " $cmd -e"
echo " # pushes './doc' into the gh-pages branch of xyz/abc"
}
def git_deploy
in_temp_path do |temppath|
status "Cloning repository"
system! "git clone #{repo} -b #{branch} #{temppath}"
#
# Defaults
#
if git_current_branch != branch
status "Warning: No #{branch} branch found in repo, creating one."
return git_deploy_force
end
force=0
dryrun=0
repospec=
source=
branch=
message="Update"
useenv=0
author=""
keep=0
copy_files input, File.join(temppath, prefix)
#
# Parse args
#
status "Committing files"
system! "git add .; git add -u; git commit -m #{message.to_s.inspect}"
while [[ "$1" =~ ^- && ! "$1" == '--' ]]; do case $1 in
-h | --help )
help
exit
;;
-b | --branch )
shift
branch="$1"
;;
-n | --dry-run )
dryrun=1
;;
-e | --use-env )
useenv=1
;;
-k | --keep )
keep=1
;;
-a | --author)
shift
author="$1"
;;
-f | --force )
force=1
;;
esac; shift; done
if [[ "$1" == '--' ]]; then shift; fi
unless simulate?
status "Updating repo"
system! "git push origin #{branch}"
end
true
end
end
if [[ "$useenv" == "1" ]] && [[ -n "$GIT_BRANCH" ]] && [[ -z "$branch" ]]; then
branch="$GIT_BRANCH"
fi
def git_deploy_force
in_temp_path do |temppath|
status "Creating new repository"
system! "git init ."
system! "git checkout -b gh-pages"
if [[ "$useenv" == "1" ]] && [[ -n "$GITHUB_REPO" ]] && [[ -n "$GIT_SOURCE" ]] && [[ -z "$2" ]]; then
repospec="$GITHUB_REPO"
source="$GIT_SOURCE"
else
repospec="$1"
source="$2"
fi
copy_files input, File.join(temppath, prefix)
: ${branch:="gh-pages"}
status "Committing files"
system! "git add . && git commit -m #{message.to_s.inspect}"
if [ -z "$source" ]; then
help
exit 1
fi
unless simulate?
status "Updating repo"
system! "git push #{repo} gh-pages:#{branch} --force"
end
true
end
end
source="`pwd -LP`/$source"
repo="https://github.com/${repospec}.git"
def get_github_info(repo, branch=nil, prefix=nil)
if github_format?(repo)
user, repo_name = repo.split('/')
r = "git@github.com:#{repo}.git"
# User page or project page?
if repo_name =~ /\.github\.com/
[r, "http://#{repo_name}/#{prefix}", branch || 'master' ]
else
[r, "http://#{user}.github.com/#{repo_name}/#{prefix}", branch || 'gh-pages' ]
end
else
[repo, nil, branch]
end
end
def run!
unless repo
print_help
exit 128
end
status "Deploying to #{repo} (branch #{branch})"
msg "NOTE: Running in simulation mode." if simulate?
msg "WARNING: If the repository has gh-pages history, it with be overriden." if force? && !simulate?
result = force? ? git_deploy_force : git_deploy
if result
puts ""
status "Done."
msg "See: #{url}" if url && !simulate?
else
tip "Failed."
exit 1
end
end
def status(str)
puts "#{c('===>',34)} #{c(str, 32)}"
end
def msg(str)
puts " #{c(str, 32)}"
end
def c(str, color)
"\033[#{color}m#{str}\033[0m"
end
def print_help
tip \
%{Usage: git update-ghpages username/repository [options]
Flags:
-f, --force Force an update (WARNING: kills the history!)
-s, --simulate Creates the repository, but doesn't push.
-v, --verbose Verbose mode
Options:
-p PATH, --prefix The prefix
-i PATH, --input Input (defaults to current directory)
-b BRANCH, --branch The branch to deploy to (defaults to gh-pages)
-m MSG, --message Commit message (defaults to 'Update')
Examples:
Update the repo 'coffee' of github user 'james' with the files from the
current directory. The files will be in http://james.github.com/coffee.
$ git update-ghpages james/coffee
Same as above, but take the files from 'doc/'.
$ git update-ghpages james/coffee -i doc
Same as the first, but the files will instead be in
http://james.github.com/coffee/manual.
$ git update-ghpages james/coffee -i doc -p manual
}.gsub(/^ {4}/, '')
end
private # Helpers
def tip(msg)
$stderr.write "#{msg}\n"
end
def github_format?(str)
str =~ /^([A-Za-z0-9\-_]+)\/([A-Za-z0-9\-_\.]+)$/
end
# Performs actions inside a temp path.
def in_temp_path(&blk)
require 'tmpdir'
Dir.mktmpdir do |dir|
Dir.chdir(dir) { yield dir }
end
end
def system!(str)
puts `#{str} 2>&1`.strip.gsub(/^/, " ")
raise "Failed with exit code #{$?.to_i}" unless $?.to_i == 0
end
# Returns the current branch name
def git_branch
`git symbolic-ref HEAD`.strip.split('/').last
end
# Copy files from source folder to another
def copy_files(from, to)
status "Copying files #{from} => #{to}..." if verbose?
Dir["#{from}/**/*"].each do |f|
next unless File.file?(f)
target = File.join(to, f.gsub(/^#{Regexp.escape from}/, ''))
FileUtils.mkdir_p File.dirname(target)
msg "%20s => %-20s" % [f, target] if verbose?
FileUtils.cp f, target
end
end
end
CLI.new.run!
run