reorganized repo
This commit is contained in:
parent
4bb5126502
commit
91c330ae01
88 changed files with 313 additions and 321 deletions
68
Makefile
68
Makefile
|
@ -2,66 +2,43 @@
|
||||||
RE2C = re2c
|
RE2C = re2c
|
||||||
SED = sed
|
SED = sed
|
||||||
|
|
||||||
# additional flags
|
# main target
|
||||||
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal
|
|
||||||
|
|
||||||
all: json_unit
|
all: json_unit
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
clean:
|
clean:
|
||||||
rm -f json_unit json_benchmarks
|
rm -f json_unit json_benchmarks
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# unit tests
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
# additional flags
|
||||||
|
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal
|
||||||
|
|
||||||
# build unit tests
|
# build unit tests
|
||||||
json_unit: test/unit.cpp src/json.hpp test/catch.hpp
|
json_unit: test/unit.cpp src/json.hpp test/catch.hpp
|
||||||
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@
|
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@
|
||||||
|
|
||||||
# execute the unit tests and check documentation
|
|
||||||
check: json_unit
|
|
||||||
./json_unit "*"
|
|
||||||
make check -C docs/examples
|
|
||||||
|
|
||||||
doxygen: update_docs src/json.hpp
|
##########################################################################
|
||||||
doxygen
|
# static analyzer
|
||||||
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: update_docs src/json.hpp
|
# call cppcheck on the main header file
|
||||||
cp Doxyfile Doxyfile_docset
|
cppcheck:
|
||||||
gsed -i 's/DISABLE_INDEX = NO/DISABLE_INDEX = YES/' Doxyfile_docset
|
cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp
|
||||||
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 = docs/mylayout.css@HTML_EXTRA_STYLESHEET = docs/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
|
|
||||||
|
|
||||||
# update online documentation
|
|
||||||
update_doxygen_online:
|
##########################################################################
|
||||||
make re2c pretty doxygen
|
# maintainer targets
|
||||||
rm -fr /tmp/github-html
|
##########################################################################
|
||||||
cp -r html /tmp/github-html
|
|
||||||
git checkout gh-pages
|
|
||||||
rm -fr html
|
|
||||||
mv /tmp/github-html html
|
|
||||||
-cd html ; git rm $(shell git ls-files --deleted)
|
|
||||||
git add html
|
|
||||||
git commit -m "Doxygen update"
|
|
||||||
git checkout master
|
|
||||||
|
|
||||||
# create scanner with re2c
|
# create scanner with re2c
|
||||||
re2c: src/json.hpp.re2c
|
re2c: src/json.hpp.re2c
|
||||||
$(RE2C) -b -s -i --no-generation-date $< | $(SED) '1d' > src/json.hpp
|
$(RE2C) -b -s -i --no-generation-date $< | $(SED) '1d' > src/json.hpp
|
||||||
|
|
||||||
# static analyser
|
|
||||||
cppcheck:
|
|
||||||
cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp
|
|
||||||
|
|
||||||
# pretty printer
|
# pretty printer
|
||||||
pretty:
|
pretty:
|
||||||
astyle --style=allman --indent=spaces=4 --indent-modifiers \
|
astyle --style=allman --indent=spaces=4 --indent-modifiers \
|
||||||
|
@ -71,9 +48,10 @@ pretty:
|
||||||
--lineend=linux --preserve-date --suffix=none \
|
--lineend=linux --preserve-date --suffix=none \
|
||||||
src/json.hpp src/json.hpp.re2c test/unit.cpp benchmarks/benchmarks.cpp docs/examples/*.cpp
|
src/json.hpp src/json.hpp.re2c test/unit.cpp benchmarks/benchmarks.cpp docs/examples/*.cpp
|
||||||
|
|
||||||
# update docs
|
|
||||||
update_docs:
|
##########################################################################
|
||||||
make create -C docs/examples
|
# benchmarks
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
# benchmarks
|
# benchmarks
|
||||||
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
|
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
|
||||||
|
|
|
@ -28,7 +28,7 @@ INHERIT_DOCS = YES
|
||||||
SEPARATE_MEMBER_PAGES = YES
|
SEPARATE_MEMBER_PAGES = YES
|
||||||
TAB_SIZE = 4
|
TAB_SIZE = 4
|
||||||
ALIASES = "complexity=@par Complexity\n"
|
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 docs/examples/\2.cpp -o \2 @endverbatim."
|
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"
|
ALIASES += requirement="@par Requirements\n"
|
||||||
TCL_SUBST =
|
TCL_SUBST =
|
||||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||||
|
@ -101,7 +101,7 @@ WARN_LOGFILE =
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options related to the input files
|
# Configuration options related to the input files
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
INPUT = src/json.hpp docs/doxyindex.cpp
|
INPUT = ../src/json.hpp doxyindex.cpp
|
||||||
INPUT_ENCODING = UTF-8
|
INPUT_ENCODING = UTF-8
|
||||||
FILE_PATTERNS =
|
FILE_PATTERNS =
|
||||||
RECURSIVE = NO
|
RECURSIVE = NO
|
||||||
|
@ -109,10 +109,10 @@ EXCLUDE =
|
||||||
EXCLUDE_SYMLINKS = NO
|
EXCLUDE_SYMLINKS = NO
|
||||||
EXCLUDE_PATTERNS =
|
EXCLUDE_PATTERNS =
|
||||||
EXCLUDE_SYMBOLS = nlohmann::internals
|
EXCLUDE_SYMBOLS = nlohmann::internals
|
||||||
EXAMPLE_PATH = docs/examples
|
EXAMPLE_PATH = examples
|
||||||
EXAMPLE_PATTERNS =
|
EXAMPLE_PATTERNS =
|
||||||
EXAMPLE_RECURSIVE = NO
|
EXAMPLE_RECURSIVE = NO
|
||||||
IMAGE_PATH = docs/images
|
IMAGE_PATH = images
|
||||||
INPUT_FILTER =
|
INPUT_FILTER =
|
||||||
FILTER_PATTERNS =
|
FILTER_PATTERNS =
|
||||||
FILTER_SOURCE_FILES = NO
|
FILTER_SOURCE_FILES = NO
|
||||||
|
@ -145,7 +145,7 @@ HTML_FILE_EXTENSION = .html
|
||||||
HTML_HEADER =
|
HTML_HEADER =
|
||||||
HTML_FOOTER =
|
HTML_FOOTER =
|
||||||
HTML_STYLESHEET =
|
HTML_STYLESHEET =
|
||||||
HTML_EXTRA_STYLESHEET = docs/mylayout.css
|
HTML_EXTRA_STYLESHEET = css/mylayout.css
|
||||||
HTML_EXTRA_FILES =
|
HTML_EXTRA_FILES =
|
||||||
HTML_COLORSTYLE_HUE = 220
|
HTML_COLORSTYLE_HUE = 220
|
||||||
HTML_COLORSTYLE_SAT = 100
|
HTML_COLORSTYLE_SAT = 100
|
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
|
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!
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
@ -1,41 +0,0 @@
|
||||||
```cpp
|
|
||||||
iterator begin();
|
|
||||||
const_iterator begin() const;
|
|
||||||
const_iterator cbegin() const;
|
|
||||||
```
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
Returns an iterator to the first value in the JSON container. If the JSON container is empty, the returned iterator will be equal to [`end()`](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::end).
|
|
||||||
|
|
||||||
![illustration of iterators](http://upload.cppreference.com/mwiki/images/1/1b/range-begin-end.svg)
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
None.
|
|
||||||
|
|
||||||
## Return value
|
|
||||||
|
|
||||||
Iterator to the first value. Note the return value its deferencabilty depends on the different value types:
|
|
||||||
|
|
||||||
| value type | deferenceable | description |
|
|
||||||
| ---------- | ------------- | ----------- |
|
|
||||||
| null | no | `null` has no value, always equal to [`end()`](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::end) |
|
|
||||||
| boolean | yes | iterator to the boolean value |
|
|
||||||
| string | yes | iterator to the string value |
|
|
||||||
| number | yes | iterator to the number value |
|
|
||||||
| object | only if object is not empty | iterator to the begin of the object |
|
|
||||||
| array | only if array is not empty | iterator to the begin of the array |
|
|
||||||
|
|
||||||
## Complexity
|
|
||||||
|
|
||||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
|
||||||
|
|
||||||
## Exceptions
|
|
||||||
|
|
||||||
None. The function's noexcept-specification is `noexcept`.
|
|
||||||
|
|
||||||
## See also
|
|
||||||
|
|
||||||
- [**end**, **cend**](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::end)<br>
|
|
||||||
returns an iterator to the end
|
|
|
@ -1,55 +0,0 @@
|
||||||
# nlohmann::basic_json::empty
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
bool empty() const noexcept;
|
|
||||||
```
|
|
||||||
|
|
||||||
Checks if the container has no elements; that is, whether `begin() == end()`.
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
(none)
|
|
||||||
|
|
||||||
## Return value
|
|
||||||
|
|
||||||
`true` if the container is empty, `false` otherwise. Note that the JSON types string, number, and boolean are never empty, null values are always empty.
|
|
||||||
|
|
||||||
## Exceptions
|
|
||||||
|
|
||||||
`noexcept` specification: `noexcept`.
|
|
||||||
|
|
||||||
## Complexity
|
|
||||||
|
|
||||||
Constant (assuming types `ObjectType` and `ArrayType` satisfy the [Container](http://en.cppreference.com/w/cpp/concept/Container) concept).
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
The following code uses empty to check if a `json` container contains any elements:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
#include <json.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
nlohman::json numbers;
|
|
||||||
std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n';
|
|
||||||
|
|
||||||
numbers.push_back(42);
|
|
||||||
numbers.push_back(13317);
|
|
||||||
std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n';
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Output
|
|
||||||
|
|
||||||
Initially, numbers.empty(): 1
|
|
||||||
After adding elements, numbers.empty(): 0
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
The `empty` member function is part of the [Container](http://en.cppreference.com/w/cpp/concept/Container) requirement.
|
|
||||||
|
|
||||||
## See also
|
|
||||||
|
|
||||||
- `size()`
|
|
|
@ -1,25 +0,0 @@
|
||||||
SRCDIR = ../../src
|
|
||||||
|
|
||||||
EXAMPLES = $(wildcard *.cpp)
|
|
||||||
|
|
||||||
all:
|
|
||||||
@echo "check"
|
|
||||||
@echo "create"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(EXAMPLES:.cpp=) $(EXAMPLES:.cpp=.output) $(EXAMPLES:.cpp=.test)
|
|
||||||
|
|
||||||
%.output: %.cpp
|
|
||||||
make $(<:.cpp=) CPPFLAGS="-I $(SRCDIR)" CXXFLAGS="-std=c++11"
|
|
||||||
./$(<:.cpp=) > $@
|
|
||||||
rm $(<:.cpp=)
|
|
||||||
|
|
||||||
%.test: %.cpp
|
|
||||||
make $(<:.cpp=) CPPFLAGS="-I $(SRCDIR)" CXXFLAGS="-std=c++11"
|
|
||||||
./$(<:.cpp=) > $@
|
|
||||||
diff $@ $(<:.cpp=.output)
|
|
||||||
rm $(<:.cpp=) $@
|
|
||||||
|
|
||||||
create: $(EXAMPLES:.cpp=.output)
|
|
||||||
|
|
||||||
check: $(EXAMPLES:.cpp=.test)
|
|
143
docs/index.md
143
docs/index.md
|
@ -1,143 +0,0 @@
|
||||||
# nlohmann::basic_json
|
|
||||||
|
|
||||||
Defined in header `<json.hpp>`
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
template <
|
|
||||||
template<typename U, typename V, typename... Args> class ObjectType = std::map,
|
|
||||||
template<typename U, typename... Args> class ArrayType = std::vector,
|
|
||||||
class StringType = std::string,
|
|
||||||
class BooleanType = bool,
|
|
||||||
class NumberIntegerType = int64_t,
|
|
||||||
class NumberFloatType = double,
|
|
||||||
template<typename U> class Allocator = std::allocator
|
|
||||||
> class basic_json;
|
|
||||||
```
|
|
||||||
|
|
||||||
## Template Parameters
|
|
||||||
|
|
||||||
- `ObjectType` - The type to store collection of name/value pairs. It can be any associative container that can hold key-value pairs as long as the key type is the same as `StringType`. The value type is again `nlohmann::basic_json`. The parameter `ObjectType` defaults to [`std::map`](http://en.cppreference.com/w/cpp/container/map).
|
|
||||||
- `ArrayType` - The type to store ordered value lists. It can be any sequence container. The parameter `ArrayType` defaults to a [`std::vector`](http://en.cppreference.com/w/cpp/container/vector) whose elements are of type `nlohmann::basic_json`.
|
|
||||||
- `StringType` - The type to store string values. The parameter `StringType` defaults to [`std::string`](http://en.cppreference.com/w/cpp/string/basic_string).
|
|
||||||
- `BooleanType`
|
|
||||||
- `NumberIntegerType`
|
|
||||||
- `NumberFloatType`
|
|
||||||
- `Allocator` - An allocator that is used to acquire memory to store the elements. The type must meet the requirements of [`Allocator`](http://en.cppreference.com/w/cpp/concept/Allocator).
|
|
||||||
|
|
||||||
## Specializations
|
|
||||||
|
|
||||||
A standard JSON type `nlohmann::json` is defined in `<json.hpp>` which uses the default types:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
using json = basic_json<
|
|
||||||
std::map,
|
|
||||||
std::vector,
|
|
||||||
std::string,
|
|
||||||
bool,
|
|
||||||
int64_t,
|
|
||||||
double,
|
|
||||||
std::allocator
|
|
||||||
>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Iterator invalidation
|
|
||||||
|
|
||||||
## Member types
|
|
||||||
|
|
||||||
- `value_type`
|
|
||||||
- `reference`
|
|
||||||
- `const_reference`
|
|
||||||
- `difference_type`
|
|
||||||
- `size_type`
|
|
||||||
- `allocator_type`
|
|
||||||
- `pointer`
|
|
||||||
- `const_pointer`
|
|
||||||
- `iterator`
|
|
||||||
- `const_iterator`
|
|
||||||
- `reverse_iterator`
|
|
||||||
- `const_reverse_iterator`
|
|
||||||
- `object_t`
|
|
||||||
- `array_t`
|
|
||||||
- `string_t`
|
|
||||||
- `boolean_t`
|
|
||||||
- `number_integer_t`
|
|
||||||
- `number_float_t`
|
|
||||||
- `list_init_t`
|
|
||||||
- `json_value`
|
|
||||||
|
|
||||||
## Member functions
|
|
||||||
|
|
||||||
- constructor
|
|
||||||
- destructor
|
|
||||||
- `operator=`
|
|
||||||
- `get_allocator`
|
|
||||||
|
|
||||||
### Object inspection
|
|
||||||
|
|
||||||
- `dump`
|
|
||||||
- `type`
|
|
||||||
- `is_null`
|
|
||||||
- `is_boolean`
|
|
||||||
- `is_number`
|
|
||||||
- `is_object`
|
|
||||||
- `is_array`
|
|
||||||
- `is_string`
|
|
||||||
- `operator value_t`
|
|
||||||
- `std::hash`
|
|
||||||
|
|
||||||
### Value conversion
|
|
||||||
|
|
||||||
- `get`
|
|
||||||
- implicit conversion
|
|
||||||
|
|
||||||
### Element access
|
|
||||||
|
|
||||||
- `at`
|
|
||||||
- `operator[]`
|
|
||||||
- `erase`
|
|
||||||
- `find`
|
|
||||||
- `count`
|
|
||||||
|
|
||||||
### Iterators
|
|
||||||
|
|
||||||
- `begin` / `cbegin`
|
|
||||||
- `end` / `cend`
|
|
||||||
- `rbegin` / `crbegin`
|
|
||||||
- `rend` / `crend`
|
|
||||||
|
|
||||||
### Capacity
|
|
||||||
|
|
||||||
- [`empty`](empty)
|
|
||||||
- `size`
|
|
||||||
- `max_size`
|
|
||||||
|
|
||||||
### Modifiers
|
|
||||||
|
|
||||||
- `clear`
|
|
||||||
- `push_back`
|
|
||||||
- `operator+=`
|
|
||||||
- `erase`
|
|
||||||
- `swap`
|
|
||||||
- `std::swap`
|
|
||||||
|
|
||||||
### Comparisons
|
|
||||||
|
|
||||||
- `operator==`
|
|
||||||
- `operator!=`
|
|
||||||
- `operator<`
|
|
||||||
- `operator<=`
|
|
||||||
- `operator>`
|
|
||||||
- `operator>=`
|
|
||||||
|
|
||||||
### Serialization
|
|
||||||
|
|
||||||
- `dump`
|
|
||||||
- `operator<<`
|
|
||||||
- `operator>>`
|
|
||||||
|
|
||||||
### Deserialization
|
|
||||||
|
|
||||||
- `parse`
|
|
||||||
- `operator<<`
|
|
||||||
- `operator>>`
|
|
|
@ -1,7 +0,0 @@
|
||||||
site_name: JSON for Modern C++
|
|
||||||
|
|
||||||
theme: readthedocs
|
|
||||||
#theme: bootstrap
|
|
||||||
#theme: yeti
|
|
||||||
|
|
||||||
markdown_extensions: [fenced_code]
|
|
Loading…
Reference in a new issue