reorganized repo
This commit is contained in:
parent
4bb5126502
commit
91c330ae01
88 changed files with 313 additions and 321 deletions
316
doc/Doxyfile
Normal file
316
doc/Doxyfile
Normal file
|
@ -0,0 +1,316 @@
|
|||
# Doxyfile 1.8.9.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "JSON for Modern C++"
|
||||
PROJECT_NUMBER = 3.0
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = .
|
||||
CREATE_SUBDIRS = NO
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = NO
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = YES
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
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 += requirement="@par Requirements\n"
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING =
|
||||
MARKDOWN_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = YES
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_PACKAGE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
EXTRACT_ANON_NSPACES = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = YES
|
||||
SORT_MEMBERS_CTORS_1ST = YES
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_FILES = NO
|
||||
SHOW_NAMESPACES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
CITE_BIB_FILES =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../src/json.hpp doxyindex.cpp
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS = nlohmann::internals
|
||||
EXAMPLE_PATH = examples
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH = images
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
USE_MDFILE_AS_MAINPAGE =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = NO
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_EXTRA_STYLESHEET = css/mylayout.css
|
||||
HTML_EXTRA_FILES =
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = YES
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = me.nlohmann.json
|
||||
DOCSET_PUBLISHER_ID = me.nlohmann
|
||||
DOCSET_PUBLISHER_NAME = Niels Lohmann
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
CHM_INDEX_ENCODING =
|
||||
BINARY_TOC = YES
|
||||
TOC_EXPAND = NO
|
||||
GENERATE_QHP = NO
|
||||
QCH_FILE =
|
||||
QHP_NAMESPACE = org.doxygen.Project
|
||||
QHP_VIRTUAL_FOLDER = doc
|
||||
QHP_CUST_FILTER_NAME =
|
||||
QHP_CUST_FILTER_ATTRS =
|
||||
QHP_SECT_FILTER_ATTRS =
|
||||
QHG_LOCATION =
|
||||
GENERATE_ECLIPSEHELP = NO
|
||||
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
DISABLE_INDEX = NO
|
||||
GENERATE_TREEVIEW = YES
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
MATHJAX_EXTENSIONS =
|
||||
MATHJAX_CODEFILE =
|
||||
SEARCHENGINE = YES
|
||||
SERVER_BASED_SEARCH = NO
|
||||
EXTERNAL_SEARCH = NO
|
||||
SEARCHENGINE_URL =
|
||||
SEARCHDATA_FILE = searchdata.xml
|
||||
EXTERNAL_SEARCH_ID =
|
||||
EXTRA_SEARCH_MAPPINGS =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
LATEX_FOOTER =
|
||||
LATEX_EXTRA_STYLESHEET =
|
||||
LATEX_EXTRA_FILES =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
RTF_SOURCE_CODE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_SUBDIR =
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the DOCBOOK output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_DOCBOOK = NO
|
||||
DOCBOOK_OUTPUT = docbook
|
||||
DOCBOOK_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = NO
|
||||
MSCGEN_PATH =
|
||||
DIA_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
DOT_NUM_THREADS = 0
|
||||
DOT_FONTNAME = Helvetica
|
||||
DOT_FONTSIZE = 10
|
||||
DOT_FONTPATH =
|
||||
CLASS_GRAPH = NO
|
||||
COLLABORATION_GRAPH = NO
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = YES
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = NO
|
||||
INCLUDED_BY_GRAPH = NO
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = NO
|
||||
DIRECTORY_GRAPH = NO
|
||||
DOT_IMAGE_FORMAT = svg
|
||||
INTERACTIVE_SVG = YES
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MSCFILE_DIRS =
|
||||
DIAFILE_DIRS =
|
||||
PLANTUML_JAR_PATH =
|
||||
PLANTUML_INCLUDE_PATH =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
64
doc/Makefile
Normal file
64
doc/Makefile
Normal file
|
@ -0,0 +1,64 @@
|
|||
SRCDIR = ../src
|
||||
|
||||
clean:
|
||||
rm -fr me.nlohmann.json.docset html
|
||||
|
||||
|
||||
##########################################################################
|
||||
# example files
|
||||
##########################################################################
|
||||
|
||||
# where are the example cpp files
|
||||
EXAMPLES = $(wildcard examples/*.cpp)
|
||||
|
||||
# create output from a stand-alone example file
|
||||
%.output: %.cpp
|
||||
make $(<:.cpp=) CPPFLAGS="-I $(SRCDIR)" CXXFLAGS="-std=c++11"
|
||||
./$(<:.cpp=) > $@
|
||||
rm $(<:.cpp=)
|
||||
|
||||
# compare created output with current output of the example files
|
||||
%.test: %.cpp
|
||||
make $(<:.cpp=) CPPFLAGS="-I $(SRCDIR)" CXXFLAGS="-std=c++11"
|
||||
./$(<:.cpp=) > $@
|
||||
diff $@ $(<:.cpp=.output)
|
||||
rm $(<:.cpp=) $@
|
||||
|
||||
# create output from all stand-alone example files
|
||||
create_output: $(EXAMPLES:.cpp=.output)
|
||||
|
||||
# check output of all stand-alone example files
|
||||
check_output: $(EXAMPLES:.cpp=.test)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Doxygen HTML documentation
|
||||
##########################################################################
|
||||
|
||||
# create Doxygen documentation
|
||||
doxygen: create_output
|
||||
doxygen
|
||||
gsed -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
gsed -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
|
||||
|
||||
##########################################################################
|
||||
# docset
|
||||
##########################################################################
|
||||
|
||||
# create docset for Dash
|
||||
docset: create_output
|
||||
cp Doxyfile Doxyfile_docset
|
||||
gsed -i 's/DISABLE_INDEX = NO/DISABLE_INDEX = YES/' Doxyfile_docset
|
||||
gsed -i 's/SEARCHENGINE = YES/SEARCHENGINE = NO/' Doxyfile_docset
|
||||
gsed -i 's/GENERATE_TREEVIEW = YES/GENERATE_TREEVIEW = NO/' Doxyfile_docset
|
||||
gsed -i 's/BINARY_TOC = YES/BINARY_TOC = NO/' Doxyfile_docset
|
||||
gsed -i 's@HTML_EXTRA_STYLESHEET = css/mylayout.css@HTML_EXTRA_STYLESHEET = css/mylayout_docset.css@' Doxyfile_docset
|
||||
rm -fr html *.docset
|
||||
doxygen Doxyfile_docset
|
||||
gsed -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
gsed -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
make -C html
|
||||
mv html/*.docset .
|
||||
gsed -i 's@<string>doxygen</string>@<string>json</string>@' me.nlohmann.json.docset/Contents/Info.plist
|
||||
rm -fr Doxyfile_docset html
|
7
doc/css/mylayout.css
Normal file
7
doc/css/mylayout.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
.memtemplate {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.memTemplParams {
|
||||
display: none;
|
||||
}
|
15
doc/css/mylayout_docset.css
Normal file
15
doc/css/mylayout_docset.css
Normal file
|
@ -0,0 +1,15 @@
|
|||
.memtemplate {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.memTemplParams {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navtab {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#top, .footer {
|
||||
display: none;
|
||||
}
|
9
doc/doxyindex.cpp
Normal file
9
doc/doxyindex.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*!
|
||||
@mainpage
|
||||
|
||||
See @ref nlohmann::basic_json
|
||||
|
||||
@copyright Niels Lohmann\n
|
||||
@include "../../LICENSE.MIT"
|
||||
*/
|
||||
|
18
doc/examples/array.cpp
Normal file
18
doc/examples/array.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON arrays
|
||||
json j_no_init_list = json::array();
|
||||
json j_empty_init_list = json::array({});
|
||||
json j_nonempty_init_list = json::array({1, 2, 3, 4});
|
||||
json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << j_no_init_list << '\n';
|
||||
std::cout << j_empty_init_list << '\n';
|
||||
std::cout << j_nonempty_init_list << '\n';
|
||||
std::cout << j_list_of_pairs << '\n';
|
||||
}
|
4
doc/examples/array.output
Normal file
4
doc/examples/array.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[]
|
||||
[]
|
||||
[1,2,3,4]
|
||||
[["one",1],["two",2]]
|
28
doc/examples/back.cpp
Normal file
28
doc/examples/back.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_object_empty(json::value_t::object);
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_array_empty(json::value_t::array);
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call back()
|
||||
//std::cout << j_null.back() << '\n'; // would throw
|
||||
std::cout << j_boolean.back() << '\n';
|
||||
std::cout << j_number_integer.back() << '\n';
|
||||
std::cout << j_number_float.back() << '\n';
|
||||
std::cout << j_object.back() << '\n';
|
||||
//std::cout << j_object_empty.back() << '\n'; // would throw
|
||||
std::cout << j_array.back() << '\n';
|
||||
//std::cout << j_array_empty.back() << '\n'; // would throw
|
||||
std::cout << j_string.back() << '\n';
|
||||
}
|
6
doc/examples/back.output
Normal file
6
doc/examples/back.output
Normal file
|
@ -0,0 +1,6 @@
|
|||
true
|
||||
17
|
||||
23.42
|
||||
2
|
||||
16
|
||||
"Hello, world"
|
12
doc/examples/basic_json.cpp
Normal file
12
doc/examples/basic_json.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value with default null value
|
||||
json j;
|
||||
|
||||
// serialize the JSON null value
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json.output
Normal file
1
doc/examples/basic_json.output
Normal file
|
@ -0,0 +1 @@
|
|||
null
|
58
doc/examples/basic_json__CompatibleArrayType.cpp
Normal file
58
doc/examples/basic_json__CompatibleArrayType.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include <json.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <forward_list>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array from std::vector
|
||||
std::vector<int> c_vector {1, 2, 3, 4};
|
||||
json j_vec(c_vector);
|
||||
|
||||
// create an array from std::deque
|
||||
std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
|
||||
json j_deque(c_deque);
|
||||
|
||||
// create an array from std::list
|
||||
std::list<bool> c_list {true, true, false, true};
|
||||
json j_list(c_list);
|
||||
|
||||
// create an array from std::forward_list
|
||||
std::forward_list<int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
|
||||
json j_flist(c_flist);
|
||||
|
||||
// create an array from std::array
|
||||
std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
|
||||
json j_array(c_array);
|
||||
|
||||
// create an array from std::set
|
||||
std::set<std::string> c_set {"one", "two", "three", "four", "one"};
|
||||
json j_set(c_set); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::unordered_set
|
||||
std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
|
||||
json j_uset(c_uset); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::multiset
|
||||
std::multiset<std::string> c_mset {"one", "two", "one", "four"};
|
||||
json j_mset(c_mset); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::unordered_multiset
|
||||
std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
|
||||
json j_umset(c_umset); // both entries for "one" are used
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << j_vec << '\n';
|
||||
std::cout << j_deque << '\n';
|
||||
std::cout << j_list << '\n';
|
||||
std::cout << j_flist << '\n';
|
||||
std::cout << j_array << '\n';
|
||||
std::cout << j_set << '\n';
|
||||
std::cout << j_uset << '\n';
|
||||
std::cout << j_mset << '\n';
|
||||
std::cout << j_umset << '\n';
|
||||
}
|
9
doc/examples/basic_json__CompatibleArrayType.output
Normal file
9
doc/examples/basic_json__CompatibleArrayType.output
Normal file
|
@ -0,0 +1,9 @@
|
|||
[1,2,3,4]
|
||||
[1.2,2.3,3.4,5.6]
|
||||
[true,true,false,true]
|
||||
[12345678909876,23456789098765,34567890987654,45678909876543]
|
||||
[1,2,3,4]
|
||||
["four","one","three","two"]
|
||||
["four","three","two","one"]
|
||||
["four","one","one","two"]
|
||||
["four","two","one","one"]
|
41
doc/examples/basic_json__CompatibleObjectType.cpp
Normal file
41
doc/examples/basic_json__CompatibleObjectType.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an object from std::map
|
||||
std::map<std::string, int> c_map
|
||||
{
|
||||
{"one", 1}, {"two", 2}, {"three", 3}
|
||||
};
|
||||
json j_map(c_map);
|
||||
|
||||
// create an object from std::unordered_map
|
||||
std::unordered_map<const char*, double> c_umap
|
||||
{
|
||||
{"one", 1.2}, {"two", 2.3}, {"three", 3.4}
|
||||
};
|
||||
json j_umap(c_umap);
|
||||
|
||||
// create an object from std::multimap
|
||||
std::multimap<std::string, bool> c_mmap
|
||||
{
|
||||
{"one", true}, {"two", true}, {"three", false}, {"three", true}
|
||||
};
|
||||
json j_mmap(c_mmap); // only one entry for key "three" is used
|
||||
|
||||
// create an object from std::unordered_multimap
|
||||
std::unordered_multimap<std::string, bool> c_ummap
|
||||
{
|
||||
{"one", true}, {"two", true}, {"three", false}, {"three", true}
|
||||
};
|
||||
json j_ummap(c_ummap); // only one entry for key "three" is used
|
||||
|
||||
// serialize the JSON objects
|
||||
std::cout << j_map << '\n';
|
||||
std::cout << j_umap << '\n';
|
||||
std::cout << j_mmap << '\n';
|
||||
std::cout << j_ummap << '\n';
|
||||
}
|
4
doc/examples/basic_json__CompatibleObjectType.output
Normal file
4
doc/examples/basic_json__CompatibleObjectType.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
{"one":1,"three":3,"two":2}
|
||||
{"one":1.2,"three":3.4,"two":2.3}
|
||||
{"one":true,"three":false,"two":true}
|
||||
{"one":true,"three":false,"two":true}
|
15
doc/examples/basic_json__array_t.cpp
Normal file
15
doc/examples/basic_json__array_t.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array_t value
|
||||
json::array_t value = {"one", "two", 3, 4.5, false};
|
||||
|
||||
// create a JSON array from the value
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json__array_t.output
Normal file
1
doc/examples/basic_json__array_t.output
Normal file
|
@ -0,0 +1 @@
|
|||
["one","two",3,4.5,false]
|
16
doc/examples/basic_json__basic_json.cpp
Normal file
16
doc/examples/basic_json__basic_json.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON array
|
||||
json j1 = {"one", "two", 3, 4.5, false};
|
||||
|
||||
// create a copy
|
||||
json j2(j1);
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j1 << " = " << j2 << '\n';
|
||||
std::cout << std::boolalpha << (j1 == j2) << '\n';
|
||||
}
|
2
doc/examples/basic_json__basic_json.output
Normal file
2
doc/examples/basic_json__basic_json.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
["one","two",3,4.5,false] = ["one","two",3,4.5,false]
|
||||
true
|
17
doc/examples/basic_json__copyassignment.cpp
Normal file
17
doc/examples/basic_json__copyassignment.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json a = 23;
|
||||
json b = 42;
|
||||
|
||||
// copy-assign a to b
|
||||
b = a;
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << a << '\n';
|
||||
std::cout << b << '\n';
|
||||
}
|
2
doc/examples/basic_json__copyassignment.output
Normal file
2
doc/examples/basic_json__copyassignment.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
23
|
||||
23
|
20
doc/examples/basic_json__list_init_t.cpp
Normal file
20
doc/examples/basic_json__list_init_t.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_empty_init_list = json({});
|
||||
json j_object = { {"one", 1}, {"two", 2} };
|
||||
json j_array = {1, 2, 3, 4};
|
||||
json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
|
||||
json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
|
||||
|
||||
// serialize the JSON value
|
||||
std::cout << j_empty_init_list << '\n';
|
||||
std::cout << j_object << '\n';
|
||||
std::cout << j_array << '\n';
|
||||
std::cout << j_nested_object << '\n';
|
||||
std::cout << j_nested_array << '\n';
|
||||
}
|
5
doc/examples/basic_json__list_init_t.output
Normal file
5
doc/examples/basic_json__list_init_t.output
Normal file
|
@ -0,0 +1,5 @@
|
|||
{}
|
||||
{"one":1,"two":2}
|
||||
[1,2,3,4]
|
||||
{"one":[1],"two":[1,2]}
|
||||
[[[1],"one"],[[1,2],"two"]]
|
16
doc/examples/basic_json__moveconstructor.cpp
Normal file
16
doc/examples/basic_json__moveconstructor.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value
|
||||
json a = 23;
|
||||
|
||||
// move contents of a to b
|
||||
json b(std::move(a));
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << a << '\n';
|
||||
std::cout << b << '\n';
|
||||
}
|
2
doc/examples/basic_json__moveconstructor.output
Normal file
2
doc/examples/basic_json__moveconstructor.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
null
|
||||
23
|
12
doc/examples/basic_json__nullptr_t.cpp
Normal file
12
doc/examples/basic_json__nullptr_t.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON null value
|
||||
json j(nullptr);
|
||||
|
||||
// serialize the JSON null value
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json__nullptr_t.output
Normal file
1
doc/examples/basic_json__nullptr_t.output
Normal file
|
@ -0,0 +1 @@
|
|||
null
|
15
doc/examples/basic_json__object_t.cpp
Normal file
15
doc/examples/basic_json__object_t.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an object_t value
|
||||
json::object_t value = { {"one", 1}, {"two", 2} };
|
||||
|
||||
// create a JSON object from the value
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON object
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json__object_t.output
Normal file
1
doc/examples/basic_json__object_t.output
Normal file
|
@ -0,0 +1 @@
|
|||
{"one":1,"two":2}
|
17
doc/examples/basic_json__size_type_basic_json.cpp
Normal file
17
doc/examples/basic_json__size_type_basic_json.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array by creating copies of a JSON value
|
||||
json value = "Hello";
|
||||
json array_0 = json(0, value);
|
||||
json array_1 = json(1, value);
|
||||
json array_5 = json(5, value);
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << array_0 << '\n';
|
||||
std::cout << array_1 << '\n';
|
||||
std::cout << array_5 << '\n';
|
||||
}
|
3
doc/examples/basic_json__size_type_basic_json.output
Normal file
3
doc/examples/basic_json__size_type_basic_json.output
Normal file
|
@ -0,0 +1,3 @@
|
|||
[]
|
||||
["Hello"]
|
||||
["Hello","Hello","Hello","Hello","Hello"]
|
24
doc/examples/basic_json__value_t.cpp
Normal file
24
doc/examples/basic_json__value_t.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create the different JSON values with default values
|
||||
json j_null(json::value_t::null);
|
||||
json j_boolean(json::value_t::boolean);
|
||||
json j_number_integer(json::value_t::number_integer);
|
||||
json j_number_float(json::value_t::number_float);
|
||||
json j_object(json::value_t::object);
|
||||
json j_array(json::value_t::array);
|
||||
json j_string(json::value_t::string);
|
||||
|
||||
// serialize the JSON values
|
||||
std::cout << j_null << '\n';
|
||||
std::cout << j_boolean << '\n';
|
||||
std::cout << j_number_integer << '\n';
|
||||
std::cout << j_number_float << '\n';
|
||||
std::cout << j_object << '\n';
|
||||
std::cout << j_array << '\n';
|
||||
std::cout << j_string << '\n';
|
||||
}
|
7
doc/examples/basic_json__value_t.output
Normal file
7
doc/examples/basic_json__value_t.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
null
|
||||
false
|
||||
0
|
||||
0
|
||||
{}
|
||||
[]
|
||||
""
|
15
doc/examples/begin.cpp
Normal file
15
doc/examples/begin.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to the first element
|
||||
json::iterator it = array.begin();
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/begin.output
Normal file
1
doc/examples/begin.output
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
15
doc/examples/cbegin.cpp
Normal file
15
doc/examples/cbegin.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
const json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to the first element
|
||||
json::const_iterator it = array.cbegin();
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/cbegin.output
Normal file
1
doc/examples/cbegin.output
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
18
doc/examples/cend.cpp
Normal file
18
doc/examples/cend.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to one past the last element
|
||||
json::const_iterator it = array.cend();
|
||||
|
||||
// decrement the iterator to point to the last element
|
||||
--it;
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/cend.output
Normal file
1
doc/examples/cend.output
Normal file
|
@ -0,0 +1 @@
|
|||
5
|
33
doc/examples/clear.cpp
Normal file
33
doc/examples/clear.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call clear()
|
||||
j_null.clear();
|
||||
j_boolean.clear();
|
||||
j_number_integer.clear();
|
||||
j_number_float.clear();
|
||||
j_object.clear();
|
||||
j_array.clear();
|
||||
j_string.clear();
|
||||
|
||||
// serialize the cleared values()
|
||||
std::cout << j_null << '\n';
|
||||
std::cout << j_boolean << '\n';
|
||||
std::cout << j_number_integer << '\n';
|
||||
std::cout << j_number_float << '\n';
|
||||
std::cout << j_object << '\n';
|
||||
std::cout << j_array << '\n';
|
||||
std::cout << j_string << '\n';
|
||||
}
|
7
doc/examples/clear.output
Normal file
7
doc/examples/clear.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
null
|
||||
false
|
||||
0
|
||||
0
|
||||
{}
|
||||
[]
|
||||
""
|
15
doc/examples/crbegin.cpp
Normal file
15
doc/examples/crbegin.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get an iterator to the reverse-beginning
|
||||
json::const_reverse_iterator it = array.crbegin();
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/crbegin.output
Normal file
1
doc/examples/crbegin.output
Normal file
|
@ -0,0 +1 @@
|
|||
5
|
18
doc/examples/crend.cpp
Normal file
18
doc/examples/crend.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get an iterator to the reverse-end
|
||||
json::const_reverse_iterator it = array.crend();
|
||||
|
||||
// increment the iterator to point to the first element
|
||||
--it;
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/crend.output
Normal file
1
doc/examples/crend.output
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
20
doc/examples/dump.cpp
Normal file
20
doc/examples/dump.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
|
||||
// call dump()
|
||||
std::cout << j_object.dump() << "\n\n";
|
||||
std::cout << j_object.dump(-1) << "\n\n";
|
||||
std::cout << j_object.dump(0) << "\n\n";
|
||||
std::cout << j_object.dump(4) << "\n\n";
|
||||
std::cout << j_array.dump() << "\n\n";
|
||||
std::cout << j_array.dump(-1) << "\n\n";
|
||||
std::cout << j_array.dump(0) << "\n\n";
|
||||
std::cout << j_array.dump(4) << "\n\n";
|
||||
}
|
34
doc/examples/dump.output
Normal file
34
doc/examples/dump.output
Normal file
|
@ -0,0 +1,34 @@
|
|||
{"one":1,"two":2}
|
||||
|
||||
{"one":1,"two":2}
|
||||
|
||||
{
|
||||
"one": 1,
|
||||
"two": 2
|
||||
}
|
||||
|
||||
{
|
||||
"one": 1,
|
||||
"two": 2
|
||||
}
|
||||
|
||||
[1,2,4,8,16]
|
||||
|
||||
[1,2,4,8,16]
|
||||
|
||||
[
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16
|
||||
]
|
||||
|
||||
[
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16
|
||||
]
|
||||
|
29
doc/examples/empty.cpp
Normal file
29
doc/examples/empty.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_object_empty(json::value_t::object);
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_array_empty(json::value_t::array);
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call empty()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.empty() << '\n';
|
||||
std::cout << j_boolean.empty() << '\n';
|
||||
std::cout << j_number_integer.empty() << '\n';
|
||||
std::cout << j_number_float.empty() << '\n';
|
||||
std::cout << j_object.empty() << '\n';
|
||||
std::cout << j_object_empty.empty() << '\n';
|
||||
std::cout << j_array.empty() << '\n';
|
||||
std::cout << j_array_empty.empty() << '\n';
|
||||
std::cout << j_string.empty() << '\n';
|
||||
}
|
9
doc/examples/empty.output
Normal file
9
doc/examples/empty.output
Normal file
|
@ -0,0 +1,9 @@
|
|||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
18
doc/examples/end.cpp
Normal file
18
doc/examples/end.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get am iterator to one past the last element
|
||||
json::iterator it = array.end();
|
||||
|
||||
// decrement the iterator to point to the last element
|
||||
--it;
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/end.output
Normal file
1
doc/examples/end.output
Normal file
|
@ -0,0 +1 @@
|
|||
5
|
28
doc/examples/front.cpp
Normal file
28
doc/examples/front.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_object_empty(json::value_t::object);
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_array_empty(json::value_t::array);
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call front()
|
||||
//std::cout << j_null.front() << '\n'; // would throw
|
||||
std::cout << j_boolean.front() << '\n';
|
||||
std::cout << j_number_integer.front() << '\n';
|
||||
std::cout << j_number_float.front() << '\n';
|
||||
std::cout << j_object.front() << '\n';
|
||||
//std::cout << j_object_empty.front() << '\n'; // would throw
|
||||
std::cout << j_array.front() << '\n';
|
||||
//std::cout << j_array_empty.front() << '\n'; // would throw
|
||||
std::cout << j_string.front() << '\n';
|
||||
}
|
6
doc/examples/front.output
Normal file
6
doc/examples/front.output
Normal file
|
@ -0,0 +1,6 @@
|
|||
true
|
||||
17
|
||||
23.42
|
||||
1
|
||||
1
|
||||
"Hello, world"
|
25
doc/examples/is_array.cpp
Normal file
25
doc/examples/is_array.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_array()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_array() << '\n';
|
||||
std::cout << j_boolean.is_array() << '\n';
|
||||
std::cout << j_number_integer.is_array() << '\n';
|
||||
std::cout << j_number_float.is_array() << '\n';
|
||||
std::cout << j_object.is_array() << '\n';
|
||||
std::cout << j_array.is_array() << '\n';
|
||||
std::cout << j_string.is_array() << '\n';
|
||||
}
|
7
doc/examples/is_array.output
Normal file
7
doc/examples/is_array.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
25
doc/examples/is_boolean.cpp
Normal file
25
doc/examples/is_boolean.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_boolean()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_boolean() << '\n';
|
||||
std::cout << j_boolean.is_boolean() << '\n';
|
||||
std::cout << j_number_integer.is_boolean() << '\n';
|
||||
std::cout << j_number_float.is_boolean() << '\n';
|
||||
std::cout << j_object.is_boolean() << '\n';
|
||||
std::cout << j_array.is_boolean() << '\n';
|
||||
std::cout << j_string.is_boolean() << '\n';
|
||||
}
|
7
doc/examples/is_boolean.output
Normal file
7
doc/examples/is_boolean.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
25
doc/examples/is_null.cpp
Normal file
25
doc/examples/is_null.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_null()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_null() << '\n';
|
||||
std::cout << j_boolean.is_null() << '\n';
|
||||
std::cout << j_number_integer.is_null() << '\n';
|
||||
std::cout << j_number_float.is_null() << '\n';
|
||||
std::cout << j_object.is_null() << '\n';
|
||||
std::cout << j_array.is_null() << '\n';
|
||||
std::cout << j_string.is_null() << '\n';
|
||||
}
|
7
doc/examples/is_null.output
Normal file
7
doc/examples/is_null.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
25
doc/examples/is_number.cpp
Normal file
25
doc/examples/is_number.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_number()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_number() << '\n';
|
||||
std::cout << j_boolean.is_number() << '\n';
|
||||
std::cout << j_number_integer.is_number() << '\n';
|
||||
std::cout << j_number_float.is_number() << '\n';
|
||||
std::cout << j_object.is_number() << '\n';
|
||||
std::cout << j_array.is_number() << '\n';
|
||||
std::cout << j_string.is_number() << '\n';
|
||||
}
|
7
doc/examples/is_number.output
Normal file
7
doc/examples/is_number.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
25
doc/examples/is_number_float.cpp
Normal file
25
doc/examples/is_number_float.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_number_float()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_number_float() << '\n';
|
||||
std::cout << j_boolean.is_number_float() << '\n';
|
||||
std::cout << j_number_integer.is_number_float() << '\n';
|
||||
std::cout << j_number_float.is_number_float() << '\n';
|
||||
std::cout << j_object.is_number_float() << '\n';
|
||||
std::cout << j_array.is_number_float() << '\n';
|
||||
std::cout << j_string.is_number_float() << '\n';
|
||||
}
|
7
doc/examples/is_number_float.output
Normal file
7
doc/examples/is_number_float.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
25
doc/examples/is_number_integer.cpp
Normal file
25
doc/examples/is_number_integer.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_number_integer()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_number_integer() << '\n';
|
||||
std::cout << j_boolean.is_number_integer() << '\n';
|
||||
std::cout << j_number_integer.is_number_integer() << '\n';
|
||||
std::cout << j_number_float.is_number_integer() << '\n';
|
||||
std::cout << j_object.is_number_integer() << '\n';
|
||||
std::cout << j_array.is_number_integer() << '\n';
|
||||
std::cout << j_string.is_number_integer() << '\n';
|
||||
}
|
7
doc/examples/is_number_integer.output
Normal file
7
doc/examples/is_number_integer.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
25
doc/examples/is_object.cpp
Normal file
25
doc/examples/is_object.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_object()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_object() << '\n';
|
||||
std::cout << j_boolean.is_object() << '\n';
|
||||
std::cout << j_number_integer.is_object() << '\n';
|
||||
std::cout << j_number_float.is_object() << '\n';
|
||||
std::cout << j_object.is_object() << '\n';
|
||||
std::cout << j_array.is_object() << '\n';
|
||||
std::cout << j_string.is_object() << '\n';
|
||||
}
|
7
doc/examples/is_object.output
Normal file
7
doc/examples/is_object.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
25
doc/examples/is_string.cpp
Normal file
25
doc/examples/is_string.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call is_string()
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << j_null.is_string() << '\n';
|
||||
std::cout << j_boolean.is_string() << '\n';
|
||||
std::cout << j_number_integer.is_string() << '\n';
|
||||
std::cout << j_number_float.is_string() << '\n';
|
||||
std::cout << j_object.is_string() << '\n';
|
||||
std::cout << j_array.is_string() << '\n';
|
||||
std::cout << j_string.is_string() << '\n';
|
||||
}
|
7
doc/examples/is_string.output
Normal file
7
doc/examples/is_string.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
24
doc/examples/max_size.cpp
Normal file
24
doc/examples/max_size.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call max_size()
|
||||
std::cout << j_null.max_size() << '\n';
|
||||
std::cout << j_boolean.max_size() << '\n';
|
||||
std::cout << j_number_integer.max_size() << '\n';
|
||||
std::cout << j_number_float.max_size() << '\n';
|
||||
std::cout << j_object.max_size() << '\n';
|
||||
std::cout << j_array.max_size() << '\n';
|
||||
std::cout << j_string.max_size() << '\n';
|
||||
}
|
7
doc/examples/max_size.output
Normal file
7
doc/examples/max_size.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
256204778801521550
|
||||
1152921504606846975
|
||||
1
|
17
doc/examples/object.cpp
Normal file
17
doc/examples/object.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON arrays
|
||||
json j_no_init_list = json::object();
|
||||
json j_empty_init_list = json::object({});
|
||||
json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
|
||||
//json j_invalid_list = json::object({ "one", 1 }); // would throw
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << j_no_init_list << '\n';
|
||||
std::cout << j_empty_init_list << '\n';
|
||||
std::cout << j_list_of_pairs << '\n';
|
||||
}
|
3
doc/examples/object.output
Normal file
3
doc/examples/object.output
Normal file
|
@ -0,0 +1,3 @@
|
|||
{}
|
||||
{}
|
||||
{"one":1,"two":2}
|
15
doc/examples/rbegin.cpp
Normal file
15
doc/examples/rbegin.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get an iterator to the reverse-beginning
|
||||
json::reverse_iterator it = array.rbegin();
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/rbegin.output
Normal file
1
doc/examples/rbegin.output
Normal file
|
@ -0,0 +1 @@
|
|||
5
|
18
doc/examples/rend.cpp
Normal file
18
doc/examples/rend.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array value
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
|
||||
// get an iterator to the reverse-end
|
||||
json::reverse_iterator it = array.rend();
|
||||
|
||||
// increment the iterator to point to the first element
|
||||
--it;
|
||||
|
||||
// serialize the element that the iterator points to
|
||||
std::cout << *it << '\n';
|
||||
}
|
1
doc/examples/rend.output
Normal file
1
doc/examples/rend.output
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
28
doc/examples/size.cpp
Normal file
28
doc/examples/size.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_object_empty(json::value_t::object);
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_array_empty(json::value_t::array);
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call size()
|
||||
std::cout << j_null.size() << '\n';
|
||||
std::cout << j_boolean.size() << '\n';
|
||||
std::cout << j_number_integer.size() << '\n';
|
||||
std::cout << j_number_float.size() << '\n';
|
||||
std::cout << j_object.size() << '\n';
|
||||
std::cout << j_object_empty.size() << '\n';
|
||||
std::cout << j_array.size() << '\n';
|
||||
std::cout << j_array_empty.size() << '\n';
|
||||
std::cout << j_string.size() << '\n';
|
||||
}
|
9
doc/examples/size.output
Normal file
9
doc/examples/size.output
Normal file
|
@ -0,0 +1,9 @@
|
|||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
0
|
||||
5
|
||||
0
|
||||
1
|
221
doc/git-update-ghpages
Executable file
221
doc/git-update-ghpages
Executable file
|
@ -0,0 +1,221 @@
|
|||
#!/usr/bin/env ruby
|
||||
# git update-ghpages user/repo -b gh-pages -p manual/ -i
|
||||
|
||||
require 'fileutils'
|
||||
require 'tmpdir'
|
||||
|
||||
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
|
||||
|
||||
# ============================================================================
|
||||
|
||||
ARGV.extend Params
|
||||
|
||||
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"
|
||||
|
||||
def verbose?() @verbose; end
|
||||
def force?() @force; end
|
||||
def simulate?() @simulate; end
|
||||
|
||||
def initialize
|
||||
# Switches
|
||||
@verbose = !! (ARGV.extract('--verbose') || ARGV.delete('-v'))
|
||||
@simulate = !! (ARGV.extract('--simulate') || ARGV.delete('-s'))
|
||||
@force = !! (ARGV.delete('--force') || ARGV.delete('-f'))
|
||||
|
||||
# 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'
|
||||
|
||||
# Github info
|
||||
branch = ARGV.extract('--branch') || ARGV.extract('-b') || nil
|
||||
@repo, @url, @branch = get_github_info(ARGV.shift, branch)
|
||||
end
|
||||
|
||||
def git_current_branch
|
||||
`git rev-parse --abbrev-ref HEAD`.strip
|
||||
end
|
||||
|
||||
def git_deploy
|
||||
in_temp_path do |temppath|
|
||||
status "Cloning repository"
|
||||
system! "git clone #{repo} -b #{branch} #{temppath}"
|
||||
|
||||
if git_current_branch != branch
|
||||
status "Warning: No #{branch} branch found in repo, creating one."
|
||||
return git_deploy_force
|
||||
end
|
||||
|
||||
copy_files input, File.join(temppath, prefix)
|
||||
|
||||
status "Committing files"
|
||||
system! "git add .; git add -u; git commit -m #{message.to_s.inspect}"
|
||||
|
||||
unless simulate?
|
||||
status "Updating repo"
|
||||
system! "git push origin #{branch}"
|
||||
end
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def git_deploy_force
|
||||
in_temp_path do |temppath|
|
||||
status "Creating new repository"
|
||||
system! "git init ."
|
||||
system! "git checkout -b gh-pages"
|
||||
|
||||
copy_files input, File.join(temppath, prefix)
|
||||
|
||||
status "Committing files"
|
||||
system! "git add . && git commit -m #{message.to_s.inspect}"
|
||||
|
||||
unless simulate?
|
||||
status "Updating repo"
|
||||
system! "git push #{repo} gh-pages:#{branch} --force"
|
||||
end
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
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!
|
435
doc/images/range-begin-end.svg
Normal file
435
doc/images/range-begin-end.svg
Normal file
|
@ -0,0 +1,435 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="545.89282"
|
||||
height="156.9409"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="range-begin-end.svg">
|
||||
<defs
|
||||
id="defs4">
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path6525"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path6519"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<linearGradient
|
||||
id="linearGradient5488">
|
||||
<stop
|
||||
style="stop-color:#c1b1b1;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop5490" />
|
||||
<stop
|
||||
style="stop-color:#e3e3e3;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop5492" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4040">
|
||||
<stop
|
||||
style="stop-color:#b6b6b6;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4042" />
|
||||
<stop
|
||||
style="stop-color:#e3e3e3;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4044" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5488"
|
||||
id="linearGradient6284"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="81"
|
||||
y1="1001.3622"
|
||||
x2="81"
|
||||
y2="971.36218" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5488-2"
|
||||
id="linearGradient6284-3"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="81"
|
||||
y1="1001.3622"
|
||||
x2="81"
|
||||
y2="971.36218" />
|
||||
<linearGradient
|
||||
id="linearGradient5488-2">
|
||||
<stop
|
||||
style="stop-color:#c1b1b1;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop5490-5" />
|
||||
<stop
|
||||
style="stop-color:#e3e3e3;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop5492-8" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5488-0"
|
||||
id="linearGradient6284-5"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="81"
|
||||
y1="1001.3622"
|
||||
x2="81"
|
||||
y2="971.36218" />
|
||||
<linearGradient
|
||||
id="linearGradient5488-0">
|
||||
<stop
|
||||
style="stop-color:#c1b1b1;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop5490-1" />
|
||||
<stop
|
||||
style="stop-color:#e3e3e3;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop5492-3" />
|
||||
</linearGradient>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mend-8"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path6525-3"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)" />
|
||||
</marker>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5488"
|
||||
id="linearGradient9026"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="81"
|
||||
y1="1001.3622"
|
||||
x2="81"
|
||||
y2="971.36218" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="332.80082"
|
||||
inkscape:cy="165.04542"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1680"
|
||||
inkscape:window-height="993"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="34"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-bbox="true"
|
||||
inkscape:object-nodes="true"
|
||||
inkscape:snap-smooth-nodes="false"
|
||||
inkscape:bbox-nodes="false"
|
||||
inkscape:snap-bbox-edge-midpoints="false"
|
||||
inkscape:object-paths="true"
|
||||
fit-margin-top="10"
|
||||
fit-margin-right="10"
|
||||
fit-margin-bottom="10"
|
||||
fit-margin-left="10" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-26.107143,-893.4807)">
|
||||
<g
|
||||
id="g7184">
|
||||
<path
|
||||
inkscape:tile-y0="219"
|
||||
inkscape:tile-x0="51"
|
||||
inkscape:tile-h="30.00002"
|
||||
inkscape:tile-w="29.999997"
|
||||
inkscape:tile-cy="234.00001"
|
||||
inkscape:tile-cx="65.999998"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3006"
|
||||
d="m 80.999997,1001.3622 -29.999997,0 0,-30.00002 29.999997,0 z"
|
||||
style="fill:url(#linearGradient9026);fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<use
|
||||
height="300"
|
||||
width="600"
|
||||
style="fill:none"
|
||||
id="use4010"
|
||||
transform="translate(29.999997,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
id="use4012"
|
||||
transform="translate(59.999994,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4014"
|
||||
transform="translate(89.999991,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4016"
|
||||
transform="translate(119.99999,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4018"
|
||||
transform="translate(149.99998,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4020"
|
||||
transform="translate(179.99998,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4022"
|
||||
transform="translate(209.99998,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4024"
|
||||
transform="translate(239.99998,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4026"
|
||||
transform="translate(269.99997,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4028"
|
||||
transform="translate(299.99997,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4030"
|
||||
transform="translate(329.99997,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4032"
|
||||
transform="translate(359.99996,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4034"
|
||||
transform="translate(389.99996,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4036"
|
||||
transform="translate(419.99996,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<use
|
||||
id="use4038"
|
||||
transform="translate(449.99995,0)"
|
||||
xlink:href="#path3006"
|
||||
inkscape:tiled-clone-of="#path3006"
|
||||
y="0"
|
||||
x="0"
|
||||
width="600"
|
||||
height="300" />
|
||||
<path
|
||||
inkscape:tile-y0="219"
|
||||
inkscape:tile-x0="51"
|
||||
inkscape:tile-h="30.00002"
|
||||
inkscape:tile-w="29.999997"
|
||||
inkscape:tile-cy="234.00001"
|
||||
inkscape:tile-cx="65.999998"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3006-3"
|
||||
d="m 560.99995,1001.3622 -30,0 0,-30.00002 30,0 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:2, 2;stroke-dashoffset:0;marker-start:none" />
|
||||
</g>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:55.00000119%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;fill:#000000;fill-opacity:1;stroke:none;font-family:Droid Sans;-inkscape-font-specification:Droid Sans"
|
||||
x="392.94931"
|
||||
y="1040.2404"
|
||||
id="text6504"
|
||||
sodipodi:linespacing="55.000001%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan6506"
|
||||
x="392.94931"
|
||||
y="1040.2404"
|
||||
rotate="0 0 0 0 0 0 0 0 0.50000191 0 0 0 0 0 0 0 0 0 0 0 0 0"
|
||||
dy="0"
|
||||
dx="0"
|
||||
style="font-size:12.80000019px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans">Past-the-last element</tspan></text>
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Mend)"
|
||||
d="m 531.84531,279.29187 c 14.75083,-11.1311 12.86656,-14.42379 15.15229,-29.29442"
|
||||
id="path6510"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,752.36218)"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<g
|
||||
id="g7203"
|
||||
transform="translate(-40,-18.482143)">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 128.39286,947.36218 -51.785717,0 0,-21.51786 51.785717,0 z"
|
||||
id="use6288-9"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:tile-x0="51"
|
||||
inkscape:tile-y0="219" />
|
||||
<text
|
||||
transform="translate(0,752.36218)"
|
||||
sodipodi:linespacing="55.000001%"
|
||||
id="text7176"
|
||||
y="189.10715"
|
||||
x="80.535713"
|
||||
style="font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:55.00000119%;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
|
||||
xml:space="preserve"><tspan
|
||||
y="189.10715"
|
||||
x="80.535713"
|
||||
id="tspan7178"
|
||||
sodipodi:role="line">begin</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
id="g7238"
|
||||
transform="translate(20.035895,11.306019)">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 538.39286,914.19254 -37.50001,0 0,-21.51786 37.50001,0 z"
|
||||
id="use6288-9-7"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:tile-x0="51"
|
||||
inkscape:tile-y0="219" />
|
||||
<text
|
||||
sodipodi:linespacing="55.000001%"
|
||||
id="text7176-3"
|
||||
y="908.29968"
|
||||
x="504.82141"
|
||||
style="font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:55.00000119%;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
|
||||
xml:space="preserve"><tspan
|
||||
y="908.29968"
|
||||
x="504.82141"
|
||||
id="tspan7178-7"
|
||||
sodipodi:role="line">end</tspan></text>
|
||||
</g>
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-mid:none;marker-end:url(#Arrow1Mend)"
|
||||
d="M 60.16588,176.51786 C 64.809921,191.17027 67.41717,201.02245 68.196339,219"
|
||||
id="path7243"
|
||||
inkscape:connector-curvature="0"
|
||||
transform="translate(0,752.36218)"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-mid:none;marker-end:url(#Arrow1Mend)"
|
||||
d="m 540.40821,925.49856 c 2.63474,15.08647 5.72454,31.23577 6.06617,45.86362"
|
||||
id="path7243-8"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 14 KiB |
1232
doc/images/range-rbegin-rend.svg
Normal file
1232
doc/images/range-rbegin-rend.svg
Normal file
File diff suppressed because it is too large
Load diff
After Width: | Height: | Size: 40 KiB |
Loading…
Add table
Add a link
Reference in a new issue