diff --git a/src/yamlcpp/#Makefile.am# b/src/yamlcpp/#Makefile.am# new file mode 100644 --- /dev/null +++ b/src/yamlcpp/#Makefile.am# @@ -0,0 +1,43 @@ +## How to make our mangled yaml-cpp from the yaml-cpp-0.6.0.tar.gz tarball +# tar xf yaml-cpp-0.6.0.tar.gz +# for i in `find yaml-cpp -type f -name "*.h" -o -name "*.cpp"`; do +# sed -e 's/namespace YAML/namespace LHAPDF_YAML/' -e 's/YAML::/LHAPDF_YAML::/g' -i +# done +# mv yaml-cpp{,.bak} && cp yaml-cpp.bak/include/yaml-cpp . -r && cp yaml-cpp.bak/src/*.{h,cpp} . + +EXTRA_DIST = yaml-cpp +noinst_LTLIBRARIES = librivet-yaml-cpp.la +librivet_yaml_cpp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) +librivet_yaml_cpp_la_SOURCES = \ + binary.cpp emitterstate.cpp node.cpp parser.cpp simplekey.cpp \ + convert.cpp emitterutils.cpp node_data.cpp regex_yaml.cpp singledocparser.cpp \ + directives.cpp exceptions.cpp nodeevents.cpp scanner.cpp stream.cpp \ + emit.cpp exp.cpp null.cpp scanscalar.cpp tag.cpp \ + emitfromevents.cpp memory.cpp ostream_wrapper.cpp scantag.cpp \ + emitter.cpp nodebuilder.cpp parse.cpp scantoken.cpp +dist_noinst_HEADERS = \ + collectionstack.h exp.h ptr_vector.h scanscalar.h streamcharsource.h token.h \ + directives.h indentation.h regeximpl.h scantag.h stream.h \ + emitterstate.h nodebuilder.h regex_yaml.h setting.h stringsource.h \ + emitterutils.h nodeevents.h scanner.h singledocparser.h tag.h + + + +EXTRA_DIST = yaml-cpp +noinst_LTLIBRARIES = liblhapdf-yaml-cpp.la +liblhapdf_yaml_cpp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) +liblhapdf_yaml_cpp_la_SOURCES = \ + aliasmanager.cpp emitterutils.cpp ostream.cpp simplekey.cpp \ + binary.cpp exp.cpp parser.cpp singledocparser.cpp \ + conversion.cpp iterator.cpp regex.cpp stream.cpp \ + directives.cpp nodebuilder.cpp scanner.cpp tag.cpp \ + emitfromevents.cpp node.cpp scanscalar.cpp \ + emitter.cpp nodeownership.cpp scantag.cpp \ + emitterstate.cpp null.cpp scantoken.cpp +dist_noinst_HEADERS = \ + collectionstack.h iterpriv.h regeximpl.h streamcharsource.h \ + directives.h nodebuilder.h scanner.h stream.h \ + emitterstate.h nodeownership.h scanscalar.h stringsource.h \ + emitterutils.h ptr_stack.h scantag.h tag.h \ + exp.h ptr_vector.h setting.h token.h \ + indentation.h regex.h singledocparser.h diff --git a/src/yamlcpp/.#Makefile.am b/src/yamlcpp/.#Makefile.am new file mode 120000 --- /dev/null +++ b/src/yamlcpp/.#Makefile.am @@ -0,0 +1,1 @@ +andy@unity.18581:1556722151 \ No newline at end of file diff --git a/src/yamlcpp/Makefile b/src/yamlcpp/Makefile new file mode 100644 --- /dev/null +++ b/src/yamlcpp/Makefile @@ -0,0 +1,858 @@ +# Makefile.in generated by automake 1.15.1 from Makefile.am. +# src/yamlcpp/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +# tar xf yaml-cpp-0.3.0.tar.gz +# for i in `find yaml-cpp -type f -name "*.h" -o -name "*.cpp"`; do \ +# sed -e 's/namespace YAML/namespace LHAPDF_YAML/' -e 's/YAML::/LHAPDF_YAML::/g' -i; done +# mv yaml-cpp{,.bak} && cp yaml-cpp.bak/include/yaml-cpp . -r && cp yaml-cpp.bak/src/*.{h,cpp} . + + + +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/LHAPDF +pkgincludedir = $(includedir)/LHAPDF +pkglibdir = $(libdir)/LHAPDF +pkglibexecdir = $(libexecdir)/LHAPDF +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +subdir = src/yamlcpp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_prog_cxx_mpi.m4 \ + $(top_srcdir)/m4/compilerflags.m4 $(top_srcdir)/m4/cython.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config/config.h \ + $(top_builddir)/include/LHAPDF/Version.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +liblhapdf_yaml_cpp_la_LIBADD = +am_liblhapdf_yaml_cpp_la_OBJECTS = \ + liblhapdf_yaml_cpp_la-aliasmanager.lo \ + liblhapdf_yaml_cpp_la-emitterutils.lo \ + liblhapdf_yaml_cpp_la-ostream.lo \ + liblhapdf_yaml_cpp_la-simplekey.lo \ + liblhapdf_yaml_cpp_la-binary.lo liblhapdf_yaml_cpp_la-exp.lo \ + liblhapdf_yaml_cpp_la-parser.lo \ + liblhapdf_yaml_cpp_la-singledocparser.lo \ + liblhapdf_yaml_cpp_la-conversion.lo \ + liblhapdf_yaml_cpp_la-iterator.lo \ + liblhapdf_yaml_cpp_la-regex.lo liblhapdf_yaml_cpp_la-stream.lo \ + liblhapdf_yaml_cpp_la-directives.lo \ + liblhapdf_yaml_cpp_la-nodebuilder.lo \ + liblhapdf_yaml_cpp_la-scanner.lo liblhapdf_yaml_cpp_la-tag.lo \ + liblhapdf_yaml_cpp_la-emitfromevents.lo \ + liblhapdf_yaml_cpp_la-node.lo \ + liblhapdf_yaml_cpp_la-scanscalar.lo \ + liblhapdf_yaml_cpp_la-emitter.lo \ + liblhapdf_yaml_cpp_la-nodeownership.lo \ + liblhapdf_yaml_cpp_la-scantag.lo \ + liblhapdf_yaml_cpp_la-emitterstate.lo \ + liblhapdf_yaml_cpp_la-null.lo \ + liblhapdf_yaml_cpp_la-scantoken.lo +liblhapdf_yaml_cpp_la_OBJECTS = $(am_liblhapdf_yaml_cpp_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_$(V)) +am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY)) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I. -I$(top_builddir)/config -I$(top_builddir)/include/LHAPDF +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_$(V)) +am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_$(V)) +am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(liblhapdf_yaml_cpp_la_SOURCES) +DIST_SOURCES = $(liblhapdf_yaml_cpp_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(dist_noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/andy/proj/hep/lhapdf6/config/missing aclocal-1.15 +AMTAR = $${TAR-tar} +AM_CPPFLAGS = +AM_CXXFLAGS = -pedantic -Wall -Wno-long-long +AM_DEFAULT_VERBOSITY = 0 +AM_LDFLAGS = +AR = ar +AUTOCONF = ${SHELL} /home/andy/proj/hep/lhapdf6/config/missing autoconf +AUTOHEADER = ${SHELL} /home/andy/proj/hep/lhapdf6/config/missing autoheader +AUTOMAKE = ${SHELL} /home/andy/proj/hep/lhapdf6/config/missing automake-1.15 +AWK = gawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -g -O2 +CPP = gcc -E +CPPFLAGS = -I/home/andy/heplocal/include +CXX = g++ +CXXCPP = g++ -E +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -mavx +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DLLTOOL = false +DOXYGEN = /usr/bin/doxygen +DSYMUTIL = +DUMPBIN = +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +FGREP = /bin/grep -F +GREP = /bin/grep +HAVE_CXX11 = 1 +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LD = /usr/bin/ld -m elf_x86_64 +LDFLAGS = -L/home/andy/heplocal/lib +LHAPDF_CXX = g++ +LHAPDF_CXXFLAGS = -mavx +LIBOBJS = +LIBS = +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LIPO = +LN_S = ln -s +LTLIBOBJS = +LT_SYS_LIBRARY_PATH = +MAKEINFO = ${SHELL} /home/andy/proj/hep/lhapdf6/config/missing makeinfo +MANIFEST_TOOL = : +MKDIR_P = /bin/mkdir -p +MPICXX = +NM = /usr/bin/nm -B +NMEDIT = +OBJDUMP = objdump +OBJEXT = o +OTOOL = +OTOOL64 = +PACKAGE = LHAPDF +PACKAGE_BUGREPORT = lhapdf@projects.hepforge.org +PACKAGE_NAME = LHAPDF +PACKAGE_STRING = LHAPDF 6.2.3 +PACKAGE_TARNAME = LHAPDF +PACKAGE_URL = +PACKAGE_VERSION = 6.2.3 +PATH_SEPARATOR = : +PDFLATEX = /usr/bin/pdflatex +PYTHON = /usr/bin/python +PYTHON_EXEC_PREFIX = ${exec_prefix} +PYTHON_PATH = /home/andy/heplocal/lib/python2.7/site-packages +PYTHON_PLATFORM = linux2 +PYTHON_PREFIX = ${prefix} +PYTHON_VERSION = 2.7 +RANLIB = ranlib +SED = /bin/sed +SET_MAKE = +SHELL = /bin/bash +STRIP = strip +SWVERS = +VERSION = 6.2.3 +abs_builddir = /home/andy/proj/hep/lhapdf6/src/yamlcpp +abs_srcdir = /home/andy/proj/hep/lhapdf6/src/yamlcpp +abs_top_builddir = /home/andy/proj/hep/lhapdf6 +abs_top_srcdir = /home/andy/proj/hep/lhapdf6 +ac_ct_AR = ar +ac_ct_CC = gcc +ac_ct_CXX = g++ +ac_ct_DUMPBIN = +am__include = include +am__leading_dot = . +am__quote = +am__tar = $${TAR-tar} chof - "$$tardir" +am__untar = $${TAR-tar} xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /home/andy/proj/hep/lhapdf6/config/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = $(MKDIR_P) +oldincludedir = /usr/include +pdfdir = ${docdir} +pkgpyexecdir = ${pyexecdir}/LHAPDF +pkgpythondir = ${pythondir}/LHAPDF +prefix = /home/andy/heplocal +program_transform_name = s,x,x, +psdir = ${docdir} +pyexecdir = ${exec_prefix}/lib/python2.7/site-packages +pythondir = ${prefix}/lib/python2.7/site-packages +runstatedir = ${localstatedir}/run +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_build_prefix = ../../ +top_builddir = ../.. +top_srcdir = ../.. +EXTRA_DIST = yaml-cpp +noinst_LTLIBRARIES = liblhapdf-yaml-cpp.la +liblhapdf_yaml_cpp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) +liblhapdf_yaml_cpp_la_SOURCES = \ + aliasmanager.cpp emitterutils.cpp ostream.cpp simplekey.cpp \ + binary.cpp exp.cpp parser.cpp singledocparser.cpp \ + conversion.cpp iterator.cpp regex.cpp stream.cpp \ + directives.cpp nodebuilder.cpp scanner.cpp tag.cpp \ + emitfromevents.cpp node.cpp scanscalar.cpp \ + emitter.cpp nodeownership.cpp scantag.cpp \ + emitterstate.cpp null.cpp scantoken.cpp + +dist_noinst_HEADERS = \ + collectionstack.h iterpriv.h regeximpl.h streamcharsource.h \ + directives.h nodebuilder.h scanner.h stream.h \ + emitterstate.h nodeownership.h scanscalar.h stringsource.h \ + emitterutils.h ptr_stack.h scantag.h tag.h \ + exp.h ptr_vector.h setting.h token.h \ + indentation.h regex.h singledocparser.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/yamlcpp/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/yamlcpp/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +liblhapdf-yaml-cpp.la: $(liblhapdf_yaml_cpp_la_OBJECTS) $(liblhapdf_yaml_cpp_la_DEPENDENCIES) $(EXTRA_liblhapdf_yaml_cpp_la_DEPENDENCIES) + $(AM_V_CXXLD)$(CXXLINK) $(liblhapdf_yaml_cpp_la_OBJECTS) $(liblhapdf_yaml_cpp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-node.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-null.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Plo +include ./$(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Plo + +.cpp.o: + $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# $(AM_V_CXX)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: + $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# $(AM_V_CXX)source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: + $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# $(AM_V_CXX)source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LTCXXCOMPILE) -c -o $@ $< + +liblhapdf_yaml_cpp_la-aliasmanager.lo: aliasmanager.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-aliasmanager.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Tpo -c -o liblhapdf_yaml_cpp_la-aliasmanager.lo `test -f 'aliasmanager.cpp' || echo '$(srcdir)/'`aliasmanager.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Plo +# $(AM_V_CXX)source='aliasmanager.cpp' object='liblhapdf_yaml_cpp_la-aliasmanager.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-aliasmanager.lo `test -f 'aliasmanager.cpp' || echo '$(srcdir)/'`aliasmanager.cpp + +liblhapdf_yaml_cpp_la-emitterutils.lo: emitterutils.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitterutils.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Tpo -c -o liblhapdf_yaml_cpp_la-emitterutils.lo `test -f 'emitterutils.cpp' || echo '$(srcdir)/'`emitterutils.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Plo +# $(AM_V_CXX)source='emitterutils.cpp' object='liblhapdf_yaml_cpp_la-emitterutils.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitterutils.lo `test -f 'emitterutils.cpp' || echo '$(srcdir)/'`emitterutils.cpp + +liblhapdf_yaml_cpp_la-ostream.lo: ostream.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-ostream.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Tpo -c -o liblhapdf_yaml_cpp_la-ostream.lo `test -f 'ostream.cpp' || echo '$(srcdir)/'`ostream.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Plo +# $(AM_V_CXX)source='ostream.cpp' object='liblhapdf_yaml_cpp_la-ostream.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-ostream.lo `test -f 'ostream.cpp' || echo '$(srcdir)/'`ostream.cpp + +liblhapdf_yaml_cpp_la-simplekey.lo: simplekey.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-simplekey.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Tpo -c -o liblhapdf_yaml_cpp_la-simplekey.lo `test -f 'simplekey.cpp' || echo '$(srcdir)/'`simplekey.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Plo +# $(AM_V_CXX)source='simplekey.cpp' object='liblhapdf_yaml_cpp_la-simplekey.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-simplekey.lo `test -f 'simplekey.cpp' || echo '$(srcdir)/'`simplekey.cpp + +liblhapdf_yaml_cpp_la-binary.lo: binary.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-binary.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Tpo -c -o liblhapdf_yaml_cpp_la-binary.lo `test -f 'binary.cpp' || echo '$(srcdir)/'`binary.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Plo +# $(AM_V_CXX)source='binary.cpp' object='liblhapdf_yaml_cpp_la-binary.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-binary.lo `test -f 'binary.cpp' || echo '$(srcdir)/'`binary.cpp + +liblhapdf_yaml_cpp_la-exp.lo: exp.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-exp.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Tpo -c -o liblhapdf_yaml_cpp_la-exp.lo `test -f 'exp.cpp' || echo '$(srcdir)/'`exp.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Plo +# $(AM_V_CXX)source='exp.cpp' object='liblhapdf_yaml_cpp_la-exp.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-exp.lo `test -f 'exp.cpp' || echo '$(srcdir)/'`exp.cpp + +liblhapdf_yaml_cpp_la-parser.lo: parser.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-parser.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Tpo -c -o liblhapdf_yaml_cpp_la-parser.lo `test -f 'parser.cpp' || echo '$(srcdir)/'`parser.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Plo +# $(AM_V_CXX)source='parser.cpp' object='liblhapdf_yaml_cpp_la-parser.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-parser.lo `test -f 'parser.cpp' || echo '$(srcdir)/'`parser.cpp + +liblhapdf_yaml_cpp_la-singledocparser.lo: singledocparser.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-singledocparser.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Tpo -c -o liblhapdf_yaml_cpp_la-singledocparser.lo `test -f 'singledocparser.cpp' || echo '$(srcdir)/'`singledocparser.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Plo +# $(AM_V_CXX)source='singledocparser.cpp' object='liblhapdf_yaml_cpp_la-singledocparser.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-singledocparser.lo `test -f 'singledocparser.cpp' || echo '$(srcdir)/'`singledocparser.cpp + +liblhapdf_yaml_cpp_la-conversion.lo: conversion.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-conversion.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Tpo -c -o liblhapdf_yaml_cpp_la-conversion.lo `test -f 'conversion.cpp' || echo '$(srcdir)/'`conversion.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Plo +# $(AM_V_CXX)source='conversion.cpp' object='liblhapdf_yaml_cpp_la-conversion.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-conversion.lo `test -f 'conversion.cpp' || echo '$(srcdir)/'`conversion.cpp + +liblhapdf_yaml_cpp_la-iterator.lo: iterator.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-iterator.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Tpo -c -o liblhapdf_yaml_cpp_la-iterator.lo `test -f 'iterator.cpp' || echo '$(srcdir)/'`iterator.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Plo +# $(AM_V_CXX)source='iterator.cpp' object='liblhapdf_yaml_cpp_la-iterator.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-iterator.lo `test -f 'iterator.cpp' || echo '$(srcdir)/'`iterator.cpp + +liblhapdf_yaml_cpp_la-regex.lo: regex.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-regex.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Tpo -c -o liblhapdf_yaml_cpp_la-regex.lo `test -f 'regex.cpp' || echo '$(srcdir)/'`regex.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Plo +# $(AM_V_CXX)source='regex.cpp' object='liblhapdf_yaml_cpp_la-regex.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-regex.lo `test -f 'regex.cpp' || echo '$(srcdir)/'`regex.cpp + +liblhapdf_yaml_cpp_la-stream.lo: stream.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-stream.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Tpo -c -o liblhapdf_yaml_cpp_la-stream.lo `test -f 'stream.cpp' || echo '$(srcdir)/'`stream.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Plo +# $(AM_V_CXX)source='stream.cpp' object='liblhapdf_yaml_cpp_la-stream.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-stream.lo `test -f 'stream.cpp' || echo '$(srcdir)/'`stream.cpp + +liblhapdf_yaml_cpp_la-directives.lo: directives.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-directives.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Tpo -c -o liblhapdf_yaml_cpp_la-directives.lo `test -f 'directives.cpp' || echo '$(srcdir)/'`directives.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Plo +# $(AM_V_CXX)source='directives.cpp' object='liblhapdf_yaml_cpp_la-directives.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-directives.lo `test -f 'directives.cpp' || echo '$(srcdir)/'`directives.cpp + +liblhapdf_yaml_cpp_la-nodebuilder.lo: nodebuilder.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-nodebuilder.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Tpo -c -o liblhapdf_yaml_cpp_la-nodebuilder.lo `test -f 'nodebuilder.cpp' || echo '$(srcdir)/'`nodebuilder.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Plo +# $(AM_V_CXX)source='nodebuilder.cpp' object='liblhapdf_yaml_cpp_la-nodebuilder.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-nodebuilder.lo `test -f 'nodebuilder.cpp' || echo '$(srcdir)/'`nodebuilder.cpp + +liblhapdf_yaml_cpp_la-scanner.lo: scanner.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scanner.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Tpo -c -o liblhapdf_yaml_cpp_la-scanner.lo `test -f 'scanner.cpp' || echo '$(srcdir)/'`scanner.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Plo +# $(AM_V_CXX)source='scanner.cpp' object='liblhapdf_yaml_cpp_la-scanner.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scanner.lo `test -f 'scanner.cpp' || echo '$(srcdir)/'`scanner.cpp + +liblhapdf_yaml_cpp_la-tag.lo: tag.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-tag.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Tpo -c -o liblhapdf_yaml_cpp_la-tag.lo `test -f 'tag.cpp' || echo '$(srcdir)/'`tag.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Plo +# $(AM_V_CXX)source='tag.cpp' object='liblhapdf_yaml_cpp_la-tag.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-tag.lo `test -f 'tag.cpp' || echo '$(srcdir)/'`tag.cpp + +liblhapdf_yaml_cpp_la-emitfromevents.lo: emitfromevents.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitfromevents.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Tpo -c -o liblhapdf_yaml_cpp_la-emitfromevents.lo `test -f 'emitfromevents.cpp' || echo '$(srcdir)/'`emitfromevents.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Plo +# $(AM_V_CXX)source='emitfromevents.cpp' object='liblhapdf_yaml_cpp_la-emitfromevents.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitfromevents.lo `test -f 'emitfromevents.cpp' || echo '$(srcdir)/'`emitfromevents.cpp + +liblhapdf_yaml_cpp_la-node.lo: node.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-node.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-node.Tpo -c -o liblhapdf_yaml_cpp_la-node.lo `test -f 'node.cpp' || echo '$(srcdir)/'`node.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-node.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-node.Plo +# $(AM_V_CXX)source='node.cpp' object='liblhapdf_yaml_cpp_la-node.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-node.lo `test -f 'node.cpp' || echo '$(srcdir)/'`node.cpp + +liblhapdf_yaml_cpp_la-scanscalar.lo: scanscalar.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scanscalar.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Tpo -c -o liblhapdf_yaml_cpp_la-scanscalar.lo `test -f 'scanscalar.cpp' || echo '$(srcdir)/'`scanscalar.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Plo +# $(AM_V_CXX)source='scanscalar.cpp' object='liblhapdf_yaml_cpp_la-scanscalar.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scanscalar.lo `test -f 'scanscalar.cpp' || echo '$(srcdir)/'`scanscalar.cpp + +liblhapdf_yaml_cpp_la-emitter.lo: emitter.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitter.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Tpo -c -o liblhapdf_yaml_cpp_la-emitter.lo `test -f 'emitter.cpp' || echo '$(srcdir)/'`emitter.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Plo +# $(AM_V_CXX)source='emitter.cpp' object='liblhapdf_yaml_cpp_la-emitter.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitter.lo `test -f 'emitter.cpp' || echo '$(srcdir)/'`emitter.cpp + +liblhapdf_yaml_cpp_la-nodeownership.lo: nodeownership.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-nodeownership.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Tpo -c -o liblhapdf_yaml_cpp_la-nodeownership.lo `test -f 'nodeownership.cpp' || echo '$(srcdir)/'`nodeownership.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Plo +# $(AM_V_CXX)source='nodeownership.cpp' object='liblhapdf_yaml_cpp_la-nodeownership.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-nodeownership.lo `test -f 'nodeownership.cpp' || echo '$(srcdir)/'`nodeownership.cpp + +liblhapdf_yaml_cpp_la-scantag.lo: scantag.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scantag.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Tpo -c -o liblhapdf_yaml_cpp_la-scantag.lo `test -f 'scantag.cpp' || echo '$(srcdir)/'`scantag.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Plo +# $(AM_V_CXX)source='scantag.cpp' object='liblhapdf_yaml_cpp_la-scantag.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scantag.lo `test -f 'scantag.cpp' || echo '$(srcdir)/'`scantag.cpp + +liblhapdf_yaml_cpp_la-emitterstate.lo: emitterstate.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitterstate.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Tpo -c -o liblhapdf_yaml_cpp_la-emitterstate.lo `test -f 'emitterstate.cpp' || echo '$(srcdir)/'`emitterstate.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Plo +# $(AM_V_CXX)source='emitterstate.cpp' object='liblhapdf_yaml_cpp_la-emitterstate.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitterstate.lo `test -f 'emitterstate.cpp' || echo '$(srcdir)/'`emitterstate.cpp + +liblhapdf_yaml_cpp_la-null.lo: null.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-null.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-null.Tpo -c -o liblhapdf_yaml_cpp_la-null.lo `test -f 'null.cpp' || echo '$(srcdir)/'`null.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-null.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-null.Plo +# $(AM_V_CXX)source='null.cpp' object='liblhapdf_yaml_cpp_la-null.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-null.lo `test -f 'null.cpp' || echo '$(srcdir)/'`null.cpp + +liblhapdf_yaml_cpp_la-scantoken.lo: scantoken.cpp + $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scantoken.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Tpo -c -o liblhapdf_yaml_cpp_la-scantoken.lo `test -f 'scantoken.cpp' || echo '$(srcdir)/'`scantoken.cpp + $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Plo +# $(AM_V_CXX)source='scantoken.cpp' object='liblhapdf_yaml_cpp_la-scantoken.lo' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(AM_V_CXX_no)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scantoken.lo `test -f 'scantoken.cpp' || echo '$(srcdir)/'`scantoken.cpp + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/yamlcpp/Makefile.in b/src/yamlcpp/Makefile.in new file mode 100644 --- /dev/null +++ b/src/yamlcpp/Makefile.in @@ -0,0 +1,858 @@ +# Makefile.in generated by automake 1.15.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# tar xf yaml-cpp-0.3.0.tar.gz +# for i in `find yaml-cpp -type f -name "*.h" -o -name "*.cpp"`; do \ +# sed -e 's/namespace YAML/namespace LHAPDF_YAML/' -e 's/YAML::/LHAPDF_YAML::/g' -i; done +# mv yaml-cpp{,.bak} && cp yaml-cpp.bak/include/yaml-cpp . -r && cp yaml-cpp.bak/src/*.{h,cpp} . + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/yamlcpp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4/ax_prog_cxx_mpi.m4 \ + $(top_srcdir)/m4/compilerflags.m4 $(top_srcdir)/m4/cython.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config/config.h \ + $(top_builddir)/include/LHAPDF/Version.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +liblhapdf_yaml_cpp_la_LIBADD = +am_liblhapdf_yaml_cpp_la_OBJECTS = \ + liblhapdf_yaml_cpp_la-aliasmanager.lo \ + liblhapdf_yaml_cpp_la-emitterutils.lo \ + liblhapdf_yaml_cpp_la-ostream.lo \ + liblhapdf_yaml_cpp_la-simplekey.lo \ + liblhapdf_yaml_cpp_la-binary.lo liblhapdf_yaml_cpp_la-exp.lo \ + liblhapdf_yaml_cpp_la-parser.lo \ + liblhapdf_yaml_cpp_la-singledocparser.lo \ + liblhapdf_yaml_cpp_la-conversion.lo \ + liblhapdf_yaml_cpp_la-iterator.lo \ + liblhapdf_yaml_cpp_la-regex.lo liblhapdf_yaml_cpp_la-stream.lo \ + liblhapdf_yaml_cpp_la-directives.lo \ + liblhapdf_yaml_cpp_la-nodebuilder.lo \ + liblhapdf_yaml_cpp_la-scanner.lo liblhapdf_yaml_cpp_la-tag.lo \ + liblhapdf_yaml_cpp_la-emitfromevents.lo \ + liblhapdf_yaml_cpp_la-node.lo \ + liblhapdf_yaml_cpp_la-scanscalar.lo \ + liblhapdf_yaml_cpp_la-emitter.lo \ + liblhapdf_yaml_cpp_la-nodeownership.lo \ + liblhapdf_yaml_cpp_la-scantag.lo \ + liblhapdf_yaml_cpp_la-emitterstate.lo \ + liblhapdf_yaml_cpp_la-null.lo \ + liblhapdf_yaml_cpp_la-scantoken.lo +liblhapdf_yaml_cpp_la_OBJECTS = $(am_liblhapdf_yaml_cpp_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/config -I$(top_builddir)/include/LHAPDF +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(liblhapdf_yaml_cpp_la_SOURCES) +DIST_SOURCES = $(liblhapdf_yaml_cpp_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(dist_noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_CPPFLAGS = @AM_CPPFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_LDFLAGS = @AM_LDFLAGS@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HAVE_CXX11 = @HAVE_CXX11@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LHAPDF_CXX = @LHAPDF_CXX@ +LHAPDF_CXXFLAGS = @LHAPDF_CXXFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MPICXX = @MPICXX@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PATH = @PYTHON_PATH@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SWVERS = @SWVERS@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = yaml-cpp +noinst_LTLIBRARIES = liblhapdf-yaml-cpp.la +liblhapdf_yaml_cpp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) +liblhapdf_yaml_cpp_la_SOURCES = \ + aliasmanager.cpp emitterutils.cpp ostream.cpp simplekey.cpp \ + binary.cpp exp.cpp parser.cpp singledocparser.cpp \ + conversion.cpp iterator.cpp regex.cpp stream.cpp \ + directives.cpp nodebuilder.cpp scanner.cpp tag.cpp \ + emitfromevents.cpp node.cpp scanscalar.cpp \ + emitter.cpp nodeownership.cpp scantag.cpp \ + emitterstate.cpp null.cpp scantoken.cpp + +dist_noinst_HEADERS = \ + collectionstack.h iterpriv.h regeximpl.h streamcharsource.h \ + directives.h nodebuilder.h scanner.h stream.h \ + emitterstate.h nodeownership.h scanscalar.h stringsource.h \ + emitterutils.h ptr_stack.h scantag.h tag.h \ + exp.h ptr_vector.h setting.h token.h \ + indentation.h regex.h singledocparser.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/yamlcpp/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/yamlcpp/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +liblhapdf-yaml-cpp.la: $(liblhapdf_yaml_cpp_la_OBJECTS) $(liblhapdf_yaml_cpp_la_DEPENDENCIES) $(EXTRA_liblhapdf_yaml_cpp_la_DEPENDENCIES) + $(AM_V_CXXLD)$(CXXLINK) $(liblhapdf_yaml_cpp_la_OBJECTS) $(liblhapdf_yaml_cpp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-node.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-null.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< + +liblhapdf_yaml_cpp_la-aliasmanager.lo: aliasmanager.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-aliasmanager.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Tpo -c -o liblhapdf_yaml_cpp_la-aliasmanager.lo `test -f 'aliasmanager.cpp' || echo '$(srcdir)/'`aliasmanager.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-aliasmanager.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='aliasmanager.cpp' object='liblhapdf_yaml_cpp_la-aliasmanager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-aliasmanager.lo `test -f 'aliasmanager.cpp' || echo '$(srcdir)/'`aliasmanager.cpp + +liblhapdf_yaml_cpp_la-emitterutils.lo: emitterutils.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitterutils.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Tpo -c -o liblhapdf_yaml_cpp_la-emitterutils.lo `test -f 'emitterutils.cpp' || echo '$(srcdir)/'`emitterutils.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterutils.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='emitterutils.cpp' object='liblhapdf_yaml_cpp_la-emitterutils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitterutils.lo `test -f 'emitterutils.cpp' || echo '$(srcdir)/'`emitterutils.cpp + +liblhapdf_yaml_cpp_la-ostream.lo: ostream.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-ostream.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Tpo -c -o liblhapdf_yaml_cpp_la-ostream.lo `test -f 'ostream.cpp' || echo '$(srcdir)/'`ostream.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-ostream.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ostream.cpp' object='liblhapdf_yaml_cpp_la-ostream.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-ostream.lo `test -f 'ostream.cpp' || echo '$(srcdir)/'`ostream.cpp + +liblhapdf_yaml_cpp_la-simplekey.lo: simplekey.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-simplekey.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Tpo -c -o liblhapdf_yaml_cpp_la-simplekey.lo `test -f 'simplekey.cpp' || echo '$(srcdir)/'`simplekey.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-simplekey.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='simplekey.cpp' object='liblhapdf_yaml_cpp_la-simplekey.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-simplekey.lo `test -f 'simplekey.cpp' || echo '$(srcdir)/'`simplekey.cpp + +liblhapdf_yaml_cpp_la-binary.lo: binary.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-binary.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Tpo -c -o liblhapdf_yaml_cpp_la-binary.lo `test -f 'binary.cpp' || echo '$(srcdir)/'`binary.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-binary.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='binary.cpp' object='liblhapdf_yaml_cpp_la-binary.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-binary.lo `test -f 'binary.cpp' || echo '$(srcdir)/'`binary.cpp + +liblhapdf_yaml_cpp_la-exp.lo: exp.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-exp.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Tpo -c -o liblhapdf_yaml_cpp_la-exp.lo `test -f 'exp.cpp' || echo '$(srcdir)/'`exp.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-exp.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='exp.cpp' object='liblhapdf_yaml_cpp_la-exp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-exp.lo `test -f 'exp.cpp' || echo '$(srcdir)/'`exp.cpp + +liblhapdf_yaml_cpp_la-parser.lo: parser.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-parser.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Tpo -c -o liblhapdf_yaml_cpp_la-parser.lo `test -f 'parser.cpp' || echo '$(srcdir)/'`parser.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-parser.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='parser.cpp' object='liblhapdf_yaml_cpp_la-parser.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-parser.lo `test -f 'parser.cpp' || echo '$(srcdir)/'`parser.cpp + +liblhapdf_yaml_cpp_la-singledocparser.lo: singledocparser.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-singledocparser.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Tpo -c -o liblhapdf_yaml_cpp_la-singledocparser.lo `test -f 'singledocparser.cpp' || echo '$(srcdir)/'`singledocparser.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-singledocparser.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='singledocparser.cpp' object='liblhapdf_yaml_cpp_la-singledocparser.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-singledocparser.lo `test -f 'singledocparser.cpp' || echo '$(srcdir)/'`singledocparser.cpp + +liblhapdf_yaml_cpp_la-conversion.lo: conversion.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-conversion.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Tpo -c -o liblhapdf_yaml_cpp_la-conversion.lo `test -f 'conversion.cpp' || echo '$(srcdir)/'`conversion.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-conversion.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='conversion.cpp' object='liblhapdf_yaml_cpp_la-conversion.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-conversion.lo `test -f 'conversion.cpp' || echo '$(srcdir)/'`conversion.cpp + +liblhapdf_yaml_cpp_la-iterator.lo: iterator.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-iterator.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Tpo -c -o liblhapdf_yaml_cpp_la-iterator.lo `test -f 'iterator.cpp' || echo '$(srcdir)/'`iterator.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-iterator.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='iterator.cpp' object='liblhapdf_yaml_cpp_la-iterator.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-iterator.lo `test -f 'iterator.cpp' || echo '$(srcdir)/'`iterator.cpp + +liblhapdf_yaml_cpp_la-regex.lo: regex.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-regex.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Tpo -c -o liblhapdf_yaml_cpp_la-regex.lo `test -f 'regex.cpp' || echo '$(srcdir)/'`regex.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-regex.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='regex.cpp' object='liblhapdf_yaml_cpp_la-regex.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-regex.lo `test -f 'regex.cpp' || echo '$(srcdir)/'`regex.cpp + +liblhapdf_yaml_cpp_la-stream.lo: stream.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-stream.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Tpo -c -o liblhapdf_yaml_cpp_la-stream.lo `test -f 'stream.cpp' || echo '$(srcdir)/'`stream.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-stream.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='stream.cpp' object='liblhapdf_yaml_cpp_la-stream.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-stream.lo `test -f 'stream.cpp' || echo '$(srcdir)/'`stream.cpp + +liblhapdf_yaml_cpp_la-directives.lo: directives.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-directives.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Tpo -c -o liblhapdf_yaml_cpp_la-directives.lo `test -f 'directives.cpp' || echo '$(srcdir)/'`directives.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-directives.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='directives.cpp' object='liblhapdf_yaml_cpp_la-directives.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-directives.lo `test -f 'directives.cpp' || echo '$(srcdir)/'`directives.cpp + +liblhapdf_yaml_cpp_la-nodebuilder.lo: nodebuilder.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-nodebuilder.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Tpo -c -o liblhapdf_yaml_cpp_la-nodebuilder.lo `test -f 'nodebuilder.cpp' || echo '$(srcdir)/'`nodebuilder.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-nodebuilder.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nodebuilder.cpp' object='liblhapdf_yaml_cpp_la-nodebuilder.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-nodebuilder.lo `test -f 'nodebuilder.cpp' || echo '$(srcdir)/'`nodebuilder.cpp + +liblhapdf_yaml_cpp_la-scanner.lo: scanner.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scanner.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Tpo -c -o liblhapdf_yaml_cpp_la-scanner.lo `test -f 'scanner.cpp' || echo '$(srcdir)/'`scanner.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scanner.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='scanner.cpp' object='liblhapdf_yaml_cpp_la-scanner.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scanner.lo `test -f 'scanner.cpp' || echo '$(srcdir)/'`scanner.cpp + +liblhapdf_yaml_cpp_la-tag.lo: tag.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-tag.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Tpo -c -o liblhapdf_yaml_cpp_la-tag.lo `test -f 'tag.cpp' || echo '$(srcdir)/'`tag.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-tag.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tag.cpp' object='liblhapdf_yaml_cpp_la-tag.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-tag.lo `test -f 'tag.cpp' || echo '$(srcdir)/'`tag.cpp + +liblhapdf_yaml_cpp_la-emitfromevents.lo: emitfromevents.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitfromevents.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Tpo -c -o liblhapdf_yaml_cpp_la-emitfromevents.lo `test -f 'emitfromevents.cpp' || echo '$(srcdir)/'`emitfromevents.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitfromevents.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='emitfromevents.cpp' object='liblhapdf_yaml_cpp_la-emitfromevents.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitfromevents.lo `test -f 'emitfromevents.cpp' || echo '$(srcdir)/'`emitfromevents.cpp + +liblhapdf_yaml_cpp_la-node.lo: node.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-node.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-node.Tpo -c -o liblhapdf_yaml_cpp_la-node.lo `test -f 'node.cpp' || echo '$(srcdir)/'`node.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-node.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-node.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='node.cpp' object='liblhapdf_yaml_cpp_la-node.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-node.lo `test -f 'node.cpp' || echo '$(srcdir)/'`node.cpp + +liblhapdf_yaml_cpp_la-scanscalar.lo: scanscalar.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scanscalar.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Tpo -c -o liblhapdf_yaml_cpp_la-scanscalar.lo `test -f 'scanscalar.cpp' || echo '$(srcdir)/'`scanscalar.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scanscalar.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='scanscalar.cpp' object='liblhapdf_yaml_cpp_la-scanscalar.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scanscalar.lo `test -f 'scanscalar.cpp' || echo '$(srcdir)/'`scanscalar.cpp + +liblhapdf_yaml_cpp_la-emitter.lo: emitter.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitter.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Tpo -c -o liblhapdf_yaml_cpp_la-emitter.lo `test -f 'emitter.cpp' || echo '$(srcdir)/'`emitter.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitter.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='emitter.cpp' object='liblhapdf_yaml_cpp_la-emitter.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitter.lo `test -f 'emitter.cpp' || echo '$(srcdir)/'`emitter.cpp + +liblhapdf_yaml_cpp_la-nodeownership.lo: nodeownership.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-nodeownership.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Tpo -c -o liblhapdf_yaml_cpp_la-nodeownership.lo `test -f 'nodeownership.cpp' || echo '$(srcdir)/'`nodeownership.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-nodeownership.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nodeownership.cpp' object='liblhapdf_yaml_cpp_la-nodeownership.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-nodeownership.lo `test -f 'nodeownership.cpp' || echo '$(srcdir)/'`nodeownership.cpp + +liblhapdf_yaml_cpp_la-scantag.lo: scantag.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scantag.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Tpo -c -o liblhapdf_yaml_cpp_la-scantag.lo `test -f 'scantag.cpp' || echo '$(srcdir)/'`scantag.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scantag.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='scantag.cpp' object='liblhapdf_yaml_cpp_la-scantag.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scantag.lo `test -f 'scantag.cpp' || echo '$(srcdir)/'`scantag.cpp + +liblhapdf_yaml_cpp_la-emitterstate.lo: emitterstate.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-emitterstate.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Tpo -c -o liblhapdf_yaml_cpp_la-emitterstate.lo `test -f 'emitterstate.cpp' || echo '$(srcdir)/'`emitterstate.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-emitterstate.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='emitterstate.cpp' object='liblhapdf_yaml_cpp_la-emitterstate.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-emitterstate.lo `test -f 'emitterstate.cpp' || echo '$(srcdir)/'`emitterstate.cpp + +liblhapdf_yaml_cpp_la-null.lo: null.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-null.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-null.Tpo -c -o liblhapdf_yaml_cpp_la-null.lo `test -f 'null.cpp' || echo '$(srcdir)/'`null.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-null.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-null.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='null.cpp' object='liblhapdf_yaml_cpp_la-null.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-null.lo `test -f 'null.cpp' || echo '$(srcdir)/'`null.cpp + +liblhapdf_yaml_cpp_la-scantoken.lo: scantoken.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liblhapdf_yaml_cpp_la-scantoken.lo -MD -MP -MF $(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Tpo -c -o liblhapdf_yaml_cpp_la-scantoken.lo `test -f 'scantoken.cpp' || echo '$(srcdir)/'`scantoken.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Tpo $(DEPDIR)/liblhapdf_yaml_cpp_la-scantoken.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='scantoken.cpp' object='liblhapdf_yaml_cpp_la-scantoken.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblhapdf_yaml_cpp_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liblhapdf_yaml_cpp_la-scantoken.lo `test -f 'scantoken.cpp' || echo '$(srcdir)/'`scantoken.cpp + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/yamlcpp/aliasmanager.cpp b/src/yamlcpp/aliasmanager.cpp deleted file mode 100644 --- a/src/yamlcpp/aliasmanager.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "yaml-cpp/aliasmanager.h" -#include "yaml-cpp/node.h" -#include -#include - -namespace LHAPDF_YAML -{ - AliasManager::AliasManager(): m_curAnchor(0) - { - } - - void AliasManager::RegisterReference(const Node& node) - { - m_anchorByIdentity.insert(std::make_pair(&node, _CreateNewAnchor())); - } - - anchor_t AliasManager::LookupAnchor(const Node& node) const - { - AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(&node); - if(it == m_anchorByIdentity.end()) - return 0; - return it->second; - } - - anchor_t AliasManager::_CreateNewAnchor() - { - return ++m_curAnchor; - } -} diff --git a/src/yamlcpp/binary.cpp b/src/yamlcpp/binary.cpp --- a/src/yamlcpp/binary.cpp +++ b/src/yamlcpp/binary.cpp @@ -1,102 +1,93 @@ #include "yaml-cpp/binary.h" -#include "yaml-cpp/node.h" -namespace LHAPDF_YAML -{ - static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +namespace YAML { +static const char encoding[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - std::string EncodeBase64(const unsigned char *data, std::size_t size) - { - const char PAD = '='; - - std::string ret; - ret.resize(4 * size / 3 + 3); - char *out = &ret[0]; - - std::size_t chunks = size / 3; - std::size_t remainder = size % 3; - - for(std::size_t i=0;i> 2]; - *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; - *out++ = encoding[((data[1] & 0xf) << 2) | (data[2] >> 6)]; - *out++ = encoding[data[2] & 0x3f]; - } - - switch(remainder) { - case 0: - break; - case 1: - *out++ = encoding[data[0] >> 2]; - *out++ = encoding[((data[0] & 0x3) << 4)]; - *out++ = PAD; - *out++ = PAD; - break; - case 2: - *out++ = encoding[data[0] >> 2]; - *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; - *out++ = encoding[((data[1] & 0xf) << 2)]; - *out++ = PAD; - break; - } - - ret.resize(out - &ret[0]); - return ret; +std::string EncodeBase64(const unsigned char *data, std::size_t size) { + const char PAD = '='; + + std::string ret; + ret.resize(4 * size / 3 + 3); + char *out = &ret[0]; + + std::size_t chunks = size / 3; + std::size_t remainder = size % 3; + + for (std::size_t i = 0; i < chunks; i++, data += 3) { + *out++ = encoding[data[0] >> 2]; + *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; + *out++ = encoding[((data[1] & 0xf) << 2) | (data[2] >> 6)]; + *out++ = encoding[data[2] & 0x3f]; + } + + switch (remainder) { + case 0: + break; + case 1: + *out++ = encoding[data[0] >> 2]; + *out++ = encoding[((data[0] & 0x3) << 4)]; + *out++ = PAD; + *out++ = PAD; + break; + case 2: + *out++ = encoding[data[0] >> 2]; + *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; + *out++ = encoding[((data[1] & 0xf) << 2)]; + *out++ = PAD; + break; + } + + ret.resize(out - &ret[0]); + return ret; +} + +static const unsigned char decoding[] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, + 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, + 255, 0, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, +}; + +std::vector DecodeBase64(const std::string &input) { + typedef std::vector ret_type; + if (input.empty()) + return ret_type(); + + ret_type ret(3 * input.size() / 4 + 1); + unsigned char *out = &ret[0]; + + unsigned value = 0; + for (std::size_t i = 0; i < input.size(); i++) { + unsigned char d = decoding[static_cast(input[i])]; + if (d == 255) + return ret_type(); + + value = (value << 6) | d; + if (i % 4 == 3) { + *out++ = value >> 16; + if (i > 0 && input[i - 1] != '=') + *out++ = value >> 8; + if (input[i] != '=') + *out++ = value; } - - static const unsigned char decoding[] = { - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255, - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255, - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - }; + } - std::vector DecodeBase64(const std::string& input) - { - typedef std::vector ret_type; - if(input.empty()) - return ret_type(); - - ret_type ret(3 * input.size() / 4 + 1); - unsigned char *out = &ret[0]; - - unsigned value = 0; - for(std::size_t i=0;i(input[i])]; - if(d == 255) - return ret_type(); - - value = (value << 6) | d; - if(i % 4 == 3) { - *out++ = value >> 16; - if(i > 0 && input[i - 1] != '=') - *out++ = value >> 8; - if(input[i] != '=') - *out++ = value; - } - } - - ret.resize(out - &ret[0]); - return ret; - } - - void operator >> (const Node& node, Binary& binary) - { - std::string scalar; - node.GetScalar(scalar); - std::vector data = DecodeBase64(scalar); - binary.swap(data); - } + ret.resize(out - &ret[0]); + return ret; } +} diff --git a/src/yamlcpp/collectionstack.h b/src/yamlcpp/collectionstack.h --- a/src/yamlcpp/collectionstack.h +++ b/src/yamlcpp/collectionstack.h @@ -1,35 +1,39 @@ #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include #include -namespace LHAPDF_YAML -{ - struct CollectionType { - enum value { None, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap }; - }; +namespace YAML { +struct CollectionType { + enum value { NoCollection, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap }; +}; - class CollectionStack - { - public: - CollectionType::value GetCurCollectionType() const { - if(collectionStack.empty()) - return CollectionType::None; - return collectionStack.top(); - } - - void PushCollectionType(CollectionType::value type) { collectionStack.push(type); } - void PopCollectionType(CollectionType::value type) { assert(type == GetCurCollectionType()); collectionStack.pop(); } - - private: - std::stack collectionStack; - }; +class CollectionStack { + public: + CollectionType::value GetCurCollectionType() const { + if (collectionStack.empty()) + return CollectionType::NoCollection; + return collectionStack.top(); + } + + void PushCollectionType(CollectionType::value type) { + collectionStack.push(type); + } + void PopCollectionType(CollectionType::value type) { + assert(type == GetCurCollectionType()); + collectionStack.pop(); + } + + private: + std::stack collectionStack; +}; } -#endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/contrib/graphbuilder.cpp b/src/yamlcpp/contrib/graphbuilder.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/contrib/graphbuilder.cpp @@ -0,0 +1,17 @@ +#include "graphbuilderadapter.h" + +#include "yaml-cpp/parser.h" // IWYU pragma: keep + +namespace YAML { +class GraphBuilderInterface; + +void* BuildGraphOfNextDocument(Parser& parser, + GraphBuilderInterface& graphBuilder) { + GraphBuilderAdapter eventHandler(graphBuilder); + if (parser.HandleNextDocument(eventHandler)) { + return eventHandler.RootNode(); + } else { + return NULL; + } +} +} diff --git a/src/yamlcpp/contrib/graphbuilderadapter.cpp b/src/yamlcpp/contrib/graphbuilderadapter.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/contrib/graphbuilderadapter.cpp @@ -0,0 +1,94 @@ +#include "graphbuilderadapter.h" +#include "yaml-cpp/contrib/graphbuilder.h" + +namespace YAML { +struct Mark; + +int GraphBuilderAdapter::ContainerFrame::sequenceMarker; + +void GraphBuilderAdapter::OnNull(const Mark &mark, anchor_t anchor) { + void *pParent = GetCurrentParent(); + void *pNode = m_builder.NewNull(mark, pParent); + RegisterAnchor(anchor, pNode); + + DispositionNode(pNode); +} + +void GraphBuilderAdapter::OnAlias(const Mark &mark, anchor_t anchor) { + void *pReffedNode = m_anchors.Get(anchor); + DispositionNode(m_builder.AnchorReference(mark, pReffedNode)); +} + +void GraphBuilderAdapter::OnScalar(const Mark &mark, const std::string &tag, + anchor_t anchor, const std::string &value) { + void *pParent = GetCurrentParent(); + void *pNode = m_builder.NewScalar(mark, tag, pParent, value); + RegisterAnchor(anchor, pNode); + + DispositionNode(pNode); +} + +void GraphBuilderAdapter::OnSequenceStart(const Mark &mark, + const std::string &tag, + anchor_t anchor, + EmitterStyle::value /* style */) { + void *pNode = m_builder.NewSequence(mark, tag, GetCurrentParent()); + m_containers.push(ContainerFrame(pNode)); + RegisterAnchor(anchor, pNode); +} + +void GraphBuilderAdapter::OnSequenceEnd() { + void *pSequence = m_containers.top().pContainer; + m_containers.pop(); + + DispositionNode(pSequence); +} + +void GraphBuilderAdapter::OnMapStart(const Mark &mark, const std::string &tag, + anchor_t anchor, + EmitterStyle::value /* style */) { + void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent()); + m_containers.push(ContainerFrame(pNode, m_pKeyNode)); + m_pKeyNode = NULL; + RegisterAnchor(anchor, pNode); +} + +void GraphBuilderAdapter::OnMapEnd() { + void *pMap = m_containers.top().pContainer; + m_pKeyNode = m_containers.top().pPrevKeyNode; + m_containers.pop(); + DispositionNode(pMap); +} + +void *GraphBuilderAdapter::GetCurrentParent() const { + if (m_containers.empty()) { + return NULL; + } + return m_containers.top().pContainer; +} + +void GraphBuilderAdapter::RegisterAnchor(anchor_t anchor, void *pNode) { + if (anchor) { + m_anchors.Register(anchor, pNode); + } +} + +void GraphBuilderAdapter::DispositionNode(void *pNode) { + if (m_containers.empty()) { + m_pRootNode = pNode; + return; + } + + void *pContainer = m_containers.top().pContainer; + if (m_containers.top().isMap()) { + if (m_pKeyNode) { + m_builder.AssignInMap(pContainer, m_pKeyNode, pNode); + m_pKeyNode = NULL; + } else { + m_pKeyNode = pNode; + } + } else { + m_builder.AppendToSequence(pContainer, pNode); + } +} +} diff --git a/src/yamlcpp/contrib/graphbuilderadapter.h b/src/yamlcpp/contrib/graphbuilderadapter.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/contrib/graphbuilderadapter.h @@ -0,0 +1,79 @@ +#ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include +#include + +#include "yaml-cpp/anchor.h" +#include "yaml-cpp/contrib/anchordict.h" +#include "yaml-cpp/contrib/graphbuilder.h" +#include "yaml-cpp/emitterstyle.h" +#include "yaml-cpp/eventhandler.h" + +namespace YAML { +class GraphBuilderInterface; +struct Mark; +} // namespace YAML + +namespace YAML { +class GraphBuilderAdapter : public EventHandler { + public: + GraphBuilderAdapter(GraphBuilderInterface& builder) + : m_builder(builder), m_pRootNode(NULL), m_pKeyNode(NULL) {} + + virtual void OnDocumentStart(const Mark& mark) { (void)mark; } + virtual void OnDocumentEnd() {} + + virtual void OnNull(const Mark& mark, anchor_t anchor); + virtual void OnAlias(const Mark& mark, anchor_t anchor); + virtual void OnScalar(const Mark& mark, const std::string& tag, + anchor_t anchor, const std::string& value); + + virtual void OnSequenceStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style); + virtual void OnSequenceEnd(); + + virtual void OnMapStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style); + virtual void OnMapEnd(); + + void* RootNode() const { return m_pRootNode; } + + private: + struct ContainerFrame { + ContainerFrame(void* pSequence) + : pContainer(pSequence), pPrevKeyNode(&sequenceMarker) {} + ContainerFrame(void* pMap, void* pPrevKeyNode) + : pContainer(pMap), pPrevKeyNode(pPrevKeyNode) {} + + void* pContainer; + void* pPrevKeyNode; + + bool isMap() const { return pPrevKeyNode != &sequenceMarker; } + + private: + static int sequenceMarker; + }; + typedef std::stack ContainerStack; + typedef AnchorDict AnchorMap; + + GraphBuilderInterface& m_builder; + ContainerStack m_containers; + AnchorMap m_anchors; + void* m_pRootNode; + void* m_pKeyNode; + + void* GetCurrentParent() const; + void RegisterAnchor(anchor_t anchor, void* pNode); + void DispositionNode(void* pNode); +}; +} + +#endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/conversion.cpp b/src/yamlcpp/conversion.cpp deleted file mode 100644 --- a/src/yamlcpp/conversion.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "yaml-cpp/conversion.h" -#include - -//////////////////////////////////////////////////////////////// -// Specializations for converting a string to specific types - -namespace -{ - // we're not gonna mess with the mess that is all the isupper/etc. functions - bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; } - bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; } - char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; } - - std::string tolower(const std::string& str) - { - std::string s(str); - std::transform(s.begin(), s.end(), s.begin(), ToLower); - return s; - } - - template - bool IsEntirely(const std::string& str, T func) - { - for(std::size_t i=0;i + +#include "yaml-cpp/node/convert.h" + +namespace { +// we're not gonna mess with the mess that is all the isupper/etc. functions +bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; } +bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; } +char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; } + +std::string tolower(const std::string& str) { + std::string s(str); + std::transform(s.begin(), s.end(), s.begin(), ToLower); + return s; +} + +template +bool IsEntirely(const std::string& str, T func) { + for (std::size_t i = 0; i < str.size(); i++) + if (!func(str[i])) + return false; + + return true; +} + +// IsFlexibleCase +// . Returns true if 'str' is: +// . UPPERCASE +// . lowercase +// . Capitalized +bool IsFlexibleCase(const std::string& str) { + if (str.empty()) + return true; + + if (IsEntirely(str, IsLower)) + return true; + + bool firstcaps = IsUpper(str[0]); + std::string rest = str.substr(1); + return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper)); +} +} + +namespace YAML { +bool convert::decode(const Node& node, bool& rhs) { + if (!node.IsScalar()) + return false; + + // we can't use iostream bool extraction operators as they don't + // recognize all possible values in the table below (taken from + // http://yaml.org/type/bool.html) + static const struct { + std::string truename, falsename; + } names[] = { + {"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"}, + }; + + if (!IsFlexibleCase(node.Scalar())) + return false; + + for (unsigned i = 0; i < sizeof(names) / sizeof(names[0]); i++) { + if (names[i].truename == tolower(node.Scalar())) { + rhs = true; + return true; + } + + if (names[i].falsename == tolower(node.Scalar())) { + rhs = false; + return true; + } + } + + return false; +} +} diff --git a/src/yamlcpp/directives.cpp b/src/yamlcpp/directives.cpp --- a/src/yamlcpp/directives.cpp +++ b/src/yamlcpp/directives.cpp @@ -1,24 +1,22 @@ #include "directives.h" -namespace LHAPDF_YAML -{ - Directives::Directives() - { - // version - version.isDefault = true; - version.major = 1; - version.minor = 2; - } - - const std::string Directives::TranslateTagHandle(const std::string& handle) const - { - std::map ::const_iterator it = tags.find(handle); - if(it == tags.end()) { - if(handle == "!!") - return "tag:yaml.org,2002:"; - return handle; - } - - return it->second; - } +namespace YAML { +Directives::Directives() { + // version + version.isDefault = true; + version.major = 1; + version.minor = 2; } + +const std::string Directives::TranslateTagHandle( + const std::string& handle) const { + std::map::const_iterator it = tags.find(handle); + if (it == tags.end()) { + if (handle == "!!") + return "tag:yaml.org,2002:"; + return handle; + } + + return it->second; +} +} diff --git a/src/yamlcpp/directives.h b/src/yamlcpp/directives.h --- a/src/yamlcpp/directives.h +++ b/src/yamlcpp/directives.h @@ -1,29 +1,29 @@ #ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include #include -namespace LHAPDF_YAML -{ - struct Version { - bool isDefault; - int major, minor; - }; - - struct Directives { - Directives(); - - const std::string TranslateTagHandle(const std::string& handle) const; +namespace YAML { +struct Version { + bool isDefault; + int major, minor; +}; - Version version; - std::map tags; - }; +struct Directives { + Directives(); + + const std::string TranslateTagHandle(const std::string& handle) const; + + Version version; + std::map tags; +}; } -#endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/emit.cpp b/src/yamlcpp/emit.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/emit.cpp @@ -0,0 +1,25 @@ +#include "yaml-cpp/node/emit.h" +#include "yaml-cpp/emitfromevents.h" +#include "yaml-cpp/emitter.h" +#include "nodeevents.h" + +namespace YAML { +Emitter& operator<<(Emitter& out, const Node& node) { + EmitFromEvents emitFromEvents(out); + NodeEvents events(node); + events.Emit(emitFromEvents); + return out; +} + +std::ostream& operator<<(std::ostream& out, const Node& node) { + Emitter emitter(out); + emitter << node; + return out; +} + +std::string Dump(const Node& node) { + Emitter emitter; + emitter << node; + return emitter.c_str(); +} +} // namespace YAML diff --git a/src/yamlcpp/emitfromevents.cpp b/src/yamlcpp/emitfromevents.cpp --- a/src/yamlcpp/emitfromevents.cpp +++ b/src/yamlcpp/emitfromevents.cpp @@ -1,105 +1,119 @@ -#include "yaml-cpp/emitfromevents.h" -#include "yaml-cpp/emitter.h" -#include "yaml-cpp/null.h" #include #include +#include "yaml-cpp/emitfromevents.h" +#include "yaml-cpp/emitter.h" +#include "yaml-cpp/emittermanip.h" +#include "yaml-cpp/null.h" + +namespace YAML { +struct Mark; +} // namespace YAML + namespace { - std::string ToString(LHAPDF_YAML::anchor_t anchor) { - std::stringstream stream; - stream << anchor; - return stream.str(); - } +std::string ToString(YAML::anchor_t anchor) { + std::stringstream stream; + stream << anchor; + return stream.str(); +} } -namespace LHAPDF_YAML -{ - EmitFromEvents::EmitFromEvents(Emitter& emitter): m_emitter(emitter) - { - } - - void EmitFromEvents::OnDocumentStart(const Mark&) - { - } - - void EmitFromEvents::OnDocumentEnd() - { - } - - void EmitFromEvents::OnNull(const Mark&, anchor_t anchor) - { - BeginNode(); - EmitProps("", anchor); - m_emitter << Null; - } - - void EmitFromEvents::OnAlias(const Mark&, anchor_t anchor) - { - BeginNode(); - m_emitter << Alias(ToString(anchor)); - } - - void EmitFromEvents::OnScalar(const Mark&, const std::string& tag, anchor_t anchor, const std::string& value) - { - BeginNode(); - EmitProps(tag, anchor); - m_emitter << value; - } - - void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag, anchor_t anchor) - { - BeginNode(); - EmitProps(tag, anchor); - m_emitter << BeginSeq; - m_stateStack.push(State::WaitingForSequenceEntry); - } - - void EmitFromEvents::OnSequenceEnd() - { - m_emitter << EndSeq; - assert(m_stateStack.top() == State::WaitingForSequenceEntry); - m_stateStack.pop(); - } - - void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag, anchor_t anchor) - { - BeginNode(); - EmitProps(tag, anchor); - m_emitter << BeginMap; - m_stateStack.push(State::WaitingForKey); - } +namespace YAML { +EmitFromEvents::EmitFromEvents(Emitter& emitter) : m_emitter(emitter) {} - void EmitFromEvents::OnMapEnd() - { - m_emitter << EndMap; - assert(m_stateStack.top() == State::WaitingForKey); - m_stateStack.pop(); - } +void EmitFromEvents::OnDocumentStart(const Mark&) {} - void EmitFromEvents::BeginNode() - { - if(m_stateStack.empty()) - return; - - switch(m_stateStack.top()) { - case State::WaitingForKey: - m_emitter << Key; - m_stateStack.top() = State::WaitingForValue; - break; - case State::WaitingForValue: - m_emitter << Value; - m_stateStack.top() = State::WaitingForKey; - break; - default: - break; - } - } - - void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor) - { - if(!tag.empty() && tag != "?") - m_emitter << VerbatimTag(tag); - if(anchor) - m_emitter << Anchor(ToString(anchor)); - } +void EmitFromEvents::OnDocumentEnd() {} + +void EmitFromEvents::OnNull(const Mark&, anchor_t anchor) { + BeginNode(); + EmitProps("", anchor); + m_emitter << Null; } + +void EmitFromEvents::OnAlias(const Mark&, anchor_t anchor) { + BeginNode(); + m_emitter << Alias(ToString(anchor)); +} + +void EmitFromEvents::OnScalar(const Mark&, const std::string& tag, + anchor_t anchor, const std::string& value) { + BeginNode(); + EmitProps(tag, anchor); + m_emitter << value; +} + +void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag, + anchor_t anchor, + EmitterStyle::value style) { + BeginNode(); + EmitProps(tag, anchor); + switch (style) { + case EmitterStyle::Block: + m_emitter << Block; + break; + case EmitterStyle::Flow: + m_emitter << Flow; + break; + default: + break; + } + m_emitter << BeginSeq; + m_stateStack.push(State::WaitingForSequenceEntry); +} + +void EmitFromEvents::OnSequenceEnd() { + m_emitter << EndSeq; + assert(m_stateStack.top() == State::WaitingForSequenceEntry); + m_stateStack.pop(); +} + +void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag, + anchor_t anchor, EmitterStyle::value style) { + BeginNode(); + EmitProps(tag, anchor); + switch (style) { + case EmitterStyle::Block: + m_emitter << Block; + break; + case EmitterStyle::Flow: + m_emitter << Flow; + break; + default: + break; + } + m_emitter << BeginMap; + m_stateStack.push(State::WaitingForKey); +} + +void EmitFromEvents::OnMapEnd() { + m_emitter << EndMap; + assert(m_stateStack.top() == State::WaitingForKey); + m_stateStack.pop(); +} + +void EmitFromEvents::BeginNode() { + if (m_stateStack.empty()) + return; + + switch (m_stateStack.top()) { + case State::WaitingForKey: + m_emitter << Key; + m_stateStack.top() = State::WaitingForValue; + break; + case State::WaitingForValue: + m_emitter << Value; + m_stateStack.top() = State::WaitingForKey; + break; + default: + break; + } +} + +void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor) { + if (!tag.empty() && tag != "?" && tag != "!") + m_emitter << VerbatimTag(tag); + if (anchor) + m_emitter << Anchor(ToString(anchor)); +} +} diff --git a/src/yamlcpp/emitter.cpp b/src/yamlcpp/emitter.cpp --- a/src/yamlcpp/emitter.cpp +++ b/src/yamlcpp/emitter.cpp @@ -1,882 +1,911 @@ -#include "yaml-cpp/emitter.h" -#include "emitterstate.h" -#include "emitterutils.h" -#include "indentation.h" -#include "yaml-cpp/exceptions.h" #include -namespace LHAPDF_YAML -{ - Emitter::Emitter(): m_pState(new EmitterState) - { - } - - Emitter::~Emitter() - { - } - - const char *Emitter::c_str() const - { - return m_stream.str(); - } - - unsigned Emitter::size() const - { - return m_stream.pos(); - } - - // state checking - bool Emitter::good() const - { - return m_pState->good(); - } - - const std::string Emitter::GetLastError() const - { - return m_pState->GetLastError(); - } +#include "emitterutils.h" +#include "indentation.h" // IWYU pragma: keep +#include "yaml-cpp/emitter.h" +#include "yaml-cpp/emitterdef.h" +#include "yaml-cpp/emittermanip.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep - // global setters - bool Emitter::SetOutputCharset(EMITTER_MANIP value) - { - return m_pState->SetOutputCharset(value, GLOBAL); - } +namespace YAML { +class Binary; +struct _Null; - bool Emitter::SetStringFormat(EMITTER_MANIP value) - { - return m_pState->SetStringFormat(value, GLOBAL); - } - - bool Emitter::SetBoolFormat(EMITTER_MANIP value) - { - bool ok = false; - if(m_pState->SetBoolFormat(value, GLOBAL)) - ok = true; - if(m_pState->SetBoolCaseFormat(value, GLOBAL)) - ok = true; - if(m_pState->SetBoolLengthFormat(value, GLOBAL)) - ok = true; - return ok; - } - - bool Emitter::SetIntBase(EMITTER_MANIP value) - { - return m_pState->SetIntFormat(value, GLOBAL); - } - - bool Emitter::SetSeqFormat(EMITTER_MANIP value) - { - return m_pState->SetFlowType(GT_SEQ, value, GLOBAL); - } - - bool Emitter::SetMapFormat(EMITTER_MANIP value) - { - bool ok = false; - if(m_pState->SetFlowType(GT_MAP, value, GLOBAL)) - ok = true; - if(m_pState->SetMapKeyFormat(value, GLOBAL)) - ok = true; - return ok; - } - - bool Emitter::SetIndent(unsigned n) - { - return m_pState->SetIndent(n, GLOBAL); - } - - bool Emitter::SetPreCommentIndent(unsigned n) - { - return m_pState->SetPreCommentIndent(n, GLOBAL); - } - - bool Emitter::SetPostCommentIndent(unsigned n) - { - return m_pState->SetPostCommentIndent(n, GLOBAL); - } - - bool Emitter::SetFloatPrecision(unsigned n) - { - return m_pState->SetFloatPrecision(n, GLOBAL); - } +Emitter::Emitter() : m_pState(new EmitterState) {} - bool Emitter::SetDoublePrecision(unsigned n) - { - return m_pState->SetDoublePrecision(n, GLOBAL); - } +Emitter::Emitter(std::ostream& stream) + : m_pState(new EmitterState), m_stream(stream) {} - // SetLocalValue - // . Either start/end a group, or set a modifier locally - Emitter& Emitter::SetLocalValue(EMITTER_MANIP value) - { - if(!good()) - return *this; - - switch(value) { - case BeginDoc: - EmitBeginDoc(); - break; - case EndDoc: - EmitEndDoc(); - break; - case BeginSeq: - EmitBeginSeq(); - break; - case EndSeq: - EmitEndSeq(); - break; - case BeginMap: - EmitBeginMap(); - break; - case EndMap: - EmitEndMap(); - break; - case Key: - EmitKey(); - break; - case Value: - EmitValue(); - break; - case TagByKind: - EmitKindTag(); - break; - case Newline: - EmitNewline(); - break; - default: - m_pState->SetLocalValue(value); - break; - } - return *this; - } - - Emitter& Emitter::SetLocalIndent(const _Indent& indent) - { - m_pState->SetIndent(indent.value, LOCAL); - return *this; - } +Emitter::~Emitter() {} - Emitter& Emitter::SetLocalPrecision(const _Precision& precision) - { - if(precision.floatPrecision >= 0) - m_pState->SetFloatPrecision(precision.floatPrecision, LOCAL); - if(precision.doublePrecision >= 0) - m_pState->SetDoublePrecision(precision.doublePrecision, LOCAL); - return *this; - } +const char* Emitter::c_str() const { return m_stream.str(); } - // GotoNextPreAtomicState - // . Runs the state machine, emitting if necessary, and returns 'true' if done (i.e., ready to emit an atom) - bool Emitter::GotoNextPreAtomicState() - { - if(!good()) - return true; - - unsigned curIndent = m_pState->GetCurIndent(); - - EMITTER_STATE curState = m_pState->GetCurState(); - switch(curState) { - // document-level - case ES_WAITING_FOR_DOC: - m_pState->SwitchState(ES_WRITING_DOC); - return true; - case ES_WRITING_DOC: - return true; - case ES_DONE_WITH_DOC: - EmitBeginDoc(); - return false; - - // block sequence - case ES_WAITING_FOR_BLOCK_SEQ_ENTRY: - m_stream << IndentTo(curIndent) << "-"; - m_pState->RequireSoftSeparation(); - m_pState->SwitchState(ES_WRITING_BLOCK_SEQ_ENTRY); - return true; - case ES_WRITING_BLOCK_SEQ_ENTRY: - return true; - case ES_DONE_WITH_BLOCK_SEQ_ENTRY: - m_stream << '\n'; - m_pState->SwitchState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY); - return false; - - // flow sequence - case ES_WAITING_FOR_FLOW_SEQ_ENTRY: - m_pState->SwitchState(ES_WRITING_FLOW_SEQ_ENTRY); - return true; - case ES_WRITING_FLOW_SEQ_ENTRY: - return true; - case ES_DONE_WITH_FLOW_SEQ_ENTRY: - EmitSeparationIfNecessary(); - m_stream << ','; - m_pState->RequireSoftSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_FLOW_SEQ_ENTRY); - return false; - - // block map - case ES_WAITING_FOR_BLOCK_MAP_ENTRY: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - case ES_WAITING_FOR_BLOCK_MAP_KEY: - if(m_pState->CurrentlyInLongKey()) { - m_stream << IndentTo(curIndent) << '?'; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_WRITING_BLOCK_MAP_KEY); - return true; - case ES_WRITING_BLOCK_MAP_KEY: - return true; - case ES_DONE_WITH_BLOCK_MAP_KEY: - m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN); - return true; - case ES_WAITING_FOR_BLOCK_MAP_VALUE: - m_pState->SwitchState(ES_WRITING_BLOCK_MAP_VALUE); - return true; - case ES_WRITING_BLOCK_MAP_VALUE: - return true; - case ES_DONE_WITH_BLOCK_MAP_VALUE: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - - // flow map - case ES_WAITING_FOR_FLOW_MAP_ENTRY: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - case ES_WAITING_FOR_FLOW_MAP_KEY: - EmitSeparationIfNecessary(); - m_pState->SwitchState(ES_WRITING_FLOW_MAP_KEY); - if(m_pState->CurrentlyInLongKey()) { - m_stream << '?'; - m_pState->RequireSoftSeparation(); - } - return true; - case ES_WRITING_FLOW_MAP_KEY: - return true; - case ES_DONE_WITH_FLOW_MAP_KEY: - m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN); - return true; - case ES_WAITING_FOR_FLOW_MAP_VALUE: - EmitSeparationIfNecessary(); - m_stream << ':'; - m_pState->RequireSoftSeparation(); - m_pState->SwitchState(ES_WRITING_FLOW_MAP_VALUE); - return true; - case ES_WRITING_FLOW_MAP_VALUE: - return true; - case ES_DONE_WITH_FLOW_MAP_VALUE: - m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN); - return true; - default: - assert(false); - } +std::size_t Emitter::size() const { return m_stream.pos(); } - assert(false); - return true; - } - - // PreAtomicWrite - // . Depending on the emitter state, write to the stream to get it - // in position to do an atomic write (e.g., scalar, sequence, or map) - void Emitter::PreAtomicWrite() - { - if(!good()) - return; - - while(!GotoNextPreAtomicState()) - ; - } - - // PostAtomicWrite - // . Clean up - void Emitter::PostAtomicWrite() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - switch(curState) { - // document-level - case ES_WRITING_DOC: - m_pState->SwitchState(ES_DONE_WITH_DOC); - break; +// state checking +bool Emitter::good() const { return m_pState->good(); } - // block seq - case ES_WRITING_BLOCK_SEQ_ENTRY: - m_pState->SwitchState(ES_DONE_WITH_BLOCK_SEQ_ENTRY); - break; - - // flow seq - case ES_WRITING_FLOW_SEQ_ENTRY: - m_pState->SwitchState(ES_DONE_WITH_FLOW_SEQ_ENTRY); - break; - - // block map - case ES_WRITING_BLOCK_MAP_KEY: - if(!m_pState->CurrentlyInLongKey()) { - m_stream << ':'; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_DONE_WITH_BLOCK_MAP_KEY); - break; - case ES_WRITING_BLOCK_MAP_VALUE: - m_pState->SwitchState(ES_DONE_WITH_BLOCK_MAP_VALUE); - break; - - // flow map - case ES_WRITING_FLOW_MAP_KEY: - m_pState->SwitchState(ES_DONE_WITH_FLOW_MAP_KEY); - break; - case ES_WRITING_FLOW_MAP_VALUE: - m_pState->SwitchState(ES_DONE_WITH_FLOW_MAP_VALUE); - break; - default: - assert(false); - }; - - m_pState->ClearModifiedSettings(); - } - - // EmitSeparationIfNecessary - void Emitter::EmitSeparationIfNecessary() - { - if(!good()) - return; - - if(m_pState->RequiresSoftSeparation()) - m_stream << ' '; - else if(m_pState->RequiresHardSeparation()) - m_stream << '\n'; - m_pState->UnsetSeparation(); - } - - // EmitBeginDoc - void Emitter::EmitBeginDoc() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - if(curState != ES_WAITING_FOR_DOC && curState != ES_WRITING_DOC && curState != ES_DONE_WITH_DOC) { - m_pState->SetError("Unexpected begin document"); - return; - } - - if(curState == ES_WRITING_DOC || curState == ES_DONE_WITH_DOC) - m_stream << '\n'; - m_stream << "---\n"; - - m_pState->UnsetSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_DOC); - } - - // EmitEndDoc - void Emitter::EmitEndDoc() - { - if(!good()) - return; - - - EMITTER_STATE curState = m_pState->GetCurState(); - if(curState != ES_WAITING_FOR_DOC && curState != ES_WRITING_DOC && curState != ES_DONE_WITH_DOC) { - m_pState->SetError("Unexpected end document"); - return; - } - - if(curState == ES_WRITING_DOC || curState == ES_DONE_WITH_DOC) - m_stream << '\n'; - m_stream << "...\n"; - - m_pState->UnsetSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_DOC); - } - - // EmitBeginSeq - void Emitter::EmitBeginSeq() - { - if(!good()) - return; - - // must have a long key if we're emitting a sequence - m_pState->StartLongKey(); - - PreAtomicWrite(); - - EMITTER_STATE curState = m_pState->GetCurState(); - EMITTER_MANIP flowType = m_pState->GetFlowType(GT_SEQ); - if(flowType == Block) { - if(curState == ES_WRITING_BLOCK_SEQ_ENTRY || - curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE || - curState == ES_WRITING_DOC - ) { - if(m_pState->RequiresHardSeparation() || curState != ES_WRITING_DOC) { - m_stream << "\n"; - m_pState->UnsetSeparation(); - } - } - m_pState->PushState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY); - } else if(flowType == Flow) { - EmitSeparationIfNecessary(); - m_stream << "["; - m_pState->PushState(ES_WAITING_FOR_FLOW_SEQ_ENTRY); - } else - assert(false); - - m_pState->BeginGroup(GT_SEQ); - } - - // EmitEndSeq - void Emitter::EmitEndSeq() - { - if(!good()) - return; - - if(m_pState->GetCurGroupType() != GT_SEQ) - return m_pState->SetError(ErrorMsg::UNEXPECTED_END_SEQ); - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK) { - // Note: block sequences are *not* allowed to be empty, but we convert it - // to a flow sequence if it is - assert(curState == ES_DONE_WITH_BLOCK_SEQ_ENTRY || curState == ES_WAITING_FOR_BLOCK_SEQ_ENTRY); - if(curState == ES_WAITING_FOR_BLOCK_SEQ_ENTRY) { - // Note: only one of these will actually output anything for a given situation - EmitSeparationIfNecessary(); - unsigned curIndent = m_pState->GetCurIndent(); - m_stream << IndentTo(curIndent); - - m_stream << "[]"; - } - } else if(flowType == FT_FLOW) { - // Note: flow sequences are allowed to be empty - assert(curState == ES_DONE_WITH_FLOW_SEQ_ENTRY || curState == ES_WAITING_FOR_FLOW_SEQ_ENTRY); - m_stream << "]"; - } else - assert(false); - - m_pState->PopState(); - m_pState->EndGroup(GT_SEQ); - - PostAtomicWrite(); - } - - // EmitBeginMap - void Emitter::EmitBeginMap() - { - if(!good()) - return; - - // must have a long key if we're emitting a map - m_pState->StartLongKey(); - - PreAtomicWrite(); - - EMITTER_STATE curState = m_pState->GetCurState(); - EMITTER_MANIP flowType = m_pState->GetFlowType(GT_MAP); - if(flowType == Block) { - if(curState == ES_WRITING_BLOCK_SEQ_ENTRY || - curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE || - curState == ES_WRITING_DOC - ) { - if(m_pState->RequiresHardSeparation() || (curState != ES_WRITING_DOC && curState != ES_WRITING_BLOCK_SEQ_ENTRY)) { - m_stream << "\n"; - m_pState->UnsetSeparation(); - } - } - m_pState->PushState(ES_WAITING_FOR_BLOCK_MAP_ENTRY); - } else if(flowType == Flow) { - EmitSeparationIfNecessary(); - m_stream << "{"; - m_pState->PushState(ES_WAITING_FOR_FLOW_MAP_ENTRY); - } else - assert(false); - - m_pState->BeginGroup(GT_MAP); - } - - // EmitEndMap - void Emitter::EmitEndMap() - { - if(!good()) - return; - - if(m_pState->GetCurGroupType() != GT_MAP) - return m_pState->SetError(ErrorMsg::UNEXPECTED_END_MAP); - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK) { - // Note: block sequences are *not* allowed to be empty, but we convert it - // to a flow sequence if it is - assert(curState == ES_DONE_WITH_BLOCK_MAP_VALUE || curState == ES_WAITING_FOR_BLOCK_MAP_ENTRY); - if(curState == ES_WAITING_FOR_BLOCK_MAP_ENTRY) { - // Note: only one of these will actually output anything for a given situation - EmitSeparationIfNecessary(); - unsigned curIndent = m_pState->GetCurIndent(); - m_stream << IndentTo(curIndent); - m_stream << "{}"; - } - } else if(flowType == FT_FLOW) { - // Note: flow maps are allowed to be empty - assert(curState == ES_DONE_WITH_FLOW_MAP_VALUE || curState == ES_WAITING_FOR_FLOW_MAP_ENTRY); - EmitSeparationIfNecessary(); - m_stream << "}"; - } else - assert(false); - - m_pState->PopState(); - m_pState->EndGroup(GT_MAP); - - PostAtomicWrite(); - } - - // EmitKey - void Emitter::EmitKey() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(curState != ES_WAITING_FOR_BLOCK_MAP_ENTRY && curState != ES_DONE_WITH_BLOCK_MAP_VALUE - && curState != ES_WAITING_FOR_FLOW_MAP_ENTRY && curState != ES_DONE_WITH_FLOW_MAP_VALUE) - return m_pState->SetError(ErrorMsg::UNEXPECTED_KEY_TOKEN); - - if(flowType == FT_BLOCK) { - if(curState == ES_DONE_WITH_BLOCK_MAP_VALUE) - m_stream << '\n'; - unsigned curIndent = m_pState->GetCurIndent(); - m_stream << IndentTo(curIndent); - m_pState->UnsetSeparation(); - m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_KEY); - } else if(flowType == FT_FLOW) { - EmitSeparationIfNecessary(); - if(curState == ES_DONE_WITH_FLOW_MAP_VALUE) { - m_stream << ','; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_WAITING_FOR_FLOW_MAP_KEY); - } else - assert(false); - - if(m_pState->GetMapKeyFormat() == LongKey) - m_pState->StartLongKey(); - else if(m_pState->GetMapKeyFormat() == Auto) - m_pState->StartSimpleKey(); - else - assert(false); - } - - // EmitValue - void Emitter::EmitValue() - { - if(!good()) - return; - - EMITTER_STATE curState = m_pState->GetCurState(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(curState != ES_DONE_WITH_BLOCK_MAP_KEY && curState != ES_DONE_WITH_FLOW_MAP_KEY) - return m_pState->SetError(ErrorMsg::UNEXPECTED_VALUE_TOKEN); - - if(flowType == FT_BLOCK) { - if(m_pState->CurrentlyInLongKey()) { - m_stream << '\n'; - m_stream << IndentTo(m_pState->GetCurIndent()); - m_stream << ':'; - m_pState->RequireSoftSeparation(); - } - m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_VALUE); - } else if(flowType == FT_FLOW) { - m_pState->SwitchState(ES_WAITING_FOR_FLOW_MAP_VALUE); - } else - assert(false); - } - - // EmitNewline - void Emitter::EmitNewline() - { - if(!good()) - return; - - if(CanEmitNewline()) { - m_stream << '\n'; - m_pState->UnsetSeparation(); - } - } - - bool Emitter::CanEmitNewline() const - { - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK && m_pState->CurrentlyInLongKey()) - return true; - - EMITTER_STATE curState = m_pState->GetCurState(); - return curState != ES_DONE_WITH_BLOCK_MAP_KEY && curState != ES_WAITING_FOR_BLOCK_MAP_VALUE && curState != ES_WRITING_BLOCK_MAP_VALUE; - } - - // ******************************************************************************************* - // overloads of Write - - Emitter& Emitter::Write(const std::string& str) - { - if(!good()) - return *this; - - // literal scalars must use long keys - if(m_pState->GetStringFormat() == Literal && m_pState->GetCurGroupFlowType() != FT_FLOW) - m_pState->StartLongKey(); - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - bool escapeNonAscii = m_pState->GetOutputCharset() == EscapeNonAscii; - EMITTER_MANIP strFmt = m_pState->GetStringFormat(); - FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - unsigned curIndent = m_pState->GetCurIndent(); - - switch(strFmt) { - case Auto: - Utils::WriteString(m_stream, str, flowType == FT_FLOW, escapeNonAscii); - break; - case SingleQuoted: - if(!Utils::WriteSingleQuotedString(m_stream, str)) { - m_pState->SetError(ErrorMsg::SINGLE_QUOTED_CHAR); - return *this; - } - break; - case DoubleQuoted: - Utils::WriteDoubleQuotedString(m_stream, str, escapeNonAscii); - break; - case Literal: - if(flowType == FT_FLOW) - Utils::WriteString(m_stream, str, flowType == FT_FLOW, escapeNonAscii); - else - Utils::WriteLiteralString(m_stream, str, curIndent + m_pState->GetIndent()); - break; - default: - assert(false); - } - - PostAtomicWrite(); - return *this; - } - - void Emitter::PreWriteIntegralType(std::stringstream& str) - { - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - EMITTER_MANIP intFmt = m_pState->GetIntFormat(); - switch(intFmt) { - case Dec: - str << std::dec; - break; - case Hex: - str << "0x"; - str << std::hex; - break; - case Oct: - str << "0"; - str << std::oct; - break; - default: - assert(false); - } - } - - void Emitter::PreWriteStreamable(std::stringstream&) - { - PreAtomicWrite(); - EmitSeparationIfNecessary(); - } - - unsigned Emitter::GetFloatPrecision() const - { - return m_pState->GetFloatPrecision(); - } - - unsigned Emitter::GetDoublePrecision() const - { - return m_pState->GetDoublePrecision(); - } - - void Emitter::PostWriteIntegralType(const std::stringstream& str) - { - m_stream << str.str(); - PostAtomicWrite(); - } - - void Emitter::PostWriteStreamable(const std::stringstream& str) - { - m_stream << str.str(); - PostAtomicWrite(); - } - - const char *Emitter::ComputeFullBoolName(bool b) const - { - const EMITTER_MANIP mainFmt = (m_pState->GetBoolLengthFormat() == ShortBool ? YesNoBool : m_pState->GetBoolFormat()); - const EMITTER_MANIP caseFmt = m_pState->GetBoolCaseFormat(); - switch(mainFmt) { - case YesNoBool: - switch(caseFmt) { - case UpperCase: return b ? "YES" : "NO"; - case CamelCase: return b ? "Yes" : "No"; - case LowerCase: return b ? "yes" : "no"; - default: break; - } - break; - case OnOffBool: - switch(caseFmt) { - case UpperCase: return b ? "ON" : "OFF"; - case CamelCase: return b ? "On" : "Off"; - case LowerCase: return b ? "on" : "off"; - default: break; - } - break; - case TrueFalseBool: - switch(caseFmt) { - case UpperCase: return b ? "TRUE" : "FALSE"; - case CamelCase: return b ? "True" : "False"; - case LowerCase: return b ? "true" : "false"; - default: break; - } - break; - default: - break; - } - return b ? "y" : "n"; // should never get here, but it can't hurt to give these answers - } - - Emitter& Emitter::Write(bool b) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - const char *name = ComputeFullBoolName(b); - if(m_pState->GetBoolLengthFormat() == ShortBool) - m_stream << name[0]; - else - m_stream << name; - - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(char ch) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - Utils::WriteChar(m_stream, ch); - - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(const _Alias& alias) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - if(!Utils::WriteAlias(m_stream, alias.content)) { - m_pState->SetError(ErrorMsg::INVALID_ALIAS); - return *this; - } - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(const _Anchor& anchor) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - if(!Utils::WriteAnchor(m_stream, anchor.content)) { - m_pState->SetError(ErrorMsg::INVALID_ANCHOR); - return *this; - } - m_pState->RequireHardSeparation(); - // Note: no PostAtomicWrite() because we need another value for this node - return *this; - } - - Emitter& Emitter::Write(const _Tag& tag) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - - bool success = false; - if(tag.type == _Tag::Type::Verbatim) - success = Utils::WriteTag(m_stream, tag.content, true); - else if(tag.type == _Tag::Type::PrimaryHandle) - success = Utils::WriteTag(m_stream, tag.content, false); - else - success = Utils::WriteTagWithPrefix(m_stream, tag.prefix, tag.content); - - if(!success) { - m_pState->SetError(ErrorMsg::INVALID_TAG); - return *this; - } - - m_pState->RequireHardSeparation(); - // Note: no PostAtomicWrite() because we need another value for this node - return *this; - } - - void Emitter::EmitKindTag() - { - Write(LocalTag("")); - } - - Emitter& Emitter::Write(const _Comment& comment) - { - if(!good()) - return *this; - - if(m_stream.col() > 0) - m_stream << Indentation(m_pState->GetPreCommentIndent()); - Utils::WriteComment(m_stream, comment.content, m_pState->GetPostCommentIndent()); - m_pState->RequireHardSeparation(); - m_pState->ForceHardSeparation(); - - return *this; - } - - Emitter& Emitter::Write(const _Null& /*null*/) - { - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - m_stream << "~"; - PostAtomicWrite(); - return *this; - } - - Emitter& Emitter::Write(const Binary& binary) - { - Write(SecondaryTag("binary")); - - if(!good()) - return *this; - - PreAtomicWrite(); - EmitSeparationIfNecessary(); - Utils::WriteBinary(m_stream, binary); - PostAtomicWrite(); - return *this; - } +const std::string Emitter::GetLastError() const { + return m_pState->GetLastError(); } +// global setters +bool Emitter::SetOutputCharset(EMITTER_MANIP value) { + return m_pState->SetOutputCharset(value, FmtScope::Global); +} + +bool Emitter::SetStringFormat(EMITTER_MANIP value) { + return m_pState->SetStringFormat(value, FmtScope::Global); +} + +bool Emitter::SetBoolFormat(EMITTER_MANIP value) { + bool ok = false; + if (m_pState->SetBoolFormat(value, FmtScope::Global)) + ok = true; + if (m_pState->SetBoolCaseFormat(value, FmtScope::Global)) + ok = true; + if (m_pState->SetBoolLengthFormat(value, FmtScope::Global)) + ok = true; + return ok; +} + +bool Emitter::SetIntBase(EMITTER_MANIP value) { + return m_pState->SetIntFormat(value, FmtScope::Global); +} + +bool Emitter::SetSeqFormat(EMITTER_MANIP value) { + return m_pState->SetFlowType(GroupType::Seq, value, FmtScope::Global); +} + +bool Emitter::SetMapFormat(EMITTER_MANIP value) { + bool ok = false; + if (m_pState->SetFlowType(GroupType::Map, value, FmtScope::Global)) + ok = true; + if (m_pState->SetMapKeyFormat(value, FmtScope::Global)) + ok = true; + return ok; +} + +bool Emitter::SetIndent(std::size_t n) { + return m_pState->SetIndent(n, FmtScope::Global); +} + +bool Emitter::SetPreCommentIndent(std::size_t n) { + return m_pState->SetPreCommentIndent(n, FmtScope::Global); +} + +bool Emitter::SetPostCommentIndent(std::size_t n) { + return m_pState->SetPostCommentIndent(n, FmtScope::Global); +} + +bool Emitter::SetFloatPrecision(std::size_t n) { + return m_pState->SetFloatPrecision(n, FmtScope::Global); +} + +bool Emitter::SetDoublePrecision(std::size_t n) { + return m_pState->SetDoublePrecision(n, FmtScope::Global); +} + +// SetLocalValue +// . Either start/end a group, or set a modifier locally +Emitter& Emitter::SetLocalValue(EMITTER_MANIP value) { + if (!good()) + return *this; + + switch (value) { + case BeginDoc: + EmitBeginDoc(); + break; + case EndDoc: + EmitEndDoc(); + break; + case BeginSeq: + EmitBeginSeq(); + break; + case EndSeq: + EmitEndSeq(); + break; + case BeginMap: + EmitBeginMap(); + break; + case EndMap: + EmitEndMap(); + break; + case Key: + case Value: + // deprecated (these can be deduced by the parity of nodes in a map) + break; + case TagByKind: + EmitKindTag(); + break; + case Newline: + EmitNewline(); + break; + default: + m_pState->SetLocalValue(value); + break; + } + return *this; +} + +Emitter& Emitter::SetLocalIndent(const _Indent& indent) { + m_pState->SetIndent(indent.value, FmtScope::Local); + return *this; +} + +Emitter& Emitter::SetLocalPrecision(const _Precision& precision) { + if (precision.floatPrecision >= 0) + m_pState->SetFloatPrecision(precision.floatPrecision, FmtScope::Local); + if (precision.doublePrecision >= 0) + m_pState->SetDoublePrecision(precision.doublePrecision, FmtScope::Local); + return *this; +} + +// EmitBeginDoc +void Emitter::EmitBeginDoc() { + if (!good()) + return; + + if (m_pState->CurGroupType() != GroupType::NoType) { + m_pState->SetError("Unexpected begin document"); + return; + } + + if (m_pState->HasAnchor() || m_pState->HasTag()) { + m_pState->SetError("Unexpected begin document"); + return; + } + + if (m_stream.col() > 0) + m_stream << "\n"; + m_stream << "---\n"; + + m_pState->StartedDoc(); +} + +// EmitEndDoc +void Emitter::EmitEndDoc() { + if (!good()) + return; + + if (m_pState->CurGroupType() != GroupType::NoType) { + m_pState->SetError("Unexpected begin document"); + return; + } + + if (m_pState->HasAnchor() || m_pState->HasTag()) { + m_pState->SetError("Unexpected begin document"); + return; + } + + if (m_stream.col() > 0) + m_stream << "\n"; + m_stream << "...\n"; +} + +// EmitBeginSeq +void Emitter::EmitBeginSeq() { + if (!good()) + return; + + PrepareNode(m_pState->NextGroupType(GroupType::Seq)); + + m_pState->StartedGroup(GroupType::Seq); +} + +// EmitEndSeq +void Emitter::EmitEndSeq() { + if (!good()) + return; + + if (m_pState->CurGroupChildCount() == 0) + m_pState->ForceFlow(); + + if (m_pState->CurGroupFlowType() == FlowType::Flow) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(m_pState->CurIndent()); + if (m_pState->CurGroupChildCount() == 0) + m_stream << "["; + m_stream << "]"; + } + + m_pState->EndedGroup(GroupType::Seq); +} + +// EmitBeginMap +void Emitter::EmitBeginMap() { + if (!good()) + return; + + PrepareNode(m_pState->NextGroupType(GroupType::Map)); + + m_pState->StartedGroup(GroupType::Map); +} + +// EmitEndMap +void Emitter::EmitEndMap() { + if (!good()) + return; + + if (m_pState->CurGroupChildCount() == 0) + m_pState->ForceFlow(); + + if (m_pState->CurGroupFlowType() == FlowType::Flow) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(m_pState->CurIndent()); + if (m_pState->CurGroupChildCount() == 0) + m_stream << "{"; + m_stream << "}"; + } + + m_pState->EndedGroup(GroupType::Map); +} + +// EmitNewline +void Emitter::EmitNewline() { + if (!good()) + return; + + PrepareNode(EmitterNodeType::NoType); + m_stream << "\n"; + m_pState->SetNonContent(); +} + +bool Emitter::CanEmitNewline() const { return true; } + +// Put the stream in a state so we can simply write the next node +// E.g., if we're in a sequence, write the "- " +void Emitter::PrepareNode(EmitterNodeType::value child) { + switch (m_pState->CurGroupNodeType()) { + case EmitterNodeType::NoType: + PrepareTopNode(child); + break; + case EmitterNodeType::FlowSeq: + FlowSeqPrepareNode(child); + break; + case EmitterNodeType::BlockSeq: + BlockSeqPrepareNode(child); + break; + case EmitterNodeType::FlowMap: + FlowMapPrepareNode(child); + break; + case EmitterNodeType::BlockMap: + BlockMapPrepareNode(child); + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + assert(false); + break; + } +} + +void Emitter::PrepareTopNode(EmitterNodeType::value child) { + if (child == EmitterNodeType::NoType) + return; + + if (m_pState->CurGroupChildCount() > 0 && m_stream.col() > 0) { + if (child != EmitterNodeType::NoType) + EmitBeginDoc(); + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + // TODO: if we were writing null, and + // we wanted it blank, we wouldn't want a space + SpaceOrIndentTo(m_pState->HasBegunContent(), 0); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + if (m_pState->HasBegunNode()) + m_stream << "\n"; + break; + } +} + +void Emitter::FlowSeqPrepareNode(EmitterNodeType::value child) { + const std::size_t lastIndent = m_pState->LastIndent(); + + if (!m_pState->HasBegunNode()) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(lastIndent); + if (m_pState->CurGroupChildCount() == 0) + m_stream << "["; + else + m_stream << ","; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo( + m_pState->HasBegunContent() || m_pState->CurGroupChildCount() > 0, + lastIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + assert(false); + break; + } +} + +void Emitter::BlockSeqPrepareNode(EmitterNodeType::value child) { + const std::size_t curIndent = m_pState->CurIndent(); + const std::size_t nextIndent = curIndent + m_pState->CurGroupIndent(); + + if (child == EmitterNodeType::NoType) + return; + + if (!m_pState->HasBegunContent()) { + if (m_pState->CurGroupChildCount() > 0 || m_stream.comment()) { + m_stream << "\n"; + } + m_stream << IndentTo(curIndent); + m_stream << "-"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo(m_pState->HasBegunContent(), nextIndent); + break; + case EmitterNodeType::BlockSeq: + m_stream << "\n"; + break; + case EmitterNodeType::BlockMap: + if (m_pState->HasBegunContent() || m_stream.comment()) + m_stream << "\n"; + break; + } +} + +void Emitter::FlowMapPrepareNode(EmitterNodeType::value child) { + if (m_pState->CurGroupChildCount() % 2 == 0) { + if (m_pState->GetMapKeyFormat() == LongKey) + m_pState->SetLongKey(); + + if (m_pState->CurGroupLongKey()) + FlowMapPrepareLongKey(child); + else + FlowMapPrepareSimpleKey(child); + } else { + if (m_pState->CurGroupLongKey()) + FlowMapPrepareLongKeyValue(child); + else + FlowMapPrepareSimpleKeyValue(child); + } +} + +void Emitter::FlowMapPrepareLongKey(EmitterNodeType::value child) { + const std::size_t lastIndent = m_pState->LastIndent(); + + if (!m_pState->HasBegunNode()) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(lastIndent); + if (m_pState->CurGroupChildCount() == 0) + m_stream << "{ ?"; + else + m_stream << ", ?"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo( + m_pState->HasBegunContent() || m_pState->CurGroupChildCount() > 0, + lastIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + assert(false); + break; + } +} + +void Emitter::FlowMapPrepareLongKeyValue(EmitterNodeType::value child) { + const std::size_t lastIndent = m_pState->LastIndent(); + + if (!m_pState->HasBegunNode()) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(lastIndent); + m_stream << ":"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo( + m_pState->HasBegunContent() || m_pState->CurGroupChildCount() > 0, + lastIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + assert(false); + break; + } +} + +void Emitter::FlowMapPrepareSimpleKey(EmitterNodeType::value child) { + const std::size_t lastIndent = m_pState->LastIndent(); + + if (!m_pState->HasBegunNode()) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(lastIndent); + if (m_pState->CurGroupChildCount() == 0) + m_stream << "{"; + else + m_stream << ","; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo( + m_pState->HasBegunContent() || m_pState->CurGroupChildCount() > 0, + lastIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + assert(false); + break; + } +} + +void Emitter::FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child) { + const std::size_t lastIndent = m_pState->LastIndent(); + + if (!m_pState->HasBegunNode()) { + if (m_stream.comment()) + m_stream << "\n"; + m_stream << IndentTo(lastIndent); + m_stream << ":"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo( + m_pState->HasBegunContent() || m_pState->CurGroupChildCount() > 0, + lastIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + assert(false); + break; + } +} + +void Emitter::BlockMapPrepareNode(EmitterNodeType::value child) { + if (m_pState->CurGroupChildCount() % 2 == 0) { + if (m_pState->GetMapKeyFormat() == LongKey) + m_pState->SetLongKey(); + if (child == EmitterNodeType::BlockSeq || + child == EmitterNodeType::BlockMap) + m_pState->SetLongKey(); + + if (m_pState->CurGroupLongKey()) + BlockMapPrepareLongKey(child); + else + BlockMapPrepareSimpleKey(child); + } else { + if (m_pState->CurGroupLongKey()) + BlockMapPrepareLongKeyValue(child); + else + BlockMapPrepareSimpleKeyValue(child); + } +} + +void Emitter::BlockMapPrepareLongKey(EmitterNodeType::value child) { + const std::size_t curIndent = m_pState->CurIndent(); + const std::size_t childCount = m_pState->CurGroupChildCount(); + + if (child == EmitterNodeType::NoType) + return; + + if (!m_pState->HasBegunContent()) { + if (childCount > 0) { + m_stream << "\n"; + } + if (m_stream.comment()) { + m_stream << "\n"; + } + m_stream << IndentTo(curIndent); + m_stream << "?"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo(true, curIndent + 1); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + break; + } +} + +void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child) { + const std::size_t curIndent = m_pState->CurIndent(); + + if (child == EmitterNodeType::NoType) + return; + + if (!m_pState->HasBegunContent()) { + m_stream << "\n"; + m_stream << IndentTo(curIndent); + m_stream << ":"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + SpaceOrIndentTo(true, curIndent + 1); + break; + } +} + +void Emitter::BlockMapPrepareSimpleKey(EmitterNodeType::value child) { + const std::size_t curIndent = m_pState->CurIndent(); + const std::size_t childCount = m_pState->CurGroupChildCount(); + + if (child == EmitterNodeType::NoType) + return; + + if (!m_pState->HasBegunNode()) { + if (childCount > 0) { + m_stream << "\n"; + } + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo(m_pState->HasBegunContent(), curIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + break; + } +} + +void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child) { + const std::size_t curIndent = m_pState->CurIndent(); + const std::size_t nextIndent = curIndent + m_pState->CurGroupIndent(); + + if (!m_pState->HasBegunNode()) { + m_stream << ":"; + } + + switch (child) { + case EmitterNodeType::NoType: + break; + case EmitterNodeType::Property: + case EmitterNodeType::Scalar: + case EmitterNodeType::FlowSeq: + case EmitterNodeType::FlowMap: + SpaceOrIndentTo(true, nextIndent); + break; + case EmitterNodeType::BlockSeq: + case EmitterNodeType::BlockMap: + m_stream << "\n"; + break; + } +} + +// SpaceOrIndentTo +// . Prepares for some more content by proper spacing +void Emitter::SpaceOrIndentTo(bool requireSpace, std::size_t indent) { + if (m_stream.comment()) + m_stream << "\n"; + if (m_stream.col() > 0 && requireSpace) + m_stream << " "; + m_stream << IndentTo(indent); +} + +void Emitter::PrepareIntegralStream(std::stringstream& stream) const { + + switch (m_pState->GetIntFormat()) { + case Dec: + stream << std::dec; + break; + case Hex: + stream << "0x"; + stream << std::hex; + break; + case Oct: + stream << "0"; + stream << std::oct; + break; + default: + assert(false); + } +} + +void Emitter::StartedScalar() { m_pState->StartedScalar(); } + +// ******************************************************************************************* +// overloads of Write + +Emitter& Emitter::Write(const std::string& str) { + if (!good()) + return *this; + + const bool escapeNonAscii = m_pState->GetOutputCharset() == EscapeNonAscii; + const StringFormat::value strFormat = + Utils::ComputeStringFormat(str, m_pState->GetStringFormat(), + m_pState->CurGroupFlowType(), escapeNonAscii); + + if (strFormat == StringFormat::Literal) + m_pState->SetMapKeyFormat(YAML::LongKey, FmtScope::Local); + + PrepareNode(EmitterNodeType::Scalar); + + switch (strFormat) { + case StringFormat::Plain: + m_stream << str; + break; + case StringFormat::SingleQuoted: + Utils::WriteSingleQuotedString(m_stream, str); + break; + case StringFormat::DoubleQuoted: + Utils::WriteDoubleQuotedString(m_stream, str, escapeNonAscii); + break; + case StringFormat::Literal: + Utils::WriteLiteralString(m_stream, str, + m_pState->CurIndent() + m_pState->GetIndent()); + break; + } + + StartedScalar(); + + return *this; +} + +std::size_t Emitter::GetFloatPrecision() const { + return m_pState->GetFloatPrecision(); +} + +std::size_t Emitter::GetDoublePrecision() const { + return m_pState->GetDoublePrecision(); +} + +const char* Emitter::ComputeFullBoolName(bool b) const { + const EMITTER_MANIP mainFmt = (m_pState->GetBoolLengthFormat() == ShortBool + ? YesNoBool + : m_pState->GetBoolFormat()); + const EMITTER_MANIP caseFmt = m_pState->GetBoolCaseFormat(); + switch (mainFmt) { + case YesNoBool: + switch (caseFmt) { + case UpperCase: + return b ? "YES" : "NO"; + case CamelCase: + return b ? "Yes" : "No"; + case LowerCase: + return b ? "yes" : "no"; + default: + break; + } + break; + case OnOffBool: + switch (caseFmt) { + case UpperCase: + return b ? "ON" : "OFF"; + case CamelCase: + return b ? "On" : "Off"; + case LowerCase: + return b ? "on" : "off"; + default: + break; + } + break; + case TrueFalseBool: + switch (caseFmt) { + case UpperCase: + return b ? "TRUE" : "FALSE"; + case CamelCase: + return b ? "True" : "False"; + case LowerCase: + return b ? "true" : "false"; + default: + break; + } + break; + default: + break; + } + return b ? "y" : "n"; // should never get here, but it can't hurt to give + // these answers +} + +Emitter& Emitter::Write(bool b) { + if (!good()) + return *this; + + PrepareNode(EmitterNodeType::Scalar); + + const char* name = ComputeFullBoolName(b); + if (m_pState->GetBoolLengthFormat() == ShortBool) + m_stream << name[0]; + else + m_stream << name; + + StartedScalar(); + + return *this; +} + +Emitter& Emitter::Write(char ch) { + if (!good()) + return *this; + + PrepareNode(EmitterNodeType::Scalar); + Utils::WriteChar(m_stream, ch); + StartedScalar(); + + return *this; +} + +Emitter& Emitter::Write(const _Alias& alias) { + if (!good()) + return *this; + + if (m_pState->HasAnchor() || m_pState->HasTag()) { + m_pState->SetError(ErrorMsg::INVALID_ALIAS); + return *this; + } + + PrepareNode(EmitterNodeType::Scalar); + + if (!Utils::WriteAlias(m_stream, alias.content)) { + m_pState->SetError(ErrorMsg::INVALID_ALIAS); + return *this; + } + + StartedScalar(); + + return *this; +} + +Emitter& Emitter::Write(const _Anchor& anchor) { + if (!good()) + return *this; + + if (m_pState->HasAnchor()) { + m_pState->SetError(ErrorMsg::INVALID_ANCHOR); + return *this; + } + + PrepareNode(EmitterNodeType::Property); + + if (!Utils::WriteAnchor(m_stream, anchor.content)) { + m_pState->SetError(ErrorMsg::INVALID_ANCHOR); + return *this; + } + + m_pState->SetAnchor(); + + return *this; +} + +Emitter& Emitter::Write(const _Tag& tag) { + if (!good()) + return *this; + + if (m_pState->HasTag()) { + m_pState->SetError(ErrorMsg::INVALID_TAG); + return *this; + } + + PrepareNode(EmitterNodeType::Property); + + bool success = false; + if (tag.type == _Tag::Type::Verbatim) + success = Utils::WriteTag(m_stream, tag.content, true); + else if (tag.type == _Tag::Type::PrimaryHandle) + success = Utils::WriteTag(m_stream, tag.content, false); + else + success = Utils::WriteTagWithPrefix(m_stream, tag.prefix, tag.content); + + if (!success) { + m_pState->SetError(ErrorMsg::INVALID_TAG); + return *this; + } + + m_pState->SetTag(); + + return *this; +} + +void Emitter::EmitKindTag() { Write(LocalTag("")); } + +Emitter& Emitter::Write(const _Comment& comment) { + if (!good()) + return *this; + + PrepareNode(EmitterNodeType::NoType); + + if (m_stream.col() > 0) + m_stream << Indentation(m_pState->GetPreCommentIndent()); + Utils::WriteComment(m_stream, comment.content, + m_pState->GetPostCommentIndent()); + + m_pState->SetNonContent(); + + return *this; +} + +Emitter& Emitter::Write(const _Null& /*null*/) { + if (!good()) + return *this; + + PrepareNode(EmitterNodeType::Scalar); + + m_stream << "~"; + + StartedScalar(); + + return *this; +} + +Emitter& Emitter::Write(const Binary& binary) { + Write(SecondaryTag("binary")); + + if (!good()) + return *this; + + PrepareNode(EmitterNodeType::Scalar); + Utils::WriteBinary(m_stream, binary); + StartedScalar(); + + return *this; +} +} diff --git a/src/yamlcpp/emitterstate.cpp b/src/yamlcpp/emitterstate.cpp --- a/src/yamlcpp/emitterstate.cpp +++ b/src/yamlcpp/emitterstate.cpp @@ -1,283 +1,365 @@ -#include "emitterstate.h" -#include "yaml-cpp/exceptions.h" #include -namespace LHAPDF_YAML -{ - EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_requiresSoftSeparation(false), m_requiresHardSeparation(false) - { - // start up - m_stateStack.push(ES_WAITING_FOR_DOC); +#include "emitterstate.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep - // set default global manipulators - m_charset.set(EmitNonAscii); - m_strFmt.set(Auto); - m_boolFmt.set(TrueFalseBool); - m_boolLengthFmt.set(LongBool); - m_boolCaseFmt.set(LowerCase); - m_intFmt.set(Dec); - m_indent.set(2); - m_preCommentIndent.set(2); - m_postCommentIndent.set(1); - m_seqFmt.set(Block); - m_mapFmt.set(Block); - m_mapKeyFmt.set(Auto); - m_floatPrecision.set(6); - m_doublePrecision.set(15); - } +namespace YAML { +EmitterState::EmitterState() + : m_isGood(true), + m_curIndent(0), + m_hasAnchor(false), + m_hasTag(false), + m_hasNonContent(false), + m_docCount(0) { + // set default global manipulators + m_charset.set(EmitNonAscii); + m_strFmt.set(Auto); + m_boolFmt.set(TrueFalseBool); + m_boolLengthFmt.set(LongBool); + m_boolCaseFmt.set(LowerCase); + m_intFmt.set(Dec); + m_indent.set(2); + m_preCommentIndent.set(2); + m_postCommentIndent.set(1); + m_seqFmt.set(Block); + m_mapFmt.set(Block); + m_mapKeyFmt.set(Auto); + m_floatPrecision.set(std::numeric_limits::digits10 + 1); + m_doublePrecision.set(std::numeric_limits::digits10 + 1); +} - EmitterState::~EmitterState() - { - } +EmitterState::~EmitterState() {} - // SetLocalValue - // . We blindly tries to set all possible formatters to this value - // . Only the ones that make sense will be accepted - void EmitterState::SetLocalValue(EMITTER_MANIP value) - { - SetOutputCharset(value, LOCAL); - SetStringFormat(value, LOCAL); - SetBoolFormat(value, LOCAL); - SetBoolCaseFormat(value, LOCAL); - SetBoolLengthFormat(value, LOCAL); - SetIntFormat(value, LOCAL); - SetFlowType(GT_SEQ, value, LOCAL); - SetFlowType(GT_MAP, value, LOCAL); - SetMapKeyFormat(value, LOCAL); - } +// SetLocalValue +// . We blindly tries to set all possible formatters to this value +// . Only the ones that make sense will be accepted +void EmitterState::SetLocalValue(EMITTER_MANIP value) { + SetOutputCharset(value, FmtScope::Local); + SetStringFormat(value, FmtScope::Local); + SetBoolFormat(value, FmtScope::Local); + SetBoolCaseFormat(value, FmtScope::Local); + SetBoolLengthFormat(value, FmtScope::Local); + SetIntFormat(value, FmtScope::Local); + SetFlowType(GroupType::Seq, value, FmtScope::Local); + SetFlowType(GroupType::Map, value, FmtScope::Local); + SetMapKeyFormat(value, FmtScope::Local); +} - void EmitterState::BeginGroup(GROUP_TYPE type) - { - unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent); - m_curIndent += lastIndent; +void EmitterState::SetAnchor() { m_hasAnchor = true; } - std::unique_ptr pGroup(new Group(type)); +void EmitterState::SetTag() { m_hasTag = true; } - // transfer settings (which last until this group is done) - pGroup->modifiedSettings = m_modifiedSettings; +void EmitterState::SetNonContent() { m_hasNonContent = true; } - // set up group - pGroup->flow = GetFlowType(type); - pGroup->indent = GetIndent(); - pGroup->usingLongKey = (GetMapKeyFormat() == LongKey ? true : false); +void EmitterState::SetLongKey() { + assert(!m_groups.empty()); + if (m_groups.empty()) { + return; + } - m_groups.push(std::move(pGroup)); - } + assert(m_groups.back()->type == GroupType::Map); + m_groups.back()->longKey = true; +} - void EmitterState::EndGroup(GROUP_TYPE type) - { - if(m_groups.empty()) - return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); +void EmitterState::ForceFlow() { + assert(!m_groups.empty()); + if (m_groups.empty()) { + return; + } - // get rid of the current group - { - std::unique_ptr pFinishedGroup = m_groups.pop(); - if(pFinishedGroup->type != type) - return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); - } + m_groups.back()->flowType = FlowType::Flow; +} - // reset old settings - unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent); - assert(m_curIndent >= lastIndent); - m_curIndent -= lastIndent; +void EmitterState::StartedNode() { + if (m_groups.empty()) { + m_docCount++; + } else { + m_groups.back()->childCount++; + if (m_groups.back()->childCount % 2 == 0) { + m_groups.back()->longKey = false; + } + } - // some global settings that we changed may have been overridden - // by a local setting we just popped, so we need to restore them - m_globalModifiedSettings.restore(); - } + m_hasAnchor = false; + m_hasTag = false; + m_hasNonContent = false; +} - GROUP_TYPE EmitterState::GetCurGroupType() const - { - if(m_groups.empty()) - return GT_NONE; +EmitterNodeType::value EmitterState::NextGroupType( + GroupType::value type) const { + if (type == GroupType::Seq) { + if (GetFlowType(type) == Block) + return EmitterNodeType::BlockSeq; + else + return EmitterNodeType::FlowSeq; + } else { + if (GetFlowType(type) == Block) + return EmitterNodeType::BlockMap; + else + return EmitterNodeType::FlowMap; + } - return m_groups.top().type; - } + // can't happen + assert(false); + return EmitterNodeType::NoType; +} - FLOW_TYPE EmitterState::GetCurGroupFlowType() const - { - if(m_groups.empty()) - return FT_NONE; +void EmitterState::StartedDoc() { + m_hasAnchor = false; + m_hasTag = false; + m_hasNonContent = false; +} - return (m_groups.top().flow == Flow ? FT_FLOW : FT_BLOCK); - } +void EmitterState::EndedDoc() { + m_hasAnchor = false; + m_hasTag = false; + m_hasNonContent = false; +} - bool EmitterState::CurrentlyInLongKey() - { - if(m_groups.empty()) - return false; - return m_groups.top().usingLongKey; - } +void EmitterState::StartedScalar() { + StartedNode(); + ClearModifiedSettings(); +} - void EmitterState::StartLongKey() - { - if(!m_groups.empty()) - m_groups.top().usingLongKey = true; - } +void EmitterState::StartedGroup(GroupType::value type) { + StartedNode(); - void EmitterState::StartSimpleKey() - { - if(!m_groups.empty()) - m_groups.top().usingLongKey = false; - } + const std::size_t lastGroupIndent = + (m_groups.empty() ? 0 : m_groups.back()->indent); + m_curIndent += lastGroupIndent; - void EmitterState::ClearModifiedSettings() - { - m_modifiedSettings.clear(); - } + // TODO: Create move constructors for settings types to simplify transfer + std::unique_ptr pGroup(new Group(type)); - bool EmitterState::SetOutputCharset(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case EmitNonAscii: - case EscapeNonAscii: - _Set(m_charset, value, scope); - return true; - default: - return false; - } - } + // transfer settings (which last until this group is done) + // + // NB: if pGroup->modifiedSettings == m_modifiedSettings, + // m_modifiedSettings is not changed! + pGroup->modifiedSettings = std::move(m_modifiedSettings); - bool EmitterState::SetStringFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Auto: - case SingleQuoted: - case DoubleQuoted: - case Literal: - _Set(m_strFmt, value, scope); - return true; - default: - return false; - } - } + // set up group + if (GetFlowType(type) == Block) { + pGroup->flowType = FlowType::Block; + } else { + pGroup->flowType = FlowType::Flow; + } + pGroup->indent = GetIndent(); - bool EmitterState::SetBoolFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case OnOffBool: - case TrueFalseBool: - case YesNoBool: - _Set(m_boolFmt, value, scope); - return true; - default: - return false; - } - } + m_groups.push_back(std::move(pGroup)); +} - bool EmitterState::SetBoolLengthFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case LongBool: - case ShortBool: - _Set(m_boolLengthFmt, value, scope); - return true; - default: - return false; - } - } +void EmitterState::EndedGroup(GroupType::value type) { + if (m_groups.empty()) { + if (type == GroupType::Seq) { + return SetError(ErrorMsg::UNEXPECTED_END_SEQ); + } else { + return SetError(ErrorMsg::UNEXPECTED_END_MAP); + } + } - bool EmitterState::SetBoolCaseFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case UpperCase: - case LowerCase: - case CamelCase: - _Set(m_boolCaseFmt, value, scope); - return true; - default: - return false; - } - } + // get rid of the current group + { + std::unique_ptr pFinishedGroup = std::move(m_groups.back()); + m_groups.pop_back(); + if (pFinishedGroup->type != type) { + return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); + } + } - bool EmitterState::SetIntFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Dec: - case Hex: - case Oct: - _Set(m_intFmt, value, scope); - return true; - default: - return false; - } - } + // reset old settings + std::size_t lastIndent = (m_groups.empty() ? 0 : m_groups.back()->indent); + assert(m_curIndent >= lastIndent); + m_curIndent -= lastIndent; - bool EmitterState::SetIndent(unsigned value, FMT_SCOPE scope) - { - if(value == 0) - return false; + // some global settings that we changed may have been overridden + // by a local setting we just popped, so we need to restore them + m_globalModifiedSettings.restore(); - _Set(m_indent, value, scope); - return true; - } + ClearModifiedSettings(); +} - bool EmitterState::SetPreCommentIndent(unsigned value, FMT_SCOPE scope) - { - if(value == 0) - return false; +EmitterNodeType::value EmitterState::CurGroupNodeType() const { + if (m_groups.empty()) { + return EmitterNodeType::NoType; + } - _Set(m_preCommentIndent, value, scope); - return true; - } + return m_groups.back()->NodeType(); +} - bool EmitterState::SetPostCommentIndent(unsigned value, FMT_SCOPE scope) - { - if(value == 0) - return false; +GroupType::value EmitterState::CurGroupType() const { + return m_groups.empty() ? GroupType::NoType : m_groups.back()->type; +} - _Set(m_postCommentIndent, value, scope); - return true; - } +FlowType::value EmitterState::CurGroupFlowType() const { + return m_groups.empty() ? FlowType::NoType : m_groups.back()->flowType; +} - bool EmitterState::SetFlowType(GROUP_TYPE groupType, EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Block: - case Flow: - _Set(groupType == GT_SEQ ? m_seqFmt : m_mapFmt, value, scope); - return true; - default: - return false; - } - } +std::size_t EmitterState::CurGroupIndent() const { + return m_groups.empty() ? 0 : m_groups.back()->indent; +} - EMITTER_MANIP EmitterState::GetFlowType(GROUP_TYPE groupType) const - { - // force flow style if we're currently in a flow - FLOW_TYPE flowType = GetCurGroupFlowType(); - if(flowType == FT_FLOW) - return Flow; +std::size_t EmitterState::CurGroupChildCount() const { + return m_groups.empty() ? m_docCount : m_groups.back()->childCount; +} - // otherwise, go with what's asked of use - return (groupType == GT_SEQ ? m_seqFmt.get() : m_mapFmt.get()); - } +bool EmitterState::CurGroupLongKey() const { + return m_groups.empty() ? false : m_groups.back()->longKey; +} - bool EmitterState::SetMapKeyFormat(EMITTER_MANIP value, FMT_SCOPE scope) - { - switch(value) { - case Auto: - case LongKey: - _Set(m_mapKeyFmt, value, scope); - return true; - default: - return false; - } - } +std::size_t EmitterState::LastIndent() const { + if (m_groups.size() <= 1) { + return 0; + } - bool EmitterState::SetFloatPrecision(int value, FMT_SCOPE scope) - { - if(value < 0 || value > std::numeric_limits::digits10) - return false; - _Set(m_floatPrecision, value, scope); - return true; - } + return m_curIndent - m_groups[m_groups.size() - 2]->indent; +} - bool EmitterState::SetDoublePrecision(int value, FMT_SCOPE scope) - { - if(value < 0 || value > std::numeric_limits::digits10) - return false; - _Set(m_doublePrecision, value, scope); - return true; - } +void EmitterState::ClearModifiedSettings() { m_modifiedSettings.clear(); } + +bool EmitterState::SetOutputCharset(EMITTER_MANIP value, + FmtScope::value scope) { + switch (value) { + case EmitNonAscii: + case EscapeNonAscii: + _Set(m_charset, value, scope); + return true; + default: + return false; + } } + +bool EmitterState::SetStringFormat(EMITTER_MANIP value, FmtScope::value scope) { + switch (value) { + case Auto: + case SingleQuoted: + case DoubleQuoted: + case Literal: + _Set(m_strFmt, value, scope); + return true; + default: + return false; + } +} + +bool EmitterState::SetBoolFormat(EMITTER_MANIP value, FmtScope::value scope) { + switch (value) { + case OnOffBool: + case TrueFalseBool: + case YesNoBool: + _Set(m_boolFmt, value, scope); + return true; + default: + return false; + } +} + +bool EmitterState::SetBoolLengthFormat(EMITTER_MANIP value, + FmtScope::value scope) { + switch (value) { + case LongBool: + case ShortBool: + _Set(m_boolLengthFmt, value, scope); + return true; + default: + return false; + } +} + +bool EmitterState::SetBoolCaseFormat(EMITTER_MANIP value, + FmtScope::value scope) { + switch (value) { + case UpperCase: + case LowerCase: + case CamelCase: + _Set(m_boolCaseFmt, value, scope); + return true; + default: + return false; + } +} + +bool EmitterState::SetIntFormat(EMITTER_MANIP value, FmtScope::value scope) { + switch (value) { + case Dec: + case Hex: + case Oct: + _Set(m_intFmt, value, scope); + return true; + default: + return false; + } +} + +bool EmitterState::SetIndent(std::size_t value, FmtScope::value scope) { + if (value <= 1) + return false; + + _Set(m_indent, value, scope); + return true; +} + +bool EmitterState::SetPreCommentIndent(std::size_t value, + FmtScope::value scope) { + if (value == 0) + return false; + + _Set(m_preCommentIndent, value, scope); + return true; +} + +bool EmitterState::SetPostCommentIndent(std::size_t value, + FmtScope::value scope) { + if (value == 0) + return false; + + _Set(m_postCommentIndent, value, scope); + return true; +} + +bool EmitterState::SetFlowType(GroupType::value groupType, EMITTER_MANIP value, + FmtScope::value scope) { + switch (value) { + case Block: + case Flow: + _Set(groupType == GroupType::Seq ? m_seqFmt : m_mapFmt, value, scope); + return true; + default: + return false; + } +} + +EMITTER_MANIP EmitterState::GetFlowType(GroupType::value groupType) const { + // force flow style if we're currently in a flow + if (CurGroupFlowType() == FlowType::Flow) + return Flow; + + // otherwise, go with what's asked of us + return (groupType == GroupType::Seq ? m_seqFmt.get() : m_mapFmt.get()); +} + +bool EmitterState::SetMapKeyFormat(EMITTER_MANIP value, FmtScope::value scope) { + switch (value) { + case Auto: + case LongKey: + _Set(m_mapKeyFmt, value, scope); + return true; + default: + return false; + } +} + +bool EmitterState::SetFloatPrecision(std::size_t value, FmtScope::value scope) { + if (value > std::numeric_limits::digits10 + 1) + return false; + _Set(m_floatPrecision, value, scope); + return true; +} + +bool EmitterState::SetDoublePrecision(std::size_t value, + FmtScope::value scope) { + if (value > std::numeric_limits::digits10 + 1) + return false; + _Set(m_doublePrecision, value, scope); + return true; +} +} diff --git a/src/yamlcpp/emitterstate.h b/src/yamlcpp/emitterstate.h --- a/src/yamlcpp/emitterstate.h +++ b/src/yamlcpp/emitterstate.h @@ -1,217 +1,203 @@ #ifndef EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include "setting.h" +#include "yaml-cpp/emitterdef.h" +#include "yaml-cpp/emittermanip.h" -#include "ptr_stack.h" -#include "setting.h" -#include "yaml-cpp/emittermanip.h" #include +#include +#include +#include #include -#include -#include -namespace LHAPDF_YAML -{ - enum FMT_SCOPE { - LOCAL, - GLOBAL - }; - - enum GROUP_TYPE { - GT_NONE, - GT_SEQ, - GT_MAP - }; - - enum FLOW_TYPE { - FT_NONE, - FT_FLOW, - FT_BLOCK - }; - - enum NODE_STATE { - NS_START, - NS_READY_FOR_ATOM, - NS_END - }; - - enum EMITTER_STATE { - ES_WAITING_FOR_DOC, - ES_WRITING_DOC, - ES_DONE_WITH_DOC, - - // block seq - ES_WAITING_FOR_BLOCK_SEQ_ENTRY, - ES_WRITING_BLOCK_SEQ_ENTRY, - ES_DONE_WITH_BLOCK_SEQ_ENTRY, - - // flow seq - ES_WAITING_FOR_FLOW_SEQ_ENTRY, - ES_WRITING_FLOW_SEQ_ENTRY, - ES_DONE_WITH_FLOW_SEQ_ENTRY, - - // block map - ES_WAITING_FOR_BLOCK_MAP_ENTRY, - ES_WAITING_FOR_BLOCK_MAP_KEY, - ES_WRITING_BLOCK_MAP_KEY, - ES_DONE_WITH_BLOCK_MAP_KEY, - ES_WAITING_FOR_BLOCK_MAP_VALUE, - ES_WRITING_BLOCK_MAP_VALUE, - ES_DONE_WITH_BLOCK_MAP_VALUE, - - // flow map - ES_WAITING_FOR_FLOW_MAP_ENTRY, - ES_WAITING_FOR_FLOW_MAP_KEY, - ES_WRITING_FLOW_MAP_KEY, - ES_DONE_WITH_FLOW_MAP_KEY, - ES_WAITING_FOR_FLOW_MAP_VALUE, - ES_WRITING_FLOW_MAP_VALUE, - ES_DONE_WITH_FLOW_MAP_VALUE - }; - - class EmitterState - { - public: - EmitterState(); - ~EmitterState(); - - // basic state checking - bool good() const { return m_isGood; } - const std::string GetLastError() const { return m_lastError; } - void SetError(const std::string& error) { m_isGood = false; m_lastError = error; } - - // main state of the machine - EMITTER_STATE GetCurState() const { return m_stateStack.top(); } - void SwitchState(EMITTER_STATE state) { PopState(); PushState(state); } - void PushState(EMITTER_STATE state) { m_stateStack.push(state); } - void PopState() { m_stateStack.pop(); } - - void SetLocalValue(EMITTER_MANIP value); - - // group handling - void BeginGroup(GROUP_TYPE type); - void EndGroup(GROUP_TYPE type); - - GROUP_TYPE GetCurGroupType() const; - FLOW_TYPE GetCurGroupFlowType() const; - int GetCurIndent() const { return m_curIndent; } - - bool CurrentlyInLongKey(); - void StartLongKey(); - void StartSimpleKey(); +namespace YAML { +struct FmtScope { + enum value { Local, Global }; +}; +struct GroupType { + enum value { NoType, Seq, Map }; +}; +struct FlowType { + enum value { NoType, Flow, Block }; +}; - bool RequiresSoftSeparation() const { return m_requiresSoftSeparation; } - bool RequiresHardSeparation() const { return m_requiresHardSeparation; } - void RequireSoftSeparation() { m_requiresSoftSeparation = true; } - void RequireHardSeparation() { m_requiresSoftSeparation = true; m_requiresHardSeparation = true; } - void ForceHardSeparation() { m_requiresSoftSeparation = false; } - void UnsetSeparation() { m_requiresSoftSeparation = false; m_requiresHardSeparation = false; } +class EmitterState { + public: + EmitterState(); + ~EmitterState(); - void ClearModifiedSettings(); + // basic state checking + bool good() const { return m_isGood; } + const std::string GetLastError() const { return m_lastError; } + void SetError(const std::string& error) { + m_isGood = false; + m_lastError = error; + } - // formatters - bool SetOutputCharset(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetOutputCharset() const { return m_charset.get(); } + // node handling + void SetAnchor(); + void SetTag(); + void SetNonContent(); + void SetLongKey(); + void ForceFlow(); + void StartedDoc(); + void EndedDoc(); + void StartedScalar(); + void StartedGroup(GroupType::value type); + void EndedGroup(GroupType::value type); - bool SetStringFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetStringFormat() const { return m_strFmt.get(); } - - bool SetBoolFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetBoolFormat() const { return m_boolFmt.get(); } + EmitterNodeType::value NextGroupType(GroupType::value type) const; + EmitterNodeType::value CurGroupNodeType() const; - bool SetBoolLengthFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetBoolLengthFormat() const { return m_boolLengthFmt.get(); } + GroupType::value CurGroupType() const; + FlowType::value CurGroupFlowType() const; + std::size_t CurGroupIndent() const; + std::size_t CurGroupChildCount() const; + bool CurGroupLongKey() const; - bool SetBoolCaseFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetBoolCaseFormat() const { return m_boolCaseFmt.get(); } + std::size_t LastIndent() const; + std::size_t CurIndent() const { return m_curIndent; } + bool HasAnchor() const { return m_hasAnchor; } + bool HasTag() const { return m_hasTag; } + bool HasBegunNode() const { + return m_hasAnchor || m_hasTag || m_hasNonContent; + } + bool HasBegunContent() const { return m_hasAnchor || m_hasTag; } - bool SetIntFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetIntFormat() const { return m_intFmt.get(); } + void ClearModifiedSettings(); - bool SetIndent(unsigned value, FMT_SCOPE scope); - int GetIndent() const { return m_indent.get(); } - - bool SetPreCommentIndent(unsigned value, FMT_SCOPE scope); - int GetPreCommentIndent() const { return m_preCommentIndent.get(); } - bool SetPostCommentIndent(unsigned value, FMT_SCOPE scope); - int GetPostCommentIndent() const { return m_postCommentIndent.get(); } - - bool SetFlowType(GROUP_TYPE groupType, EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetFlowType(GROUP_TYPE groupType) const; - - bool SetMapKeyFormat(EMITTER_MANIP value, FMT_SCOPE scope); - EMITTER_MANIP GetMapKeyFormat() const { return m_mapKeyFmt.get(); } - - bool SetFloatPrecision(int value, FMT_SCOPE scope); - unsigned GetFloatPrecision() const { return m_floatPrecision.get(); } - bool SetDoublePrecision(int value, FMT_SCOPE scope); - unsigned GetDoublePrecision() const { return m_doublePrecision.get(); } - - private: - template - void _Set(Setting& fmt, T value, FMT_SCOPE scope); - - private: - // basic state ok? - bool m_isGood; - std::string m_lastError; - - // other state - std::stack m_stateStack; - - Setting m_charset; - Setting m_strFmt; - Setting m_boolFmt; - Setting m_boolLengthFmt; - Setting m_boolCaseFmt; - Setting m_intFmt; - Setting m_indent; - Setting m_preCommentIndent, m_postCommentIndent; - Setting m_seqFmt; - Setting m_mapFmt; - Setting m_mapKeyFmt; - Setting m_floatPrecision; - Setting m_doublePrecision; - - SettingChanges m_modifiedSettings; - SettingChanges m_globalModifiedSettings; - - struct Group { - Group(GROUP_TYPE type_): type(type_), usingLongKey(false), indent(0) {} - - GROUP_TYPE type; - EMITTER_MANIP flow; - bool usingLongKey; - int indent; - - SettingChanges modifiedSettings; - }; + // formatters + void SetLocalValue(EMITTER_MANIP value); - ptr_stack m_groups; - unsigned m_curIndent; - bool m_requiresSoftSeparation; - bool m_requiresHardSeparation; - }; + bool SetOutputCharset(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetOutputCharset() const { return m_charset.get(); } - template - void EmitterState::_Set(Setting& fmt, T value, FMT_SCOPE scope) { - switch(scope) { - case LOCAL: - m_modifiedSettings.push(fmt.set(value)); - break; - case GLOBAL: - fmt.set(value); - m_globalModifiedSettings.push(fmt.set(value)); // this pushes an identity set, so when we restore, - // it restores to the value here, and not the previous one - break; - default: - assert(false); - } - } + bool SetStringFormat(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetStringFormat() const { return m_strFmt.get(); } + + bool SetBoolFormat(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetBoolFormat() const { return m_boolFmt.get(); } + + bool SetBoolLengthFormat(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetBoolLengthFormat() const { return m_boolLengthFmt.get(); } + + bool SetBoolCaseFormat(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetBoolCaseFormat() const { return m_boolCaseFmt.get(); } + + bool SetIntFormat(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetIntFormat() const { return m_intFmt.get(); } + + bool SetIndent(std::size_t value, FmtScope::value scope); + std::size_t GetIndent() const { return m_indent.get(); } + + bool SetPreCommentIndent(std::size_t value, FmtScope::value scope); + std::size_t GetPreCommentIndent() const { return m_preCommentIndent.get(); } + bool SetPostCommentIndent(std::size_t value, FmtScope::value scope); + std::size_t GetPostCommentIndent() const { return m_postCommentIndent.get(); } + + bool SetFlowType(GroupType::value groupType, EMITTER_MANIP value, + FmtScope::value scope); + EMITTER_MANIP GetFlowType(GroupType::value groupType) const; + + bool SetMapKeyFormat(EMITTER_MANIP value, FmtScope::value scope); + EMITTER_MANIP GetMapKeyFormat() const { return m_mapKeyFmt.get(); } + + bool SetFloatPrecision(std::size_t value, FmtScope::value scope); + std::size_t GetFloatPrecision() const { return m_floatPrecision.get(); } + bool SetDoublePrecision(std::size_t value, FmtScope::value scope); + std::size_t GetDoublePrecision() const { return m_doublePrecision.get(); } + + private: + template + void _Set(Setting& fmt, T value, FmtScope::value scope); + + void StartedNode(); + + private: + // basic state ok? + bool m_isGood; + std::string m_lastError; + + // other state + Setting m_charset; + Setting m_strFmt; + Setting m_boolFmt; + Setting m_boolLengthFmt; + Setting m_boolCaseFmt; + Setting m_intFmt; + Setting m_indent; + Setting m_preCommentIndent, m_postCommentIndent; + Setting m_seqFmt; + Setting m_mapFmt; + Setting m_mapKeyFmt; + Setting m_floatPrecision; + Setting m_doublePrecision; + + SettingChanges m_modifiedSettings; + SettingChanges m_globalModifiedSettings; + + struct Group { + explicit Group(GroupType::value type_) + : type(type_), indent(0), childCount(0), longKey(false) {} + + GroupType::value type; + FlowType::value flowType; + std::size_t indent; + std::size_t childCount; + bool longKey; + + SettingChanges modifiedSettings; + + EmitterNodeType::value NodeType() const { + if (type == GroupType::Seq) { + if (flowType == FlowType::Flow) + return EmitterNodeType::FlowSeq; + else + return EmitterNodeType::BlockSeq; + } else { + if (flowType == FlowType::Flow) + return EmitterNodeType::FlowMap; + else + return EmitterNodeType::BlockMap; + } + + // can't get here + assert(false); + return EmitterNodeType::NoType; + } + }; + + std::vector> m_groups; + std::size_t m_curIndent; + bool m_hasAnchor; + bool m_hasTag; + bool m_hasNonContent; + std::size_t m_docCount; +}; + +template +void EmitterState::_Set(Setting& fmt, T value, FmtScope::value scope) { + switch (scope) { + case FmtScope::Local: + m_modifiedSettings.push(fmt.set(value)); + break; + case FmtScope::Global: + fmt.set(value); + m_globalModifiedSettings.push( + fmt.set(value)); // this pushes an identity set, so when we restore, + // it restores to the value here, and not the previous one + break; + default: + assert(false); + } +} } -#endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/emitterutils.cpp b/src/yamlcpp/emitterutils.cpp --- a/src/yamlcpp/emitterutils.cpp +++ b/src/yamlcpp/emitterutils.cpp @@ -1,378 +1,483 @@ +#include +#include + #include "emitterutils.h" #include "exp.h" #include "indentation.h" -#include "yaml-cpp/binary.h" -#include "yaml-cpp/exceptions.h" +#include "regex_yaml.h" +#include "regeximpl.h" #include "stringsource.h" -#include -#include +#include "yaml-cpp/binary.h" // IWYU pragma: keep +#include "yaml-cpp/ostream_wrapper.h" +#include "yaml-cpp/null.h" -namespace LHAPDF_YAML -{ - namespace Utils - { - namespace { - enum {REPLACEMENT_CHARACTER = 0xFFFD}; +namespace YAML { +namespace Utils { +namespace { +enum { REPLACEMENT_CHARACTER = 0xFFFD }; - bool IsAnchorChar(int ch) { // test for ns-anchor-char - switch (ch) { - case ',': case '[': case ']': case '{': case '}': // c-flow-indicator - case ' ': case '\t': // s-white - case 0xFEFF: // c-byte-order-mark - case 0xA: case 0xD: // b-char - return false; - case 0x85: - return true; - } +bool IsAnchorChar(int ch) { // test for ns-anchor-char + switch (ch) { + case ',': + case '[': + case ']': + case '{': + case '}': // c-flow-indicator + case ' ': + case '\t': // s-white + case 0xFEFF: // c-byte-order-mark + case 0xA: + case 0xD: // b-char + return false; + case 0x85: + return true; + } - if (ch < 0x20) - return false; + if (ch < 0x20) { + return false; + } - if (ch < 0x7E) - return true; + if (ch < 0x7E) { + return true; + } - if (ch < 0xA0) - return false; - if (ch >= 0xD800 && ch <= 0xDFFF) - return false; - if ((ch & 0xFFFE) == 0xFFFE) - return false; - if ((ch >= 0xFDD0) && (ch <= 0xFDEF)) - return false; - if (ch > 0x10FFFF) - return false; + if (ch < 0xA0) { + return false; + } + if (ch >= 0xD800 && ch <= 0xDFFF) { + return false; + } + if ((ch & 0xFFFE) == 0xFFFE) { + return false; + } + if ((ch >= 0xFDD0) && (ch <= 0xFDEF)) { + return false; + } + if (ch > 0x10FFFF) { + return false; + } - return true; - } - - int Utf8BytesIndicated(char ch) { - int byteVal = static_cast(ch); - switch (byteVal >> 4) { - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: - return 1; - case 12: case 13: - return 2; - case 14: - return 3; - case 15: - return 4; - default: - return -1; - } - } - - bool IsTrailingByte(char ch) { - return (ch & 0xC0) == 0x80; - } - - bool GetNextCodePointAndAdvance(int& codePoint, std::string::const_iterator& first, std::string::const_iterator last) { - if (first == last) - return false; - - int nBytes = Utf8BytesIndicated(*first); - if (nBytes < 1) { - // Bad lead byte - ++first; - codePoint = REPLACEMENT_CHARACTER; - return true; - } - - if (nBytes == 1) { - codePoint = *first++; - return true; - } - - // Gather bits from trailing bytes - codePoint = static_cast(*first) & ~(0xFF << (7 - nBytes)); - ++first; - --nBytes; - for (; nBytes > 0; ++first, --nBytes) { - if ((first == last) || !IsTrailingByte(*first)) { - codePoint = REPLACEMENT_CHARACTER; - break; - } - codePoint <<= 6; - codePoint |= *first & 0x3F; - } - - // Check for illegal code points - if (codePoint > 0x10FFFF) - codePoint = REPLACEMENT_CHARACTER; - else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) - codePoint = REPLACEMENT_CHARACTER; - else if ((codePoint & 0xFFFE) == 0xFFFE) - codePoint = REPLACEMENT_CHARACTER; - else if (codePoint >= 0xFDD0 && codePoint <= 0xFDEF) - codePoint = REPLACEMENT_CHARACTER; - return true; - } - - void WriteCodePoint(ostream& out, int codePoint) { - if (codePoint < 0 || codePoint > 0x10FFFF) { - codePoint = REPLACEMENT_CHARACTER; - } - if (codePoint < 0x7F) { - out << static_cast(codePoint); - } else if (codePoint < 0x7FF) { - out << static_cast(0xC0 | (codePoint >> 6)) - << static_cast(0x80 | (codePoint & 0x3F)); - } else if (codePoint < 0xFFFF) { - out << static_cast(0xE0 | (codePoint >> 12)) - << static_cast(0x80 | ((codePoint >> 6) & 0x3F)) - << static_cast(0x80 | (codePoint & 0x3F)); - } else { - out << static_cast(0xF0 | (codePoint >> 18)) - << static_cast(0x80 | ((codePoint >> 12) & 0x3F)) - << static_cast(0x80 | ((codePoint >> 6) & 0x3F)) - << static_cast(0x80 | (codePoint & 0x3F)); - } - } - - bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) { - if(str.empty()) - return false; - - // first check the start - const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar()); - if(!start.Matches(str)) - return false; - - // and check the end for plain whitespace (which can't be faithfully kept in a plain scalar) - if(!str.empty() && *str.rbegin() == ' ') - return false; - - // then check until something is disallowed - const RegEx& disallowed = (inFlow ? Exp::EndScalarInFlow() : Exp::EndScalar()) - || (Exp::BlankOrBreak() + Exp::Comment()) - || Exp::NotPrintable() - || Exp::Utf8_ByteOrderMark() - || Exp::Break() - || Exp::Tab(); - StringCharSource buffer(str.c_str(), str.size()); - while(buffer) { - if(disallowed.Matches(buffer)) - return false; - if(allowOnlyAscii && (0x7F < static_cast(buffer[0]))) - return false; - ++buffer; - } - - return true; - } - - void WriteDoubleQuoteEscapeSequence(ostream& out, int codePoint) { - static const char hexDigits[] = "0123456789abcdef"; - - char escSeq[] = "\\U00000000"; - int digits = 8; - if (codePoint < 0xFF) { - escSeq[1] = 'x'; - digits = 2; - } else if (codePoint < 0xFFFF) { - escSeq[1] = 'u'; - digits = 4; - } - - // Write digits into the escape sequence - int i = 2; - for (; digits > 0; --digits, ++i) { - escSeq[i] = hexDigits[(codePoint >> (4 * (digits - 1))) & 0xF]; - } - - escSeq[i] = 0; // terminate with NUL character - out << escSeq; - } - - bool WriteAliasName(ostream& out, const std::string& str) { - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (!IsAnchorChar(codePoint)) - return false; - - WriteCodePoint(out, codePoint); - } - return true; - } - } - - bool WriteString(ostream& out, const std::string& str, bool inFlow, bool escapeNonAscii) - { - if(IsValidPlainScalar(str, inFlow, escapeNonAscii)) { - out << str; - return true; - } else - return WriteDoubleQuotedString(out, str, escapeNonAscii); - } - - bool WriteSingleQuotedString(ostream& out, const std::string& str) - { - out << "'"; - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (codePoint == '\n') - return false; // We can't handle a new line and the attendant indentation yet - - if (codePoint == '\'') - out << "''"; - else - WriteCodePoint(out, codePoint); - } - out << "'"; - return true; - } - - bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii) - { - out << "\""; - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (codePoint == '\"') - out << "\\\""; - else if (codePoint == '\\') - out << "\\\\"; - else if (codePoint < 0x20 || (codePoint >= 0x80 && codePoint <= 0xA0)) // Control characters and non-breaking space - WriteDoubleQuoteEscapeSequence(out, codePoint); - else if (codePoint == 0xFEFF) // Byte order marks (ZWNS) should be escaped (YAML 1.2, sec. 5.2) - WriteDoubleQuoteEscapeSequence(out, codePoint); - else if (escapeNonAscii && codePoint > 0x7E) - WriteDoubleQuoteEscapeSequence(out, codePoint); - else - WriteCodePoint(out, codePoint); - } - out << "\""; - return true; - } - - bool WriteLiteralString(ostream& out, const std::string& str, int indent) - { - out << "|\n"; - out << IndentTo(indent); - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if (codePoint == '\n') - out << "\n" << IndentTo(indent); - else - WriteCodePoint(out, codePoint); - } - return true; - } - - bool WriteChar(ostream& out, char ch) - { - if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) - out << ch; - else if((0x20 <= ch && ch <= 0x7e) || ch == ' ') - out << "\"" << ch << "\""; - else if(ch == '\t') - out << "\"\\t\""; - else if(ch == '\n') - out << "\"\\n\""; - else if(ch == '\b') - out << "\"\\b\""; - else { - out << "\""; - WriteDoubleQuoteEscapeSequence(out, ch); - out << "\""; - } - return true; - } - - bool WriteComment(ostream& out, const std::string& str, int postCommentIndent) - { - const unsigned curIndent = out.col(); - out << "#" << Indentation(postCommentIndent); - int codePoint; - for(std::string::const_iterator i = str.begin(); - GetNextCodePointAndAdvance(codePoint, i, str.end()); - ) - { - if(codePoint == '\n') - out << "\n" << IndentTo(curIndent) << "#" << Indentation(postCommentIndent); - else - WriteCodePoint(out, codePoint); - } - return true; - } - - bool WriteAlias(ostream& out, const std::string& str) - { - out << "*"; - return WriteAliasName(out, str); - } - - bool WriteAnchor(ostream& out, const std::string& str) - { - out << "&"; - return WriteAliasName(out, str); - } - - bool WriteTag(ostream& out, const std::string& str, bool verbatim) - { - out << (verbatim ? "!<" : "!"); - StringCharSource buffer(str.c_str(), str.size()); - const RegEx& reValid = verbatim ? Exp::URI() : Exp::Tag(); - while(buffer) { - int n = reValid.Match(buffer); - if(n <= 0) - return false; - - while(--n >= 0) { - out << buffer[0]; - ++buffer; - } - } - if (verbatim) - out << ">"; - return true; - } - - bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag) - { - out << "!"; - StringCharSource prefixBuffer(prefix.c_str(), prefix.size()); - while(prefixBuffer) { - int n = Exp::URI().Match(prefixBuffer); - if(n <= 0) - return false; - - while(--n >= 0) { - out << prefixBuffer[0]; - ++prefixBuffer; - } - } - - out << "!"; - StringCharSource tagBuffer(tag.c_str(), tag.size()); - while(tagBuffer) { - int n = Exp::Tag().Match(tagBuffer); - if(n <= 0) - return false; - - while(--n >= 0) { - out << tagBuffer[0]; - ++tagBuffer; - } - } - return true; - } - - bool WriteBinary(ostream& out, const Binary& binary) - { - WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()), false); - return true; - } - } + return true; } +int Utf8BytesIndicated(char ch) { + int byteVal = static_cast(ch); + switch (byteVal >> 4) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + return 1; + case 12: + case 13: + return 2; + case 14: + return 3; + case 15: + return 4; + default: + return -1; + } +} + +bool IsTrailingByte(char ch) { return (ch & 0xC0) == 0x80; } + +bool GetNextCodePointAndAdvance(int& codePoint, + std::string::const_iterator& first, + std::string::const_iterator last) { + if (first == last) + return false; + + int nBytes = Utf8BytesIndicated(*first); + if (nBytes < 1) { + // Bad lead byte + ++first; + codePoint = REPLACEMENT_CHARACTER; + return true; + } + + if (nBytes == 1) { + codePoint = *first++; + return true; + } + + // Gather bits from trailing bytes + codePoint = static_cast(*first) & ~(0xFF << (7 - nBytes)); + ++first; + --nBytes; + for (; nBytes > 0; ++first, --nBytes) { + if ((first == last) || !IsTrailingByte(*first)) { + codePoint = REPLACEMENT_CHARACTER; + break; + } + codePoint <<= 6; + codePoint |= *first & 0x3F; + } + + // Check for illegal code points + if (codePoint > 0x10FFFF) + codePoint = REPLACEMENT_CHARACTER; + else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) + codePoint = REPLACEMENT_CHARACTER; + else if ((codePoint & 0xFFFE) == 0xFFFE) + codePoint = REPLACEMENT_CHARACTER; + else if (codePoint >= 0xFDD0 && codePoint <= 0xFDEF) + codePoint = REPLACEMENT_CHARACTER; + return true; +} + +void WriteCodePoint(ostream_wrapper& out, int codePoint) { + if (codePoint < 0 || codePoint > 0x10FFFF) { + codePoint = REPLACEMENT_CHARACTER; + } + if (codePoint < 0x7F) { + out << static_cast(codePoint); + } else if (codePoint < 0x7FF) { + out << static_cast(0xC0 | (codePoint >> 6)) + << static_cast(0x80 | (codePoint & 0x3F)); + } else if (codePoint < 0xFFFF) { + out << static_cast(0xE0 | (codePoint >> 12)) + << static_cast(0x80 | ((codePoint >> 6) & 0x3F)) + << static_cast(0x80 | (codePoint & 0x3F)); + } else { + out << static_cast(0xF0 | (codePoint >> 18)) + << static_cast(0x80 | ((codePoint >> 12) & 0x3F)) + << static_cast(0x80 | ((codePoint >> 6) & 0x3F)) + << static_cast(0x80 | (codePoint & 0x3F)); + } +} + +bool IsValidPlainScalar(const std::string& str, FlowType::value flowType, + bool allowOnlyAscii) { + // check against null + if (IsNullString(str)) { + return false; + } + + // check the start + const RegEx& start = (flowType == FlowType::Flow ? Exp::PlainScalarInFlow() + : Exp::PlainScalar()); + if (!start.Matches(str)) { + return false; + } + + // and check the end for plain whitespace (which can't be faithfully kept in a + // plain scalar) + if (!str.empty() && *str.rbegin() == ' ') { + return false; + } + + // then check until something is disallowed + static const RegEx& disallowed_flow = + Exp::EndScalarInFlow() || (Exp::BlankOrBreak() + Exp::Comment()) || + Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() || Exp::Break() || + Exp::Tab(); + static const RegEx& disallowed_block = + Exp::EndScalar() || (Exp::BlankOrBreak() + Exp::Comment()) || + Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() || Exp::Break() || + Exp::Tab(); + const RegEx& disallowed = + flowType == FlowType::Flow ? disallowed_flow : disallowed_block; + + StringCharSource buffer(str.c_str(), str.size()); + while (buffer) { + if (disallowed.Matches(buffer)) { + return false; + } + if (allowOnlyAscii && (0x80 <= static_cast(buffer[0]))) { + return false; + } + ++buffer; + } + + return true; +} + +bool IsValidSingleQuotedScalar(const std::string& str, bool escapeNonAscii) { + // TODO: check for non-printable characters? + for (std::size_t i = 0; i < str.size(); i++) { + if (escapeNonAscii && (0x80 <= static_cast(str[i]))) { + return false; + } + if (str[i] == '\n') { + return false; + } + } + return true; +} + +bool IsValidLiteralScalar(const std::string& str, FlowType::value flowType, + bool escapeNonAscii) { + if (flowType == FlowType::Flow) { + return false; + } + + // TODO: check for non-printable characters? + for (std::size_t i = 0; i < str.size(); i++) { + if (escapeNonAscii && (0x80 <= static_cast(str[i]))) { + return false; + } + } + return true; +} + +void WriteDoubleQuoteEscapeSequence(ostream_wrapper& out, int codePoint) { + static const char hexDigits[] = "0123456789abcdef"; + + out << "\\"; + int digits = 8; + if (codePoint < 0xFF) { + out << "x"; + digits = 2; + } else if (codePoint < 0xFFFF) { + out << "u"; + digits = 4; + } else { + out << "U"; + digits = 8; + } + + // Write digits into the escape sequence + for (; digits > 0; --digits) + out << hexDigits[(codePoint >> (4 * (digits - 1))) & 0xF]; +} + +bool WriteAliasName(ostream_wrapper& out, const std::string& str) { + int codePoint; + for (std::string::const_iterator i = str.begin(); + GetNextCodePointAndAdvance(codePoint, i, str.end());) { + if (!IsAnchorChar(codePoint)) { + return false; + } + + WriteCodePoint(out, codePoint); + } + return true; +} +} + +StringFormat::value ComputeStringFormat(const std::string& str, + EMITTER_MANIP strFormat, + FlowType::value flowType, + bool escapeNonAscii) { + switch (strFormat) { + case Auto: + if (IsValidPlainScalar(str, flowType, escapeNonAscii)) { + return StringFormat::Plain; + } + return StringFormat::DoubleQuoted; + case SingleQuoted: + if (IsValidSingleQuotedScalar(str, escapeNonAscii)) { + return StringFormat::SingleQuoted; + } + return StringFormat::DoubleQuoted; + case DoubleQuoted: + return StringFormat::DoubleQuoted; + case Literal: + if (IsValidLiteralScalar(str, flowType, escapeNonAscii)) { + return StringFormat::Literal; + } + return StringFormat::DoubleQuoted; + default: + break; + } + + return StringFormat::DoubleQuoted; +} + +bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str) { + out << "'"; + int codePoint; + for (std::string::const_iterator i = str.begin(); + GetNextCodePointAndAdvance(codePoint, i, str.end());) { + if (codePoint == '\n') { + return false; // We can't handle a new line and the attendant indentation + // yet + } + + if (codePoint == '\'') { + out << "''"; + } else { + WriteCodePoint(out, codePoint); + } + } + out << "'"; + return true; +} + +bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, + bool escapeNonAscii) { + out << "\""; + int codePoint; + for (std::string::const_iterator i = str.begin(); + GetNextCodePointAndAdvance(codePoint, i, str.end());) { + switch (codePoint) { + case '\"': + out << "\\\""; + break; + case '\\': + out << "\\\\"; + break; + case '\n': + out << "\\n"; + break; + case '\t': + out << "\\t"; + break; + case '\r': + out << "\\r"; + break; + case '\b': + out << "\\b"; + break; + default: + if (codePoint < 0x20 || + (codePoint >= 0x80 && + codePoint <= 0xA0)) { // Control characters and non-breaking space + WriteDoubleQuoteEscapeSequence(out, codePoint); + } else if (codePoint == 0xFEFF) { // Byte order marks (ZWNS) should be + // escaped (YAML 1.2, sec. 5.2) + WriteDoubleQuoteEscapeSequence(out, codePoint); + } else if (escapeNonAscii && codePoint > 0x7E) { + WriteDoubleQuoteEscapeSequence(out, codePoint); + } else { + WriteCodePoint(out, codePoint); + } + } + } + out << "\""; + return true; +} + +bool WriteLiteralString(ostream_wrapper& out, const std::string& str, + std::size_t indent) { + out << "|\n"; + out << IndentTo(indent); + int codePoint; + for (std::string::const_iterator i = str.begin(); + GetNextCodePointAndAdvance(codePoint, i, str.end());) { + if (codePoint == '\n') { + out << "\n" << IndentTo(indent); + } else { + WriteCodePoint(out, codePoint); + } + } + return true; +} + +bool WriteChar(ostream_wrapper& out, char ch) { + if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) { + out << ch; + } else if (ch == '\"') { + out << "\"\\\"\""; + } else if (ch == '\t') { + out << "\"\\t\""; + } else if (ch == '\n') { + out << "\"\\n\""; + } else if (ch == '\b') { + out << "\"\\b\""; + } else if (ch == '\\') { + out << "\"\\\\\""; + } else if ((0x20 <= ch && ch <= 0x7e) || ch == ' ') { + out << "\"" << ch << "\""; + } else { + out << "\""; + WriteDoubleQuoteEscapeSequence(out, ch); + out << "\""; + } + return true; +} + +bool WriteComment(ostream_wrapper& out, const std::string& str, + std::size_t postCommentIndent) { + const std::size_t curIndent = out.col(); + out << "#" << Indentation(postCommentIndent); + out.set_comment(); + int codePoint; + for (std::string::const_iterator i = str.begin(); + GetNextCodePointAndAdvance(codePoint, i, str.end());) { + if (codePoint == '\n') { + out << "\n" << IndentTo(curIndent) << "#" + << Indentation(postCommentIndent); + out.set_comment(); + } else { + WriteCodePoint(out, codePoint); + } + } + return true; +} + +bool WriteAlias(ostream_wrapper& out, const std::string& str) { + out << "*"; + return WriteAliasName(out, str); +} + +bool WriteAnchor(ostream_wrapper& out, const std::string& str) { + out << "&"; + return WriteAliasName(out, str); +} + +bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim) { + out << (verbatim ? "!<" : "!"); + StringCharSource buffer(str.c_str(), str.size()); + const RegEx& reValid = verbatim ? Exp::URI() : Exp::Tag(); + while (buffer) { + int n = reValid.Match(buffer); + if (n <= 0) { + return false; + } + + while (--n >= 0) { + out << buffer[0]; + ++buffer; + } + } + if (verbatim) { + out << ">"; + } + return true; +} + +bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, + const std::string& tag) { + out << "!"; + StringCharSource prefixBuffer(prefix.c_str(), prefix.size()); + while (prefixBuffer) { + int n = Exp::URI().Match(prefixBuffer); + if (n <= 0) { + return false; + } + + while (--n >= 0) { + out << prefixBuffer[0]; + ++prefixBuffer; + } + } + + out << "!"; + StringCharSource tagBuffer(tag.c_str(), tag.size()); + while (tagBuffer) { + int n = Exp::Tag().Match(tagBuffer); + if (n <= 0) { + return false; + } + + while (--n >= 0) { + out << tagBuffer[0]; + ++tagBuffer; + } + } + return true; +} + +bool WriteBinary(ostream_wrapper& out, const Binary& binary) { + WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()), + false); + return true; +} +} +} diff --git a/src/yamlcpp/emitterutils.h b/src/yamlcpp/emitterutils.h --- a/src/yamlcpp/emitterutils.h +++ b/src/yamlcpp/emitterutils.h @@ -1,32 +1,50 @@ #ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - -#include "yaml-cpp/ostream.h" #include -namespace LHAPDF_YAML -{ - class Binary; - - namespace Utils - { - bool WriteString(ostream& out, const std::string& str, bool inFlow, bool escapeNonAscii); - bool WriteSingleQuotedString(ostream& out, const std::string& str); - bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii); - bool WriteLiteralString(ostream& out, const std::string& str, int indent); - bool WriteChar(ostream& out, char ch); - bool WriteComment(ostream& out, const std::string& str, int postCommentIndent); - bool WriteAlias(ostream& out, const std::string& str); - bool WriteAnchor(ostream& out, const std::string& str); - bool WriteTag(ostream& out, const std::string& str, bool verbatim); - bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag); - bool WriteBinary(ostream& out, const Binary& binary); - } +#include "emitterstate.h" +#include "yaml-cpp/emittermanip.h" +#include "yaml-cpp/ostream_wrapper.h" + +namespace YAML { +class ostream_wrapper; +} // namespace YAML + +namespace YAML { +class Binary; + +struct StringFormat { + enum value { Plain, SingleQuoted, DoubleQuoted, Literal }; +}; + +namespace Utils { +StringFormat::value ComputeStringFormat(const std::string& str, + EMITTER_MANIP strFormat, + FlowType::value flowType, + bool escapeNonAscii); + +bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str); +bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, + bool escapeNonAscii); +bool WriteLiteralString(ostream_wrapper& out, const std::string& str, + std::size_t indent); +bool WriteChar(ostream_wrapper& out, char ch); +bool WriteComment(ostream_wrapper& out, const std::string& str, + std::size_t postCommentIndent); +bool WriteAlias(ostream_wrapper& out, const std::string& str); +bool WriteAnchor(ostream_wrapper& out, const std::string& str); +bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim); +bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, + const std::string& tag); +bool WriteBinary(ostream_wrapper& out, const Binary& binary); +} } -#endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/exceptions.cpp b/src/yamlcpp/exceptions.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/exceptions.cpp @@ -0,0 +1,31 @@ +#include "yaml-cpp/exceptions.h" + +// This is here for compatibility with older versions of Visual Studio +// which don't support noexcept +#ifdef _MSC_VER + #define YAML_CPP_NOEXCEPT _NOEXCEPT +#else + #define YAML_CPP_NOEXCEPT noexcept +#endif + +namespace YAML { + +// These destructors are defined out-of-line so the vtable is only emitted once. +Exception::~Exception() YAML_CPP_NOEXCEPT {} +ParserException::~ParserException() YAML_CPP_NOEXCEPT {} +RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT {} +InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT {} +KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT {} +InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT {} +BadConversion::~BadConversion() YAML_CPP_NOEXCEPT {} +BadDereference::~BadDereference() YAML_CPP_NOEXCEPT {} +BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT {} +BadPushback::~BadPushback() YAML_CPP_NOEXCEPT {} +BadInsert::~BadInsert() YAML_CPP_NOEXCEPT {} +EmitterException::~EmitterException() YAML_CPP_NOEXCEPT {} +BadFile::~BadFile() YAML_CPP_NOEXCEPT {} +} + +#undef YAML_CPP_NOEXCEPT + + diff --git a/src/yamlcpp/exp.cpp b/src/yamlcpp/exp.cpp --- a/src/yamlcpp/exp.cpp +++ b/src/yamlcpp/exp.cpp @@ -1,113 +1,136 @@ -#include "exp.h" -#include "yaml-cpp/exceptions.h" #include -namespace LHAPDF_YAML -{ - namespace Exp - { - unsigned ParseHex(const std::string& str, const Mark& mark) - { - unsigned value = 0; - for(std::size_t i=0;i(ch)); - } + value = (value << 4) + digit; + } - // Escape - // . Translates the next 'codeLength' characters into a hex number and returns the result. - // . Throws if it's not actually hex. - std::string Escape(Stream& in, int codeLength) - { - // grab string - std::string str; - for(int i=0;i(ch)); } - // legal unicode? - if((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) { - std::stringstream msg; - msg << ErrorMsg::INVALID_UNICODE << value; - throw ParserException(in.mark(), msg.str()); - } +// Escape +// . Translates the next 'codeLength' characters into a hex number and returns +// the result. +// . Throws if it's not actually hex. +std::string Escape(Stream& in, int codeLength) { + // grab string + std::string str; + for (int i = 0; i < codeLength; i++) + str += in.get(); - // now break it up into chars - if(value <= 0x7F) - return Str(value); - else if(value <= 0x7FF) - return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F)); - else if(value <= 0xFFFF) - return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); - else - return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) + - Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); - } + // get the value + unsigned value = ParseHex(str, in.mark()); - // Escape - // . Escapes the sequence starting 'in' (it must begin with a '\' or single quote) - // and returns the result. - // . Throws if it's an unknown escape character. - std::string Escape(Stream& in) - { - // eat slash - char escape = in.get(); + // legal unicode? + if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) { + std::stringstream msg; + msg << ErrorMsg::INVALID_UNICODE << value; + throw ParserException(in.mark(), msg.str()); + } - // switch on escape character - char ch = in.get(); + // now break it up into chars + if (value <= 0x7F) + return Str(value); + else if (value <= 0x7FF) + return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F)); + else if (value <= 0xFFFF) + return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + + Str(0x80 + (value & 0x3F)); + else + return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) + + Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); +} - // first do single quote, since it's easier - if(escape == '\'' && ch == '\'') - return "\'"; +// Escape +// . Escapes the sequence starting 'in' (it must begin with a '\' or single +// quote) +// and returns the result. +// . Throws if it's an unknown escape character. +std::string Escape(Stream& in) { + // eat slash + char escape = in.get(); - // now do the slash (we're not gonna check if it's a slash - you better pass one!) - switch(ch) { - case '0': return std::string(1, '\x00'); - case 'a': return "\x07"; - case 'b': return "\x08"; - case 't': - case '\t': return "\x09"; - case 'n': return "\x0A"; - case 'v': return "\x0B"; - case 'f': return "\x0C"; - case 'r': return "\x0D"; - case 'e': return "\x1B"; - case ' ': return "\x20"; - case '\"': return "\""; - case '\'': return "\'"; - case '\\': return "\\"; - case '/': return "/"; - case 'N': return "\x85"; - case '_': return "\xA0"; - case 'L': return "\xE2\x80\xA8"; // LS (#x2028) - case 'P': return "\xE2\x80\xA9"; // PS (#x2029) - case 'x': return Escape(in, 2); - case 'u': return Escape(in, 4); - case 'U': return Escape(in, 8); - } + // switch on escape character + char ch = in.get(); - std::stringstream msg; - throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch); - } - } + // first do single quote, since it's easier + if (escape == '\'' && ch == '\'') + return "\'"; + + // now do the slash (we're not gonna check if it's a slash - you better pass + // one!) + switch (ch) { + case '0': + return std::string(1, '\x00'); + case 'a': + return "\x07"; + case 'b': + return "\x08"; + case 't': + case '\t': + return "\x09"; + case 'n': + return "\x0A"; + case 'v': + return "\x0B"; + case 'f': + return "\x0C"; + case 'r': + return "\x0D"; + case 'e': + return "\x1B"; + case ' ': + return "\x20"; + case '\"': + return "\""; + case '\'': + return "\'"; + case '\\': + return "\\"; + case '/': + return "/"; + case 'N': + return "\x85"; + case '_': + return "\xA0"; + case 'L': + return "\xE2\x80\xA8"; // LS (#x2028) + case 'P': + return "\xE2\x80\xA9"; // PS (#x2029) + case 'x': + return Escape(in, 2); + case 'u': + return Escape(in, 4); + case 'U': + return Escape(in, 8); + } + + std::stringstream msg; + throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch); } +} +} diff --git a/src/yamlcpp/exp.h b/src/yamlcpp/exp.h --- a/src/yamlcpp/exp.h +++ b/src/yamlcpp/exp.h @@ -1,196 +1,222 @@ #ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include +#include -#include "regex.h" -#include -#include +#include "regex_yaml.h" #include "stream.h" -namespace LHAPDF_YAML -{ - //////////////////////////////////////////////////////////////////////////////// - // Here we store a bunch of expressions for matching different parts of the file. +namespace YAML { +//////////////////////////////////////////////////////////////////////////////// +// Here we store a bunch of expressions for matching different parts of the +// file. - namespace Exp - { - // misc - inline const RegEx& Space() { - static const RegEx e = RegEx(' '); - return e; - } - inline const RegEx& Tab() { - static const RegEx e = RegEx('\t'); - return e; - } - inline const RegEx& Blank() { - static const RegEx e = Space() || Tab(); - return e; - } - inline const RegEx& Break() { - static const RegEx e = RegEx('\n') || RegEx("\r\n"); - return e; - } - inline const RegEx& BlankOrBreak() { - static const RegEx e = Blank() || Break(); - return e; - } - inline const RegEx& Digit() { - static const RegEx e = RegEx('0', '9'); - return e; - } - inline const RegEx& Alpha() { - static const RegEx e = RegEx('a', 'z') || RegEx('A', 'Z'); - return e; - } - inline const RegEx& AlphaNumeric() { - static const RegEx e = Alpha() || Digit(); - return e; - } - inline const RegEx& Word() { - static const RegEx e = AlphaNumeric() || RegEx('-'); - return e; - } - inline const RegEx& Hex() { - static const RegEx e = Digit() || RegEx('A', 'F') || RegEx('a', 'f'); - return e; - } - // Valid Unicode code points that are not part of c-printable (YAML 1.2, sec. 5.1) - inline const RegEx& NotPrintable() { - static const RegEx e = RegEx(0) || - RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x7F", REGEX_OR) || - RegEx(0x0E, 0x1F) || - (RegEx('\xC2') + (RegEx('\x80', '\x84') || RegEx('\x86', '\x9F'))); - return e; - } - inline const RegEx& Utf8_ByteOrderMark() { - static const RegEx e = RegEx("\xEF\xBB\xBF"); - return e; - } - - // actual tags - - inline const RegEx& DocStart() { - static const RegEx e = RegEx("---") + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& DocEnd() { - static const RegEx e = RegEx("...") + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& DocIndicator() { - static const RegEx e = DocStart() || DocEnd(); - return e; - } - inline const RegEx& BlockEntry() { - static const RegEx e = RegEx('-') + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& Key() { - static const RegEx e = RegEx('?'); - return e; - } - inline const RegEx& KeyInFlow() { - static const RegEx e = RegEx('?') + BlankOrBreak(); - return e; - } - inline const RegEx& Value() { - static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& ValueInFlow() { - static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx(",}", REGEX_OR)); - return e; - } - inline const RegEx& ValueInJSONFlow() { - static const RegEx e = RegEx(':'); - return e; - } - inline const RegEx Comment() { - static const RegEx e = RegEx('#'); - return e; - } - inline const RegEx& Anchor() { - static const RegEx e = !(RegEx("[]{},", REGEX_OR) || BlankOrBreak()); - return e; - } - inline const RegEx& AnchorEnd() { - static const RegEx e = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak(); - return e; - } - inline const RegEx& URI() { - static const RegEx e = Word() || RegEx("#;/?:@&=+$,_.!~*'()[]", REGEX_OR) || (RegEx('%') + Hex() + Hex()); - return e; - } - inline const RegEx& Tag() { - static const RegEx e = Word() || RegEx("#;/?:@&=+$_.~*'", REGEX_OR) || (RegEx('%') + Hex() + Hex()); - return e; - } - - // Plain scalar rules: - // . Cannot start with a blank. - // . Can never start with any of , [ ] { } # & * ! | > \' \" % @ ` - // . In the block context - ? : must be not be followed with a space. - // . In the flow context ? is illegal and : and - must not be followed with a space. - inline const RegEx& PlainScalar() { - static const RegEx e = !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + (BlankOrBreak() || RegEx()))); - return e; - } - inline const RegEx& PlainScalarInFlow() { - static const RegEx e = !(BlankOrBreak() || RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-:", REGEX_OR) + Blank())); - return e; - } - inline const RegEx& EndScalar() { - static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx()); - return e; - } - inline const RegEx& EndScalarInFlow() { - static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR); - return e; - } - - inline const RegEx& EscSingleQuote() { - static const RegEx e = RegEx("\'\'"); - return e; - } - inline const RegEx& EscBreak() { - static const RegEx e = RegEx('\\') + Break(); - return e; - } - - inline const RegEx& ChompIndicator() { - static const RegEx e = RegEx("+-", REGEX_OR); - return e; - } - inline const RegEx& Chomp() { - static const RegEx e = (ChompIndicator() + Digit()) || (Digit() + ChompIndicator()) || ChompIndicator() || Digit(); - return e; - } - - // and some functions - std::string Escape(Stream& in); - } - - namespace Keys - { - const char Directive = '%'; - const char FlowSeqStart = '['; - const char FlowSeqEnd = ']'; - const char FlowMapStart = '{'; - const char FlowMapEnd = '}'; - const char FlowEntry = ','; - const char Alias = '*'; - const char Anchor = '&'; - const char Tag = '!'; - const char LiteralScalar = '|'; - const char FoldedScalar = '>'; - const char VerbatimTagStart = '<'; - const char VerbatimTagEnd = '>'; - } +namespace Exp { +// misc +inline const RegEx& Empty() { + static const RegEx e; + return e; +} +inline const RegEx& Space() { + static const RegEx e = RegEx(' '); + return e; +} +inline const RegEx& Tab() { + static const RegEx e = RegEx('\t'); + return e; +} +inline const RegEx& Blank() { + static const RegEx e = Space() || Tab(); + return e; +} +inline const RegEx& Break() { + static const RegEx e = RegEx('\n') || RegEx("\r\n"); + return e; +} +inline const RegEx& BlankOrBreak() { + static const RegEx e = Blank() || Break(); + return e; +} +inline const RegEx& Digit() { + static const RegEx e = RegEx('0', '9'); + return e; +} +inline const RegEx& Alpha() { + static const RegEx e = RegEx('a', 'z') || RegEx('A', 'Z'); + return e; +} +inline const RegEx& AlphaNumeric() { + static const RegEx e = Alpha() || Digit(); + return e; +} +inline const RegEx& Word() { + static const RegEx e = AlphaNumeric() || RegEx('-'); + return e; +} +inline const RegEx& Hex() { + static const RegEx e = Digit() || RegEx('A', 'F') || RegEx('a', 'f'); + return e; +} +// Valid Unicode code points that are not part of c-printable (YAML 1.2, sec. +// 5.1) +inline const RegEx& NotPrintable() { + static const RegEx e = + RegEx(0) || + RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x7F", REGEX_OR) || + RegEx(0x0E, 0x1F) || + (RegEx('\xC2') + (RegEx('\x80', '\x84') || RegEx('\x86', '\x9F'))); + return e; +} +inline const RegEx& Utf8_ByteOrderMark() { + static const RegEx e = RegEx("\xEF\xBB\xBF"); + return e; } -#endif // EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +// actual tags + +inline const RegEx& DocStart() { + static const RegEx e = RegEx("---") + (BlankOrBreak() || RegEx()); + return e; +} +inline const RegEx& DocEnd() { + static const RegEx e = RegEx("...") + (BlankOrBreak() || RegEx()); + return e; +} +inline const RegEx& DocIndicator() { + static const RegEx e = DocStart() || DocEnd(); + return e; +} +inline const RegEx& BlockEntry() { + static const RegEx e = RegEx('-') + (BlankOrBreak() || RegEx()); + return e; +} +inline const RegEx& Key() { + static const RegEx e = RegEx('?') + BlankOrBreak(); + return e; +} +inline const RegEx& KeyInFlow() { + static const RegEx e = RegEx('?') + BlankOrBreak(); + return e; +} +inline const RegEx& Value() { + static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx()); + return e; +} +inline const RegEx& ValueInFlow() { + static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx(",}", REGEX_OR)); + return e; +} +inline const RegEx& ValueInJSONFlow() { + static const RegEx e = RegEx(':'); + return e; +} +inline const RegEx Comment() { + static const RegEx e = RegEx('#'); + return e; +} +inline const RegEx& Anchor() { + static const RegEx e = !(RegEx("[]{},", REGEX_OR) || BlankOrBreak()); + return e; +} +inline const RegEx& AnchorEnd() { + static const RegEx e = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak(); + return e; +} +inline const RegEx& URI() { + static const RegEx e = Word() || RegEx("#;/?:@&=+$,_.!~*'()[]", REGEX_OR) || + (RegEx('%') + Hex() + Hex()); + return e; +} +inline const RegEx& Tag() { + static const RegEx e = Word() || RegEx("#;/?:@&=+$_.~*'()", REGEX_OR) || + (RegEx('%') + Hex() + Hex()); + return e; +} + +// Plain scalar rules: +// . Cannot start with a blank. +// . Can never start with any of , [ ] { } # & * ! | > \' \" % @ ` +// . In the block context - ? : must be not be followed with a space. +// . In the flow context ? is illegal and : and - must not be followed with a +// space. +inline const RegEx& PlainScalar() { + static const RegEx e = + !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || + (RegEx("-?:", REGEX_OR) + (BlankOrBreak() || RegEx()))); + return e; +} +inline const RegEx& PlainScalarInFlow() { + static const RegEx e = + !(BlankOrBreak() || RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) || + (RegEx("-:", REGEX_OR) + Blank())); + return e; +} +inline const RegEx& EndScalar() { + static const RegEx e = RegEx(':') + (BlankOrBreak() || RegEx()); + return e; +} +inline const RegEx& EndScalarInFlow() { + static const RegEx e = + (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR))) || + RegEx(",?[]{}", REGEX_OR); + return e; +} + +inline const RegEx& ScanScalarEndInFlow() { + static const RegEx e = (EndScalarInFlow() || (BlankOrBreak() + Comment())); + return e; +} + +inline const RegEx& ScanScalarEnd() { + static const RegEx e = EndScalar() || (BlankOrBreak() + Comment()); + return e; +} +inline const RegEx& EscSingleQuote() { + static const RegEx e = RegEx("\'\'"); + return e; +} +inline const RegEx& EscBreak() { + static const RegEx e = RegEx('\\') + Break(); + return e; +} + +inline const RegEx& ChompIndicator() { + static const RegEx e = RegEx("+-", REGEX_OR); + return e; +} +inline const RegEx& Chomp() { + static const RegEx e = (ChompIndicator() + Digit()) || + (Digit() + ChompIndicator()) || ChompIndicator() || + Digit(); + return e; +} + +// and some functions +std::string Escape(Stream& in); +} // namespace Exp + +namespace Keys { +const char Directive = '%'; +const char FlowSeqStart = '['; +const char FlowSeqEnd = ']'; +const char FlowMapStart = '{'; +const char FlowMapEnd = '}'; +const char FlowEntry = ','; +const char Alias = '*'; +const char Anchor = '&'; +const char Tag = '!'; +const char LiteralScalar = '|'; +const char FoldedScalar = '>'; +const char VerbatimTagStart = '<'; +const char VerbatimTagEnd = '>'; +} // namespace Keys +} // namespace YAML + +#endif // EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/indentation.h b/src/yamlcpp/indentation.h --- a/src/yamlcpp/indentation.h +++ b/src/yamlcpp/indentation.h @@ -1,38 +1,41 @@ #ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include +#include -#include "yaml-cpp/ostream.h" -#include +#include "yaml-cpp/ostream_wrapper.h" -namespace LHAPDF_YAML -{ - struct Indentation { - Indentation(unsigned n_): n(n_) {} - unsigned n; - }; - - inline ostream& operator << (ostream& out, const Indentation& indent) { - for(unsigned i=0;i pData): m_pData(std::move(pData)) - { - } - - Iterator::Iterator(const Iterator& rhs): m_pData(new IterPriv(*rhs.m_pData)) - { - } - - Iterator& Iterator::operator = (const Iterator& rhs) - { - if(this == &rhs) - return *this; - - m_pData.reset(new IterPriv(*rhs.m_pData)); - return *this; - } - - Iterator::~Iterator() - { - } - - Iterator& Iterator::operator ++ () - { - if(m_pData->type == IterPriv::IT_SEQ) - ++m_pData->seqIter; - else if(m_pData->type == IterPriv::IT_MAP) - ++m_pData->mapIter; - - return *this; - } - - Iterator Iterator::operator ++ (int) - { - Iterator temp = *this; - - if(m_pData->type == IterPriv::IT_SEQ) - ++m_pData->seqIter; - else if(m_pData->type == IterPriv::IT_MAP) - ++m_pData->mapIter; - - return temp; - } - - const Node& Iterator::operator * () const - { - if(m_pData->type == IterPriv::IT_SEQ) - return **m_pData->seqIter; - - throw BadDereference(); - } - - const Node *Iterator::operator -> () const - { - if(m_pData->type == IterPriv::IT_SEQ) - return *m_pData->seqIter; - - throw BadDereference(); - } - - const Node& Iterator::first() const - { - if(m_pData->type == IterPriv::IT_MAP) - return *m_pData->mapIter->first; - - throw BadDereference(); - } - - const Node& Iterator::second() const - { - if(m_pData->type == IterPriv::IT_MAP) - return *m_pData->mapIter->second; - - throw BadDereference(); - } - - bool operator == (const Iterator& it, const Iterator& jt) - { - if(it.m_pData->type != jt.m_pData->type) - return false; - - if(it.m_pData->type == IterPriv::IT_SEQ) - return it.m_pData->seqIter == jt.m_pData->seqIter; - else if(it.m_pData->type == IterPriv::IT_MAP) - return it.m_pData->mapIter == jt.m_pData->mapIter; - - return true; - } - - bool operator != (const Iterator& it, const Iterator& jt) - { - return !(it == jt); - } -} diff --git a/src/yamlcpp/iterpriv.h b/src/yamlcpp/iterpriv.h deleted file mode 100644 --- a/src/yamlcpp/iterpriv.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp/ltnode.h" -#include -#include - -namespace LHAPDF_YAML -{ - class Node; - - // IterPriv - // . The implementation for iterators - essentially a union of sequence and map iterators. - struct IterPriv - { - IterPriv(): type(IT_NONE) {} - IterPriv(std::vector ::const_iterator it): type(IT_SEQ), seqIter(it) {} - IterPriv(std::map ::const_iterator it): type(IT_MAP), mapIter(it) {} - - enum ITER_TYPE { IT_NONE, IT_SEQ, IT_MAP }; - ITER_TYPE type; - - std::vector ::const_iterator seqIter; - std::map ::const_iterator mapIter; - }; -} - -#endif // ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/memory.cpp b/src/yamlcpp/memory.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/memory.cpp @@ -0,0 +1,26 @@ +#include "yaml-cpp/node/detail/memory.h" +#include "yaml-cpp/node/detail/node.h" // IWYU pragma: keep +#include "yaml-cpp/node/ptr.h" + +namespace YAML { +namespace detail { + +void memory_holder::merge(memory_holder& rhs) { + if (m_pMemory == rhs.m_pMemory) + return; + + m_pMemory->merge(*rhs.m_pMemory); + rhs.m_pMemory = m_pMemory; +} + +node& memory::create_node() { + shared_node pNode(new node); + m_nodes.insert(pNode); + return *pNode; +} + +void memory::merge(const memory& rhs) { + m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end()); +} +} +} diff --git a/src/yamlcpp/node.cpp b/src/yamlcpp/node.cpp --- a/src/yamlcpp/node.cpp +++ b/src/yamlcpp/node.cpp @@ -1,269 +1,12 @@ -#include "yaml-cpp/node.h" -#include "yaml-cpp/aliasmanager.h" -#include "yaml-cpp/emitfromevents.h" -#include "yaml-cpp/emitter.h" -#include "yaml-cpp/eventhandler.h" -#include "iterpriv.h" +#include "yaml-cpp/node/node.h" #include "nodebuilder.h" -#include "nodeownership.h" -#include "scanner.h" -#include "tag.h" -#include "token.h" -#include -#include +#include "nodeevents.h" -namespace LHAPDF_YAML -{ - bool ltnode::operator()(const Node *pNode1, const Node *pNode2) const { - return *pNode1 < *pNode2; - } - - Node::Node(): m_pOwnership(new NodeOwnership), m_type(NodeType::Null) - { - } - - Node::Node(NodeOwnership& owner): m_pOwnership(new NodeOwnership(&owner)), m_type(NodeType::Null) - { - } - - Node::~Node() - { - Clear(); - } - - void Node::Clear() - { - m_pOwnership.reset(new NodeOwnership); - m_type = NodeType::Null; - m_tag.clear(); - m_scalarData.clear(); - m_seqData.clear(); - m_mapData.clear(); - } - - bool Node::IsAliased() const - { - return m_pOwnership->IsAliased(*this); - } - - Node& Node::CreateNode() - { - return m_pOwnership->Create(); - } - - std::unique_ptr Node::Clone() const - { - std::unique_ptr pNode(new Node); - NodeBuilder nodeBuilder(*pNode); - EmitEvents(nodeBuilder); - return pNode; - } - - void Node::EmitEvents(EventHandler& eventHandler) const - { - eventHandler.OnDocumentStart(m_mark); - AliasManager am; - EmitEvents(am, eventHandler); - eventHandler.OnDocumentEnd(); - } - - void Node::EmitEvents(AliasManager& am, EventHandler& eventHandler) const - { - anchor_t anchor = NullAnchor; - if(IsAliased()) { - anchor = am.LookupAnchor(*this); - if(anchor) { - eventHandler.OnAlias(m_mark, anchor); - return; - } - - am.RegisterReference(*this); - anchor = am.LookupAnchor(*this); - } - - switch(m_type) { - case NodeType::Null: - eventHandler.OnNull(m_mark, anchor); - break; - case NodeType::Scalar: - eventHandler.OnScalar(m_mark, m_tag, anchor, m_scalarData); - break; - case NodeType::Sequence: - eventHandler.OnSequenceStart(m_mark, m_tag, anchor); - for(std::size_t i=0;iEmitEvents(am, eventHandler); - eventHandler.OnSequenceEnd(); - break; - case NodeType::Map: - eventHandler.OnMapStart(m_mark, m_tag, anchor); - for(node_map::const_iterator it=m_mapData.begin();it!=m_mapData.end();++it) { - it->first->EmitEvents(am, eventHandler); - it->second->EmitEvents(am, eventHandler); - } - eventHandler.OnMapEnd(); - break; - } - } - - void Node::Init(NodeType::value type, const Mark& mark, const std::string& tag) - { - Clear(); - m_mark = mark; - m_type = type; - m_tag = tag; - } - - void Node::MarkAsAliased() - { - m_pOwnership->MarkAsAliased(*this); - } - - void Node::SetScalarData(const std::string& data) - { - assert(m_type == NodeType::Scalar); // TODO: throw? - m_scalarData = data; - } - - void Node::Append(Node& node) - { - assert(m_type == NodeType::Sequence); // TODO: throw? - m_seqData.push_back(&node); - } - - void Node::Insert(Node& key, Node& value) - { - assert(m_type == NodeType::Map); // TODO: throw? - m_mapData[&key] = &value; - } - - // begin - // Returns an iterator to the beginning of this (sequence or map). - Iterator Node::begin() const - { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - return Iterator(); - case NodeType::Sequence: - return Iterator(std::unique_ptr(new IterPriv(m_seqData.begin()))); - case NodeType::Map: - return Iterator(std::unique_ptr(new IterPriv(m_mapData.begin()))); - } - - assert(false); - return Iterator(); - } - - // end - // . Returns an iterator to the end of this (sequence or map). - Iterator Node::end() const - { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - return Iterator(); - case NodeType::Sequence: - return Iterator(std::unique_ptr(new IterPriv(m_seqData.end()))); - case NodeType::Map: - return Iterator(std::unique_ptr(new IterPriv(m_mapData.end()))); - } - - assert(false); - return Iterator(); - } - - // size - // . Returns the size of a sequence or map node - // . Otherwise, returns zero. - std::size_t Node::size() const - { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - return 0; - case NodeType::Sequence: - return m_seqData.size(); - case NodeType::Map: - return m_mapData.size(); - } - - assert(false); - return 0; - } - - const Node *Node::FindAtIndex(std::size_t i) const - { - if(m_type == NodeType::Sequence) - return m_seqData[i]; - return 0; - } - - bool Node::GetScalar(std::string& s) const - { - switch(m_type) { - case NodeType::Null: - s = "~"; - return true; - case NodeType::Scalar: - s = m_scalarData; - return true; - case NodeType::Sequence: - case NodeType::Map: - return false; - } - - assert(false); - return false; - } - - Emitter& operator << (Emitter& out, const Node& node) - { - EmitFromEvents emitFromEvents(out); - node.EmitEvents(emitFromEvents); - return out; - } - - int Node::Compare(const Node& rhs) const - { - if(m_type != rhs.m_type) - return rhs.m_type - m_type; - - switch(m_type) { - case NodeType::Null: - return 0; - case NodeType::Scalar: - return m_scalarData.compare(rhs.m_scalarData); - case NodeType::Sequence: - if(m_seqData.size() < rhs.m_seqData.size()) - return 1; - else if(m_seqData.size() > rhs.m_seqData.size()) - return -1; - for(std::size_t i=0;iCompare(*rhs.m_seqData[i])) - return cmp; - return 0; - case NodeType::Map: - if(m_mapData.size() < rhs.m_mapData.size()) - return 1; - else if(m_mapData.size() > rhs.m_mapData.size()) - return -1; - node_map::const_iterator it = m_mapData.begin(); - node_map::const_iterator jt = rhs.m_mapData.begin(); - for(;it!=m_mapData.end() && jt!=rhs.m_mapData.end();it++, jt++) { - if(int cmp = it->first->Compare(*jt->first)) - return cmp; - if(int cmp = it->second->Compare(*jt->second)) - return cmp; - } - return 0; - } - - assert(false); - return 0; - } - - bool operator < (const Node& n1, const Node& n2) - { - return n1.Compare(n2) < 0; - } +namespace YAML { +Node Clone(const Node& node) { + NodeEvents events(node); + NodeBuilder builder; + events.Emit(builder); + return builder.Root(); } +} diff --git a/src/yamlcpp/node_data.cpp b/src/yamlcpp/node_data.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/node_data.cpp @@ -0,0 +1,300 @@ +#include +#include +#include + +#include "yaml-cpp/exceptions.h" +#include "yaml-cpp/node/detail/memory.h" +#include "yaml-cpp/node/detail/node.h" // IWYU pragma: keep +#include "yaml-cpp/node/detail/node_data.h" +#include "yaml-cpp/node/detail/node_iterator.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/type.h" + +namespace YAML { +namespace detail { + +std::string node_data::empty_scalar; + +node_data::node_data() + : m_isDefined(false), + m_mark(Mark::null_mark()), + m_type(NodeType::Null), + m_style(EmitterStyle::Default), + m_seqSize(0) {} + +void node_data::mark_defined() { + if (m_type == NodeType::Undefined) + m_type = NodeType::Null; + m_isDefined = true; +} + +void node_data::set_mark(const Mark& mark) { m_mark = mark; } + +void node_data::set_type(NodeType::value type) { + if (type == NodeType::Undefined) { + m_type = type; + m_isDefined = false; + return; + } + + m_isDefined = true; + if (type == m_type) + return; + + m_type = type; + + switch (m_type) { + case NodeType::Null: + break; + case NodeType::Scalar: + m_scalar.clear(); + break; + case NodeType::Sequence: + reset_sequence(); + break; + case NodeType::Map: + reset_map(); + break; + case NodeType::Undefined: + assert(false); + break; + } +} + +void node_data::set_tag(const std::string& tag) { m_tag = tag; } + +void node_data::set_style(EmitterStyle::value style) { m_style = style; } + +void node_data::set_null() { + m_isDefined = true; + m_type = NodeType::Null; +} + +void node_data::set_scalar(const std::string& scalar) { + m_isDefined = true; + m_type = NodeType::Scalar; + m_scalar = scalar; +} + +// size/iterator +std::size_t node_data::size() const { + if (!m_isDefined) + return 0; + + switch (m_type) { + case NodeType::Sequence: + compute_seq_size(); + return m_seqSize; + case NodeType::Map: + compute_map_size(); + return m_map.size() - m_undefinedPairs.size(); + default: + return 0; + } + return 0; +} + +void node_data::compute_seq_size() const { + while (m_seqSize < m_sequence.size() && m_sequence[m_seqSize]->is_defined()) + m_seqSize++; +} + +void node_data::compute_map_size() const { + kv_pairs::iterator it = m_undefinedPairs.begin(); + while (it != m_undefinedPairs.end()) { + kv_pairs::iterator jt = std::next(it); + if (it->first->is_defined() && it->second->is_defined()) + m_undefinedPairs.erase(it); + it = jt; + } +} + +const_node_iterator node_data::begin() const { + if (!m_isDefined) + return const_node_iterator(); + + switch (m_type) { + case NodeType::Sequence: + return const_node_iterator(m_sequence.begin()); + case NodeType::Map: + return const_node_iterator(m_map.begin(), m_map.end()); + default: + return const_node_iterator(); + } +} + +node_iterator node_data::begin() { + if (!m_isDefined) + return node_iterator(); + + switch (m_type) { + case NodeType::Sequence: + return node_iterator(m_sequence.begin()); + case NodeType::Map: + return node_iterator(m_map.begin(), m_map.end()); + default: + return node_iterator(); + } +} + +const_node_iterator node_data::end() const { + if (!m_isDefined) + return const_node_iterator(); + + switch (m_type) { + case NodeType::Sequence: + return const_node_iterator(m_sequence.end()); + case NodeType::Map: + return const_node_iterator(m_map.end(), m_map.end()); + default: + return const_node_iterator(); + } +} + +node_iterator node_data::end() { + if (!m_isDefined) + return node_iterator(); + + switch (m_type) { + case NodeType::Sequence: + return node_iterator(m_sequence.end()); + case NodeType::Map: + return node_iterator(m_map.end(), m_map.end()); + default: + return node_iterator(); + } +} + +// sequence +void node_data::push_back(node& node, shared_memory_holder /* pMemory */) { + if (m_type == NodeType::Undefined || m_type == NodeType::Null) { + m_type = NodeType::Sequence; + reset_sequence(); + } + + if (m_type != NodeType::Sequence) + throw BadPushback(); + + m_sequence.push_back(&node); +} + +void node_data::insert(node& key, node& value, shared_memory_holder pMemory) { + switch (m_type) { + case NodeType::Map: + break; + case NodeType::Undefined: + case NodeType::Null: + case NodeType::Sequence: + convert_to_map(pMemory); + break; + case NodeType::Scalar: + throw BadSubscript(); + } + + insert_map_pair(key, value); +} + +// indexing +node* node_data::get(node& key, shared_memory_holder /* pMemory */) const { + if (m_type != NodeType::Map) { + return NULL; + } + + for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it->first->is(key)) + return it->second; + } + + return NULL; +} + +node& node_data::get(node& key, shared_memory_holder pMemory) { + switch (m_type) { + case NodeType::Map: + break; + case NodeType::Undefined: + case NodeType::Null: + case NodeType::Sequence: + convert_to_map(pMemory); + break; + case NodeType::Scalar: + throw BadSubscript(); + } + + for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it->first->is(key)) + return *it->second; + } + + node& value = pMemory->create_node(); + insert_map_pair(key, value); + return value; +} + +bool node_data::remove(node& key, shared_memory_holder /* pMemory */) { + if (m_type != NodeType::Map) + return false; + + for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it->first->is(key)) { + m_map.erase(it); + return true; + } + } + + return false; +} + +void node_data::reset_sequence() { + m_sequence.clear(); + m_seqSize = 0; +} + +void node_data::reset_map() { + m_map.clear(); + m_undefinedPairs.clear(); +} + +void node_data::insert_map_pair(node& key, node& value) { + m_map.emplace_back(&key, &value); + + if (!key.is_defined() || !value.is_defined()) + m_undefinedPairs.emplace_back(&key, &value); +} + +void node_data::convert_to_map(shared_memory_holder pMemory) { + switch (m_type) { + case NodeType::Undefined: + case NodeType::Null: + reset_map(); + m_type = NodeType::Map; + break; + case NodeType::Sequence: + convert_sequence_to_map(pMemory); + break; + case NodeType::Map: + break; + case NodeType::Scalar: + assert(false); + break; + } +} + +void node_data::convert_sequence_to_map(shared_memory_holder pMemory) { + assert(m_type == NodeType::Sequence); + + reset_map(); + for (std::size_t i = 0; i < m_sequence.size(); i++) { + std::stringstream stream; + stream << i; + + node& key = pMemory->create_node(); + key.set_scalar(stream.str()); + insert_map_pair(key, *m_sequence[i]); + } + + reset_sequence(); + m_type = NodeType::Map; +} +} +} diff --git a/src/yamlcpp/nodebuilder.cpp b/src/yamlcpp/nodebuilder.cpp --- a/src/yamlcpp/nodebuilder.cpp +++ b/src/yamlcpp/nodebuilder.cpp @@ -1,145 +1,130 @@ -#include "nodebuilder.h" -#include "yaml-cpp/mark.h" -#include "yaml-cpp/node.h" +#include #include -namespace LHAPDF_YAML -{ - NodeBuilder::NodeBuilder(Node& root): m_root(root), m_initializedRoot(false), m_finished(false) - { - m_root.Clear(); - m_anchors.push_back(0); // since the anchors start at 1 - } - - NodeBuilder::~NodeBuilder() - { - } +#include "nodebuilder.h" +#include "yaml-cpp/node/detail/node.h" +#include "yaml-cpp/node/impl.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/type.h" - void NodeBuilder::OnDocumentStart(const Mark&) - { - } +namespace YAML { +struct Mark; - void NodeBuilder::OnDocumentEnd() - { - assert(m_finished); - } +NodeBuilder::NodeBuilder() + : m_pMemory(new detail::memory_holder), m_pRoot(0), m_mapDepth(0) { + m_anchors.push_back(0); // since the anchors start at 1 +} - void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor) - { - Node& node = Push(anchor); - node.Init(NodeType::Null, mark, ""); - Pop(); - } +NodeBuilder::~NodeBuilder() {} - void NodeBuilder::OnAlias(const Mark& /*mark*/, anchor_t anchor) - { - Node& node = *m_anchors[anchor]; - Insert(node); - node.MarkAsAliased(); - } +Node NodeBuilder::Root() { + if (!m_pRoot) + return Node(); - void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value) - { - Node& node = Push(anchor); - node.Init(NodeType::Scalar, mark, tag); - node.SetScalarData(value); - Pop(); - } + return Node(*m_pRoot, m_pMemory); +} - void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor) - { - Node& node = Push(anchor); - node.Init(NodeType::Sequence, mark, tag); - } +void NodeBuilder::OnDocumentStart(const Mark&) {} - void NodeBuilder::OnSequenceEnd() - { - Pop(); - } +void NodeBuilder::OnDocumentEnd() {} - void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor) - { - Node& node = Push(anchor); - node.Init(NodeType::Map, mark, tag); - m_didPushKey.push(false); - } +void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor) { + detail::node& node = Push(mark, anchor); + node.set_null(); + Pop(); +} - void NodeBuilder::OnMapEnd() - { - m_didPushKey.pop(); - Pop(); - } - - Node& NodeBuilder::Push(anchor_t anchor) - { - Node& node = Push(); - RegisterAnchor(anchor, node); - return node; - } - - Node& NodeBuilder::Push() - { - if(!m_initializedRoot) { - m_initializedRoot = true; - return m_root; - } - - Node& node = m_root.CreateNode(); - m_stack.push(&node); - return node; - } - - Node& NodeBuilder::Top() - { - return m_stack.empty() ? m_root : *m_stack.top(); - } - - void NodeBuilder::Pop() - { - assert(!m_finished); - if(m_stack.empty()) { - m_finished = true; - return; - } - - Node& node = *m_stack.top(); - m_stack.pop(); - Insert(node); - } - - void NodeBuilder::Insert(Node& node) - { - Node& curTop = Top(); - switch(curTop.Type()) { - case NodeType::Null: - case NodeType::Scalar: - assert(false); - break; - case NodeType::Sequence: - curTop.Append(node); - break; - case NodeType::Map: - assert(!m_didPushKey.empty()); - if(m_didPushKey.top()) { - assert(!m_pendingKeys.empty()); +void NodeBuilder::OnAlias(const Mark& /* mark */, anchor_t anchor) { + detail::node& node = *m_anchors[anchor]; + Push(node); + Pop(); +} - Node& key = *m_pendingKeys.top(); - m_pendingKeys.pop(); - curTop.Insert(key, node); - m_didPushKey.top() = false; - } else { - m_pendingKeys.push(&node); - m_didPushKey.top() = true; - } - break; - } - } +void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, + anchor_t anchor, const std::string& value) { + detail::node& node = Push(mark, anchor); + node.set_scalar(value); + node.set_tag(tag); + Pop(); +} - void NodeBuilder::RegisterAnchor(anchor_t anchor, Node& node) - { - if(anchor) { - assert(anchor == m_anchors.size()); - m_anchors.push_back(&node); - } - } +void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style) { + detail::node& node = Push(mark, anchor); + node.set_tag(tag); + node.set_type(NodeType::Sequence); + node.set_style(style); } + +void NodeBuilder::OnSequenceEnd() { Pop(); } + +void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style) { + detail::node& node = Push(mark, anchor); + node.set_type(NodeType::Map); + node.set_tag(tag); + node.set_style(style); + m_mapDepth++; +} + +void NodeBuilder::OnMapEnd() { + assert(m_mapDepth > 0); + m_mapDepth--; + Pop(); +} + +detail::node& NodeBuilder::Push(const Mark& mark, anchor_t anchor) { + detail::node& node = m_pMemory->create_node(); + node.set_mark(mark); + RegisterAnchor(anchor, node); + Push(node); + return node; +} + +void NodeBuilder::Push(detail::node& node) { + const bool needsKey = + (!m_stack.empty() && m_stack.back()->type() == NodeType::Map && + m_keys.size() < m_mapDepth); + + m_stack.push_back(&node); + if (needsKey) + m_keys.push_back(PushedKey(&node, false)); +} + +void NodeBuilder::Pop() { + assert(!m_stack.empty()); + if (m_stack.size() == 1) { + m_pRoot = m_stack[0]; + m_stack.pop_back(); + return; + } + + detail::node& node = *m_stack.back(); + m_stack.pop_back(); + + detail::node& collection = *m_stack.back(); + + if (collection.type() == NodeType::Sequence) { + collection.push_back(node, m_pMemory); + } else if (collection.type() == NodeType::Map) { + assert(!m_keys.empty()); + PushedKey& key = m_keys.back(); + if (key.second) { + collection.insert(*key.first, node, m_pMemory); + m_keys.pop_back(); + } else { + key.second = true; + } + } else { + assert(false); + m_stack.clear(); + } +} + +void NodeBuilder::RegisterAnchor(anchor_t anchor, detail::node& node) { + if (anchor) { + assert(anchor == m_anchors.size()); + m_anchors.push_back(&node); + } +} +} diff --git a/src/yamlcpp/nodebuilder.h b/src/yamlcpp/nodebuilder.h --- a/src/yamlcpp/nodebuilder.h +++ b/src/yamlcpp/nodebuilder.h @@ -1,61 +1,70 @@ -#ifndef NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#ifndef NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif -#include "yaml-cpp/eventhandler.h" -#include -#include -#include #include -namespace LHAPDF_YAML -{ - class Node; - - class NodeBuilder: public EventHandler - { - public: - explicit NodeBuilder(Node& root); - virtual ~NodeBuilder(); +#include "yaml-cpp/anchor.h" +#include "yaml-cpp/emitterstyle.h" +#include "yaml-cpp/eventhandler.h" +#include "yaml-cpp/node/ptr.h" - virtual void OnDocumentStart(const Mark& mark); - virtual void OnDocumentEnd(); - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnMapEnd(); - - private: - Node& Push(anchor_t anchor); - Node& Push(); - Node& Top(); - void Pop(); +namespace YAML { +namespace detail { +class node; +} // namespace detail +struct Mark; +} // namespace YAML - void Insert(Node& node); - void RegisterAnchor(anchor_t anchor, Node& node); - - private: - Node& m_root; - bool m_initializedRoot; - bool m_finished; - - std::stack m_stack; - std::stack m_pendingKeys; - std::stack m_didPushKey; +namespace YAML { +class Node; - typedef std::vector Anchors; - Anchors m_anchors; - }; +class NodeBuilder : public EventHandler { + public: + NodeBuilder(); + virtual ~NodeBuilder(); + + Node Root(); + + virtual void OnDocumentStart(const Mark& mark); + virtual void OnDocumentEnd(); + + virtual void OnNull(const Mark& mark, anchor_t anchor); + virtual void OnAlias(const Mark& mark, anchor_t anchor); + virtual void OnScalar(const Mark& mark, const std::string& tag, + anchor_t anchor, const std::string& value); + + virtual void OnSequenceStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style); + virtual void OnSequenceEnd(); + + virtual void OnMapStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style); + virtual void OnMapEnd(); + + private: + detail::node& Push(const Mark& mark, anchor_t anchor); + void Push(detail::node& node); + void Pop(); + void RegisterAnchor(anchor_t anchor, detail::node& node); + + private: + detail::shared_memory_holder m_pMemory; + detail::node* m_pRoot; + + typedef std::vector Nodes; + Nodes m_stack; + Nodes m_anchors; + + typedef std::pair PushedKey; + std::vector m_keys; + std::size_t m_mapDepth; +}; } -#endif // NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/nodeevents.cpp b/src/yamlcpp/nodeevents.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/nodeevents.cpp @@ -0,0 +1,101 @@ +#include "nodeevents.h" +#include "yaml-cpp/eventhandler.h" +#include "yaml-cpp/mark.h" +#include "yaml-cpp/node/detail/node.h" +#include "yaml-cpp/node/detail/node_iterator.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/type.h" + +namespace YAML { +void NodeEvents::AliasManager::RegisterReference(const detail::node& node) { + m_anchorByIdentity.insert(std::make_pair(node.ref(), _CreateNewAnchor())); +} + +anchor_t NodeEvents::AliasManager::LookupAnchor( + const detail::node& node) const { + AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(node.ref()); + if (it == m_anchorByIdentity.end()) + return 0; + return it->second; +} + +NodeEvents::NodeEvents(const Node& node) + : m_pMemory(node.m_pMemory), m_root(node.m_pNode) { + if (m_root) + Setup(*m_root); +} + +void NodeEvents::Setup(const detail::node& node) { + int& refCount = m_refCount[node.ref()]; + refCount++; + if (refCount > 1) + return; + + if (node.type() == NodeType::Sequence) { + for (detail::const_node_iterator it = node.begin(); it != node.end(); ++it) + Setup(**it); + } else if (node.type() == NodeType::Map) { + for (detail::const_node_iterator it = node.begin(); it != node.end(); + ++it) { + Setup(*it->first); + Setup(*it->second); + } + } +} + +void NodeEvents::Emit(EventHandler& handler) { + AliasManager am; + + handler.OnDocumentStart(Mark()); + if (m_root) + Emit(*m_root, handler, am); + handler.OnDocumentEnd(); +} + +void NodeEvents::Emit(const detail::node& node, EventHandler& handler, + AliasManager& am) const { + anchor_t anchor = NullAnchor; + if (IsAliased(node)) { + anchor = am.LookupAnchor(node); + if (anchor) { + handler.OnAlias(Mark(), anchor); + return; + } + + am.RegisterReference(node); + anchor = am.LookupAnchor(node); + } + + switch (node.type()) { + case NodeType::Undefined: + break; + case NodeType::Null: + handler.OnNull(Mark(), anchor); + break; + case NodeType::Scalar: + handler.OnScalar(Mark(), node.tag(), anchor, node.scalar()); + break; + case NodeType::Sequence: + handler.OnSequenceStart(Mark(), node.tag(), anchor, node.style()); + for (detail::const_node_iterator it = node.begin(); it != node.end(); + ++it) + Emit(**it, handler, am); + handler.OnSequenceEnd(); + break; + case NodeType::Map: + handler.OnMapStart(Mark(), node.tag(), anchor, node.style()); + for (detail::const_node_iterator it = node.begin(); it != node.end(); + ++it) { + Emit(*it->first, handler, am); + Emit(*it->second, handler, am); + } + handler.OnMapEnd(); + break; + } +} + +bool NodeEvents::IsAliased(const detail::node& node) const { + RefCount::const_iterator it = m_refCount.find(node.ref()); + return it != m_refCount.end() && it->second > 1; +} +} diff --git a/src/yamlcpp/nodeevents.h b/src/yamlcpp/nodeevents.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/nodeevents.h @@ -0,0 +1,64 @@ +#ifndef NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include + +#include "yaml-cpp/anchor.h" +#include "yaml-cpp/node/ptr.h" + +namespace YAML { +namespace detail { +class node; +} // namespace detail +} // namespace YAML + +namespace YAML { +class EventHandler; +class Node; + +class NodeEvents { + public: + explicit NodeEvents(const Node& node); + + void Emit(EventHandler& handler); + + private: + class AliasManager { + public: + AliasManager() : m_curAnchor(0) {} + + void RegisterReference(const detail::node& node); + anchor_t LookupAnchor(const detail::node& node) const; + + private: + anchor_t _CreateNewAnchor() { return ++m_curAnchor; } + + private: + typedef std::map AnchorByIdentity; + AnchorByIdentity m_anchorByIdentity; + + anchor_t m_curAnchor; + }; + + void Setup(const detail::node& node); + void Emit(const detail::node& node, EventHandler& handler, + AliasManager& am) const; + bool IsAliased(const detail::node& node) const; + + private: + detail::shared_memory_holder m_pMemory; + detail::node* m_root; + + typedef std::map RefCount; + RefCount m_refCount; +}; +} + +#endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/nodeownership.cpp b/src/yamlcpp/nodeownership.cpp deleted file mode 100644 --- a/src/yamlcpp/nodeownership.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "nodeownership.h" -#include "yaml-cpp/node.h" - -namespace LHAPDF_YAML -{ - NodeOwnership::NodeOwnership(NodeOwnership *pOwner): m_pOwner(pOwner) - { - if(!m_pOwner) - m_pOwner = this; - } - - NodeOwnership::~NodeOwnership() - { - } - - Node& NodeOwnership::_Create() - { - m_nodes.push_back(std::unique_ptr(new Node)); - return m_nodes.back(); - } - - void NodeOwnership::_MarkAsAliased(const Node& node) - { - m_aliasedNodes.insert(&node); - } - - bool NodeOwnership::_IsAliased(const Node& node) const - { - return m_aliasedNodes.count(&node) > 0; - } -} diff --git a/src/yamlcpp/nodeownership.h b/src/yamlcpp/nodeownership.h deleted file mode 100644 --- a/src/yamlcpp/nodeownership.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp/noncopyable.h" -#include "ptr_vector.h" -#include - -namespace LHAPDF_YAML -{ - class Node; - - class NodeOwnership: private noncopyable - { - public: - explicit NodeOwnership(NodeOwnership *pOwner = 0); - ~NodeOwnership(); - - Node& Create() { return m_pOwner->_Create(); } - void MarkAsAliased(const Node& node) { m_pOwner->_MarkAsAliased(node); } - bool IsAliased(const Node& node) const { return m_pOwner->_IsAliased(node); } - - private: - Node& _Create(); - void _MarkAsAliased(const Node& node); - bool _IsAliased(const Node& node) const; - - private: - ptr_vector m_nodes; - std::set m_aliasedNodes; - NodeOwnership *m_pOwner; - }; -} - -#endif // NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/null.cpp b/src/yamlcpp/null.cpp --- a/src/yamlcpp/null.cpp +++ b/src/yamlcpp/null.cpp @@ -1,12 +1,10 @@ #include "yaml-cpp/null.h" -#include "yaml-cpp/node.h" -namespace LHAPDF_YAML -{ - _Null Null; +namespace YAML { +_Null Null; - bool IsNull(const Node& node) - { - return node.Read(Null); - } +bool IsNullString(const std::string& str) { + return str.empty() || str == "~" || str == "null" || str == "Null" || + str == "NULL"; } +} diff --git a/src/yamlcpp/ostream.cpp b/src/yamlcpp/ostream.cpp deleted file mode 100644 --- a/src/yamlcpp/ostream.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "yaml-cpp/ostream.h" -#include - -namespace LHAPDF_YAML -{ - ostream::ostream(): m_buffer(0), m_pos(0), m_size(0), m_row(0), m_col(0) - { - reserve(1024); - } - - ostream::~ostream() - { - delete [] m_buffer; - } - - void ostream::reserve(unsigned size) - { - if(size <= m_size) - return; - - char *newBuffer = new char[size]; - std::memset(newBuffer, 0, size * sizeof(char)); - std::memcpy(newBuffer, m_buffer, m_size * sizeof(char)); - delete [] m_buffer; - m_buffer = newBuffer; - m_size = size; - } - - void ostream::put(char ch) - { - if(m_pos >= m_size - 1) // an extra space for the NULL terminator - reserve(m_size * 2); - - m_buffer[m_pos] = ch; - m_pos++; - - if(ch == '\n') { - m_row++; - m_col = 0; - } else - m_col++; - } - - ostream& operator << (ostream& out, const char *str) - { - std::size_t length = std::strlen(str); - for(std::size_t i=0;i +#include +#include + +namespace YAML { +ostream_wrapper::ostream_wrapper() + : m_buffer(1, '\0'), + m_pStream(0), + m_pos(0), + m_row(0), + m_col(0), + m_comment(false) {} + +ostream_wrapper::ostream_wrapper(std::ostream& stream) + : m_pStream(&stream), m_pos(0), m_row(0), m_col(0), m_comment(false) {} + +ostream_wrapper::~ostream_wrapper() {} + +void ostream_wrapper::write(const std::string& str) { + if (m_pStream) { + m_pStream->write(str.c_str(), str.size()); + } else { + m_buffer.resize(std::max(m_buffer.size(), m_pos + str.size() + 1)); + std::copy(str.begin(), str.end(), m_buffer.begin() + m_pos); + } + + for (std::size_t i = 0; i < str.size(); i++) { + update_pos(str[i]); + } +} + +void ostream_wrapper::write(const char* str, std::size_t size) { + if (m_pStream) { + m_pStream->write(str, size); + } else { + m_buffer.resize(std::max(m_buffer.size(), m_pos + size + 1)); + std::copy(str, str + size, m_buffer.begin() + m_pos); + } + + for (std::size_t i = 0; i < size; i++) { + update_pos(str[i]); + } +} + +void ostream_wrapper::update_pos(char ch) { + m_pos++; + m_col++; + + if (ch == '\n') { + m_row++; + m_col = 0; + m_comment = false; + } +} +} diff --git a/src/yamlcpp/parse.cpp b/src/yamlcpp/parse.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/parse.cpp @@ -0,0 +1,72 @@ +#include "yaml-cpp/node/parse.h" + +#include +#include + +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/impl.h" +#include "yaml-cpp/parser.h" +#include "nodebuilder.h" + +namespace YAML { +Node Load(const std::string& input) { + std::stringstream stream(input); + return Load(stream); +} + +Node Load(const char* input) { + std::stringstream stream(input); + return Load(stream); +} + +Node Load(std::istream& input) { + Parser parser(input); + NodeBuilder builder; + if (!parser.HandleNextDocument(builder)) { + return Node(); + } + + return builder.Root(); +} + +Node LoadFile(const std::string& filename) { + std::ifstream fin(filename.c_str()); + if (!fin) { + throw BadFile(); + } + return Load(fin); +} + +std::vector LoadAll(const std::string& input) { + std::stringstream stream(input); + return LoadAll(stream); +} + +std::vector LoadAll(const char* input) { + std::stringstream stream(input); + return LoadAll(stream); +} + +std::vector LoadAll(std::istream& input) { + std::vector docs; + + Parser parser(input); + while (1) { + NodeBuilder builder; + if (!parser.HandleNextDocument(builder)) { + break; + } + docs.push_back(builder.Root()); + } + + return docs; +} + +std::vector LoadAllFromFile(const std::string& filename) { + std::ifstream fin(filename.c_str()); + if (!fin) { + throw BadFile(); + } + return LoadAll(fin); +} +} // namespace YAML diff --git a/src/yamlcpp/parser.cpp b/src/yamlcpp/parser.cpp --- a/src/yamlcpp/parser.cpp +++ b/src/yamlcpp/parser.cpp @@ -1,152 +1,129 @@ +#include +#include + +#include "directives.h" // IWYU pragma: keep +#include "scanner.h" // IWYU pragma: keep +#include "singledocparser.h" +#include "token.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep #include "yaml-cpp/parser.h" -#include "yaml-cpp/eventhandler.h" -#include "yaml-cpp/exceptions.h" -#include "yaml-cpp/node.h" -#include "directives.h" -#include "nodebuilder.h" -#include "scanner.h" -#include "singledocparser.h" -#include "tag.h" -#include "token.h" -#include -#include -namespace LHAPDF_YAML -{ - Parser::Parser() - { - } - - Parser::Parser(std::istream& in) - { - Load(in); - } +namespace YAML { +class EventHandler; - Parser::~Parser() - { - } +Parser::Parser() {} - Parser::operator bool() const - { - return m_pScanner.get() && !m_pScanner->empty(); - } +Parser::Parser(std::istream& in) { Load(in); } - void Parser::Load(std::istream& in) - { - m_pScanner.reset(new Scanner(in)); - m_pDirectives.reset(new Directives); - } +Parser::~Parser() {} - // HandleNextDocument - // . Handles the next document - // . Throws a ParserException on error. - // . Returns false if there are no more documents - bool Parser::HandleNextDocument(EventHandler& eventHandler) - { - if(!m_pScanner.get()) - return false; +Parser::operator bool() const { + return m_pScanner.get() && !m_pScanner->empty(); +} - ParseDirectives(); - if(m_pScanner->empty()) - return false; - - SingleDocParser sdp(*m_pScanner, *m_pDirectives); - sdp.HandleDocument(eventHandler); - return true; - } +void Parser::Load(std::istream& in) { + m_pScanner.reset(new Scanner(in)); + m_pDirectives.reset(new Directives); +} - // GetNextDocument - // . Reads the next document in the queue (of tokens). - // . Throws a ParserException on error. - bool Parser::GetNextDocument(Node& document) - { - NodeBuilder builder(document); - return HandleNextDocument(builder); - } +bool Parser::HandleNextDocument(EventHandler& eventHandler) { + if (!m_pScanner.get()) + return false; - // ParseDirectives - // . Reads any directives that are next in the queue. - void Parser::ParseDirectives() - { - bool readDirective = false; + ParseDirectives(); + if (m_pScanner->empty()) { + return false; + } - while(1) { - if(m_pScanner->empty()) - break; + SingleDocParser sdp(*m_pScanner, *m_pDirectives); + sdp.HandleDocument(eventHandler); + return true; +} - Token& token = m_pScanner->peek(); - if(token.type != Token::DIRECTIVE) - break; +void Parser::ParseDirectives() { + bool readDirective = false; - // we keep the directives from the last document if none are specified; - // but if any directives are specific, then we reset them - if(!readDirective) - m_pDirectives.reset(new Directives); + while (1) { + if (m_pScanner->empty()) { + break; + } - readDirective = true; - HandleDirective(token); - m_pScanner->pop(); - } - } + Token& token = m_pScanner->peek(); + if (token.type != Token::DIRECTIVE) { + break; + } - void Parser::HandleDirective(const Token& token) - { - if(token.value == "YAML") - HandleYamlDirective(token); - else if(token.value == "TAG") - HandleTagDirective(token); - } + // we keep the directives from the last document if none are specified; + // but if any directives are specific, then we reset them + if (!readDirective) { + m_pDirectives.reset(new Directives); + } - // HandleYamlDirective - // . Should be of the form 'major.minor' (like a version number) - void Parser::HandleYamlDirective(const Token& token) - { - if(token.params.size() != 1) - throw ParserException(token.mark, ErrorMsg::YAML_DIRECTIVE_ARGS); - - if(!m_pDirectives->version.isDefault) - throw ParserException(token.mark, ErrorMsg::REPEATED_YAML_DIRECTIVE); + readDirective = true; + HandleDirective(token); + m_pScanner->pop(); + } +} - std::stringstream str(token.params[0]); - str >> m_pDirectives->version.major; - str.get(); - str >> m_pDirectives->version.minor; - if(!str || str.peek() != EOF) - throw ParserException(token.mark, std::string(ErrorMsg::YAML_VERSION) + token.params[0]); +void Parser::HandleDirective(const Token& token) { + if (token.value == "YAML") { + HandleYamlDirective(token); + } else if (token.value == "TAG") { + HandleTagDirective(token); + } +} - if(m_pDirectives->version.major > 1) - throw ParserException(token.mark, ErrorMsg::YAML_MAJOR_VERSION); +void Parser::HandleYamlDirective(const Token& token) { + if (token.params.size() != 1) { + throw ParserException(token.mark, ErrorMsg::YAML_DIRECTIVE_ARGS); + } - m_pDirectives->version.isDefault = false; - // TODO: warning on major == 1, minor > 2? - } + if (!m_pDirectives->version.isDefault) { + throw ParserException(token.mark, ErrorMsg::REPEATED_YAML_DIRECTIVE); + } - // HandleTagDirective - // . Should be of the form 'handle prefix', where 'handle' is converted to 'prefix' in the file. - void Parser::HandleTagDirective(const Token& token) - { - if(token.params.size() != 2) - throw ParserException(token.mark, ErrorMsg::TAG_DIRECTIVE_ARGS); + std::stringstream str(token.params[0]); + str >> m_pDirectives->version.major; + str.get(); + str >> m_pDirectives->version.minor; + if (!str || str.peek() != EOF) { + throw ParserException( + token.mark, std::string(ErrorMsg::YAML_VERSION) + token.params[0]); + } - const std::string& handle = token.params[0]; - const std::string& prefix = token.params[1]; - if(m_pDirectives->tags.find(handle) != m_pDirectives->tags.end()) - throw ParserException(token.mark, ErrorMsg::REPEATED_TAG_DIRECTIVE); - - m_pDirectives->tags[handle] = prefix; - } + if (m_pDirectives->version.major > 1) { + throw ParserException(token.mark, ErrorMsg::YAML_MAJOR_VERSION); + } - void Parser::PrintTokens(std::ostream& out) - { - if(!m_pScanner.get()) - return; - - while(1) { - if(m_pScanner->empty()) - break; + m_pDirectives->version.isDefault = false; + // TODO: warning on major == 1, minor > 2? +} - out << m_pScanner->peek() << "\n"; - m_pScanner->pop(); - } - } +void Parser::HandleTagDirective(const Token& token) { + if (token.params.size() != 2) + throw ParserException(token.mark, ErrorMsg::TAG_DIRECTIVE_ARGS); + + const std::string& handle = token.params[0]; + const std::string& prefix = token.params[1]; + if (m_pDirectives->tags.find(handle) != m_pDirectives->tags.end()) { + throw ParserException(token.mark, ErrorMsg::REPEATED_TAG_DIRECTIVE); + } + + m_pDirectives->tags[handle] = prefix; } + +void Parser::PrintTokens(std::ostream& out) { + if (!m_pScanner.get()) { + return; + } + + while (1) { + if (m_pScanner->empty()) { + break; + } + + out << m_pScanner->peek() << "\n"; + m_pScanner->pop(); + } +} +} diff --git a/src/yamlcpp/ptr_stack.h b/src/yamlcpp/ptr_stack.h deleted file mode 100644 --- a/src/yamlcpp/ptr_stack.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/noncopyable.h" -#include -#include -#include -#include - -template -class ptr_stack: private LHAPDF_YAML::noncopyable -{ -public: - ptr_stack() {} - ~ptr_stack() { clear(); } - - void clear() { - for(unsigned i=0;i t) { - m_data.push_back(NULL); - m_data.back() = t.release(); - } - std::unique_ptr pop() { - std::unique_ptr t(m_data.back()); - m_data.pop_back(); - return t; - } - T& top() { return *m_data.back(); } - const T& top() const { return *m_data.back(); } - -private: - std::vector m_data; -}; - -#endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/ptr_vector.h b/src/yamlcpp/ptr_vector.h --- a/src/yamlcpp/ptr_vector.h +++ b/src/yamlcpp/ptr_vector.h @@ -1,47 +1,43 @@ #ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif -#include "yaml-cpp/noncopyable.h" #include #include #include #include -namespace LHAPDF_YAML { +#include "yaml-cpp/noncopyable.h" - template - class ptr_vector: private LHAPDF_YAML::noncopyable - { - public: - ptr_vector() {} - ~ptr_vector() { clear(); } +namespace YAML { - void clear() { - for(unsigned i=0;i +class ptr_vector : private YAML::noncopyable { + public: + ptr_vector() {} - std::size_t size() const { return m_data.size(); } - bool empty() const { return m_data.empty(); } + void clear() { m_data.clear(); } - void push_back(std::unique_ptr t) { - m_data.push_back(NULL); - m_data.back() = t.release(); - } - T& operator[](std::size_t i) { return *m_data[i]; } - const T& operator[](std::size_t i) const { return *m_data[i]; } + std::size_t size() const { return m_data.size(); } + bool empty() const { return m_data.empty(); } - T& back() { return *m_data.back(); } - const T& back() const { return *m_data.back(); } + void push_back(std::unique_ptr&& t) { m_data.push_back(std::move(t)); } + T& operator[](std::size_t i) { return *m_data[i]; } + const T& operator[](std::size_t i) const { return *m_data[i]; } - private: - std::vector m_data; - }; + T& back() { return *(m_data.back().get()); } + + const T& back() const { return *(m_data.back().get()); } + + private: + std::vector> m_data; +}; } -#endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/regex.cpp b/src/yamlcpp/regex.cpp deleted file mode 100644 --- a/src/yamlcpp/regex.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "regex.h" - -namespace LHAPDF_YAML -{ - // constructors - RegEx::RegEx(): m_op(REGEX_EMPTY) - { - } - - RegEx::RegEx(REGEX_OP op): m_op(op) - { - } - - RegEx::RegEx(char ch): m_op(REGEX_MATCH), m_a(ch) - { - } - - RegEx::RegEx(char a, char z): m_op(REGEX_RANGE), m_a(a), m_z(z) - { - } - - RegEx::RegEx(const std::string& str, REGEX_OP op): m_op(op) - { - for(std::size_t i=0;i= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include - -namespace LHAPDF_YAML -{ - class Stream; - - enum REGEX_OP { REGEX_EMPTY, REGEX_MATCH, REGEX_RANGE, REGEX_OR, REGEX_AND, REGEX_NOT, REGEX_SEQ }; - - // simplified regular expressions - // . Only straightforward matches (no repeated characters) - // . Only matches from start of string - class RegEx - { - public: - RegEx(); - RegEx(char ch); - RegEx(char a, char z); - RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); - ~RegEx() {} - - friend RegEx operator ! (const RegEx& ex); - friend RegEx operator || (const RegEx& ex1, const RegEx& ex2); - friend RegEx operator && (const RegEx& ex1, const RegEx& ex2); - friend RegEx operator + (const RegEx& ex1, const RegEx& ex2); - - bool Matches(char ch) const; - bool Matches(const std::string& str) const; - bool Matches(const Stream& in) const; - template bool Matches(const Source& source) const; - - int Match(const std::string& str) const; - int Match(const Stream& in) const; - template int Match(const Source& source) const; - - private: - RegEx(REGEX_OP op); - - template bool IsValidSource(const Source& source) const; - template int MatchUnchecked(const Source& source) const; - - template int MatchOpEmpty(const Source& source) const; - template int MatchOpMatch(const Source& source) const; - template int MatchOpRange(const Source& source) const; - template int MatchOpOr(const Source& source) const; - template int MatchOpAnd(const Source& source) const; - template int MatchOpNot(const Source& source) const; - template int MatchOpSeq(const Source& source) const; - - private: - REGEX_OP m_op; - char m_a, m_z; - std::vector m_params; - }; -} - -#include "regeximpl.h" - -#endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/regex_yaml.cpp b/src/yamlcpp/regex_yaml.cpp new file mode 100644 --- /dev/null +++ b/src/yamlcpp/regex_yaml.cpp @@ -0,0 +1,45 @@ +#include "regex_yaml.h" + +namespace YAML { +// constructors +RegEx::RegEx() : m_op(REGEX_EMPTY) {} + +RegEx::RegEx(REGEX_OP op) : m_op(op) {} + +RegEx::RegEx(char ch) : m_op(REGEX_MATCH), m_a(ch) {} + +RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z) {} + +RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op) { + for (std::size_t i = 0; i < str.size(); i++) + m_params.push_back(RegEx(str[i])); +} + +// combination constructors +RegEx operator!(const RegEx& ex) { + RegEx ret(REGEX_NOT); + ret.m_params.push_back(ex); + return ret; +} + +RegEx operator||(const RegEx& ex1, const RegEx& ex2) { + RegEx ret(REGEX_OR); + ret.m_params.push_back(ex1); + ret.m_params.push_back(ex2); + return ret; +} + +RegEx operator&&(const RegEx& ex1, const RegEx& ex2) { + RegEx ret(REGEX_AND); + ret.m_params.push_back(ex1); + ret.m_params.push_back(ex2); + return ret; +} + +RegEx operator+(const RegEx& ex1, const RegEx& ex2) { + RegEx ret(REGEX_SEQ); + ret.m_params.push_back(ex1); + ret.m_params.push_back(ex2); + return ret; +} +} diff --git a/src/yamlcpp/regex_yaml.h b/src/yamlcpp/regex_yaml.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/regex_yaml.h @@ -0,0 +1,87 @@ +#ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include + +#include "yaml-cpp/dll.h" + +namespace YAML { +class Stream; + +enum REGEX_OP { + REGEX_EMPTY, + REGEX_MATCH, + REGEX_RANGE, + REGEX_OR, + REGEX_AND, + REGEX_NOT, + REGEX_SEQ +}; + +// simplified regular expressions +// . Only straightforward matches (no repeated characters) +// . Only matches from start of string +class YAML_CPP_API RegEx { + public: + RegEx(); + RegEx(char ch); + RegEx(char a, char z); + RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); + ~RegEx() {} + + friend YAML_CPP_API RegEx operator!(const RegEx& ex); + friend YAML_CPP_API RegEx operator||(const RegEx& ex1, const RegEx& ex2); + friend YAML_CPP_API RegEx operator&&(const RegEx& ex1, const RegEx& ex2); + friend YAML_CPP_API RegEx operator+(const RegEx& ex1, const RegEx& ex2); + + bool Matches(char ch) const; + bool Matches(const std::string& str) const; + bool Matches(const Stream& in) const; + template + bool Matches(const Source& source) const; + + int Match(const std::string& str) const; + int Match(const Stream& in) const; + template + int Match(const Source& source) const; + + private: + RegEx(REGEX_OP op); + + template + bool IsValidSource(const Source& source) const; + template + int MatchUnchecked(const Source& source) const; + + template + int MatchOpEmpty(const Source& source) const; + template + int MatchOpMatch(const Source& source) const; + template + int MatchOpRange(const Source& source) const; + template + int MatchOpOr(const Source& source) const; + template + int MatchOpAnd(const Source& source) const; + template + int MatchOpNot(const Source& source) const; + template + int MatchOpSeq(const Source& source) const; + + private: + REGEX_OP m_op; + char m_a, m_z; + std::vector m_params; +}; +} + +#include "regeximpl.h" + +#endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/regeximpl.h b/src/yamlcpp/regeximpl.h --- a/src/yamlcpp/regeximpl.h +++ b/src/yamlcpp/regeximpl.h @@ -1,186 +1,186 @@ #ifndef REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include "stream.h" #include "stringsource.h" #include "streamcharsource.h" -namespace LHAPDF_YAML -{ - // query matches - inline bool RegEx::Matches(char ch) const { - std::string str; - str += ch; - return Matches(str); - } - - inline bool RegEx::Matches(const std::string& str) const { - return Match(str) >= 0; - } - - inline bool RegEx::Matches(const Stream& in) const { - return Match(in) >= 0; - } - - template - inline bool RegEx::Matches(const Source& source) const { - return Match(source) >= 0; - } - - // Match - // . Matches the given string against this regular expression. - // . Returns the number of characters matched. - // . Returns -1 if no characters were matched (the reason for - // not returning zero is that we may have an empty regex - // which is ALWAYS successful at matching zero characters). - // . REMEMBER that we only match from the start of the buffer! - inline int RegEx::Match(const std::string& str) const - { - StringCharSource source(str.c_str(), str.size()); - return Match(source); - } - - inline int RegEx::Match(const Stream& in) const - { - StreamCharSource source(in); - return Match(source); - } - - template - inline bool RegEx::IsValidSource(const Source& source) const - { - return source; - } - - template<> - inline bool RegEx::IsValidSource(const StringCharSource&source) const - { - switch(m_op) { - case REGEX_MATCH: - case REGEX_RANGE: - return source; - default: - return true; - } - } - - template - inline int RegEx::Match(const Source& source) const - { - return IsValidSource(source) ? MatchUnchecked(source) : -1; - } - - template - inline int RegEx::MatchUnchecked(const Source& source) const - { - switch(m_op) { - case REGEX_EMPTY: - return MatchOpEmpty(source); - case REGEX_MATCH: - return MatchOpMatch(source); - case REGEX_RANGE: - return MatchOpRange(source); - case REGEX_OR: - return MatchOpOr(source); - case REGEX_AND: - return MatchOpAnd(source); - case REGEX_NOT: - return MatchOpNot(source); - case REGEX_SEQ: - return MatchOpSeq(source); - } - - return -1; - } - - ////////////////////////////////////////////////////////////////////////////// - // Operators - // Note: the convention MatchOp* is that we can assume IsSourceValid(source). - // So we do all our checks *before* we call these functions - - // EmptyOperator - template - inline int RegEx::MatchOpEmpty(const Source& source) const { - return source[0] == Stream::eof() ? 0 : -1; - } - - template <> - inline int RegEx::MatchOpEmpty(const StringCharSource& source) const { - return !source ? 0 : -1; // the empty regex only is successful on the empty string - } - - // MatchOperator - template - inline int RegEx::MatchOpMatch(const Source& source) const { - if(source[0] != m_a) - return -1; - return 1; - } - - // RangeOperator - template - inline int RegEx::MatchOpRange(const Source& source) const { - if(m_a > source[0] || m_z < source[0]) - return -1; - return 1; - } - - // OrOperator - template - inline int RegEx::MatchOpOr(const Source& source) const { - for(std::size_t i=0;i= 0) - return n; - } - return -1; - } - - // AndOperator - // Note: 'AND' is a little funny, since we may be required to match things - // of different lengths. If we find a match, we return the length of - // the FIRST entry on the list. - template - inline int RegEx::MatchOpAnd(const Source& source) const { - int first = -1; - for(std::size_t i=0;i - inline int RegEx::MatchOpNot(const Source& source) const { - if(m_params.empty()) - return -1; - if(m_params[0].MatchUnchecked(source) >= 0) - return -1; - return 1; - } - - // SeqOperator - template - inline int RegEx::MatchOpSeq(const Source& source) const { - int offset = 0; - for(std::size_t i=0;i= 0; +} + +inline bool RegEx::Matches(const Stream& in) const { return Match(in) >= 0; } + +template +inline bool RegEx::Matches(const Source& source) const { + return Match(source) >= 0; +} + +// Match +// . Matches the given string against this regular expression. +// . Returns the number of characters matched. +// . Returns -1 if no characters were matched (the reason for +// not returning zero is that we may have an empty regex +// which is ALWAYS successful at matching zero characters). +// . REMEMBER that we only match from the start of the buffer! +inline int RegEx::Match(const std::string& str) const { + StringCharSource source(str.c_str(), str.size()); + return Match(source); +} + +inline int RegEx::Match(const Stream& in) const { + StreamCharSource source(in); + return Match(source); +} + +template +inline bool RegEx::IsValidSource(const Source& source) const { + return source; +} + +template <> +inline bool RegEx::IsValidSource( + const StringCharSource& source) const { + switch (m_op) { + case REGEX_MATCH: + case REGEX_RANGE: + return source; + default: + return true; + } +} + +template +inline int RegEx::Match(const Source& source) const { + return IsValidSource(source) ? MatchUnchecked(source) : -1; +} + +template +inline int RegEx::MatchUnchecked(const Source& source) const { + switch (m_op) { + case REGEX_EMPTY: + return MatchOpEmpty(source); + case REGEX_MATCH: + return MatchOpMatch(source); + case REGEX_RANGE: + return MatchOpRange(source); + case REGEX_OR: + return MatchOpOr(source); + case REGEX_AND: + return MatchOpAnd(source); + case REGEX_NOT: + return MatchOpNot(source); + case REGEX_SEQ: + return MatchOpSeq(source); + } + + return -1; +} + +////////////////////////////////////////////////////////////////////////////// +// Operators +// Note: the convention MatchOp* is that we can assume +// IsSourceValid(source). +// So we do all our checks *before* we call these functions + +// EmptyOperator +template +inline int RegEx::MatchOpEmpty(const Source& source) const { + return source[0] == Stream::eof() ? 0 : -1; +} + +template <> +inline int RegEx::MatchOpEmpty( + const StringCharSource& source) const { + return !source + ? 0 + : -1; // the empty regex only is successful on the empty string +} + +// MatchOperator +template +inline int RegEx::MatchOpMatch(const Source& source) const { + if (source[0] != m_a) + return -1; + return 1; +} + +// RangeOperator +template +inline int RegEx::MatchOpRange(const Source& source) const { + if (m_a > source[0] || m_z < source[0]) + return -1; + return 1; +} + +// OrOperator +template +inline int RegEx::MatchOpOr(const Source& source) const { + for (std::size_t i = 0; i < m_params.size(); i++) { + int n = m_params[i].MatchUnchecked(source); + if (n >= 0) + return n; + } + return -1; +} + +// AndOperator +// Note: 'AND' is a little funny, since we may be required to match things +// of different lengths. If we find a match, we return the length of +// the FIRST entry on the list. +template +inline int RegEx::MatchOpAnd(const Source& source) const { + int first = -1; + for (std::size_t i = 0; i < m_params.size(); i++) { + int n = m_params[i].MatchUnchecked(source); + if (n == -1) + return -1; + if (i == 0) + first = n; + } + return first; +} + +// NotOperator +template +inline int RegEx::MatchOpNot(const Source& source) const { + if (m_params.empty()) + return -1; + if (m_params[0].MatchUnchecked(source) >= 0) + return -1; + return 1; +} + +// SeqOperator +template +inline int RegEx::MatchOpSeq(const Source& source) const { + int offset = 0; + for (std::size_t i = 0; i < m_params.size(); i++) { + int n = m_params[i].Match(source + offset); // note Match, not + // MatchUnchecked because we + // need to check validity after + // the offset + if (n == -1) + return -1; + offset += n; + } + + return offset; +} +} + +#endif // REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/scanner.cpp b/src/yamlcpp/scanner.cpp --- a/src/yamlcpp/scanner.cpp +++ b/src/yamlcpp/scanner.cpp @@ -1,386 +1,386 @@ -#include "scanner.h" -#include "token.h" -#include "yaml-cpp/exceptions.h" -#include "exp.h" #include #include -namespace LHAPDF_YAML -{ - Scanner::Scanner(std::istream& in) - : INPUT(in), m_startedStream(false), m_endedStream(false), m_simpleKeyAllowed(false), m_canBeJSONFlow(false) - { - } +#include "exp.h" +#include "scanner.h" +#include "token.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep - Scanner::~Scanner() - { - } +namespace YAML { +Scanner::Scanner(std::istream& in) + : INPUT(in), + m_startedStream(false), + m_endedStream(false), + m_simpleKeyAllowed(false), + m_canBeJSONFlow(false) {} - // empty - // . Returns true if there are no more tokens to be read - bool Scanner::empty() - { - EnsureTokensInQueue(); - return m_tokens.empty(); - } +Scanner::~Scanner() {} - // pop - // . Simply removes the next token on the queue. - void Scanner::pop() - { - EnsureTokensInQueue(); - if(!m_tokens.empty()) - m_tokens.pop(); - } +bool Scanner::empty() { + EnsureTokensInQueue(); + return m_tokens.empty(); +} - // peek - // . Returns (but does not remove) the next token on the queue. - Token& Scanner::peek() - { - EnsureTokensInQueue(); - assert(!m_tokens.empty()); // should we be asserting here? I mean, we really just be checking - // if it's empty before peeking. +void Scanner::pop() { + EnsureTokensInQueue(); + if (!m_tokens.empty()) + m_tokens.pop(); +} + +Token& Scanner::peek() { + EnsureTokensInQueue(); + assert(!m_tokens.empty()); // should we be asserting here? I mean, we really + // just be checking + // if it's empty before peeking. #if 0 static Token *pLast = 0; if(pLast != &m_tokens.front()) std::cerr << "peek: " << m_tokens.front() << "\n"; pLast = &m_tokens.front(); #endif - return m_tokens.front(); - } + return m_tokens.front(); +} - // EnsureTokensInQueue - // . Scan until there's a valid token at the front of the queue, - // or we're sure the queue is empty. - void Scanner::EnsureTokensInQueue() - { - while(1) { - if(!m_tokens.empty()) { - Token& token = m_tokens.front(); +Mark Scanner::mark() const { return INPUT.mark(); } - // if this guy's valid, then we're done - if(token.status == Token::VALID) - return; +void Scanner::EnsureTokensInQueue() { + while (1) { + if (!m_tokens.empty()) { + Token& token = m_tokens.front(); - // here's where we clean up the impossible tokens - if(token.status == Token::INVALID) { - m_tokens.pop(); - continue; - } + // if this guy's valid, then we're done + if (token.status == Token::VALID) { + return; + } - // note: what's left are the unverified tokens - } + // here's where we clean up the impossible tokens + if (token.status == Token::INVALID) { + m_tokens.pop(); + continue; + } - // no token? maybe we've actually finished - if(m_endedStream) - return; + // note: what's left are the unverified tokens + } - // no? then scan... - ScanNextToken(); - } - } + // no token? maybe we've actually finished + if (m_endedStream) { + return; + } - // ScanNextToken - // . The main scanning function; here we branch out and - // scan whatever the next token should be. - void Scanner::ScanNextToken() - { - if(m_endedStream) - return; + // no? then scan... + ScanNextToken(); + } +} - if(!m_startedStream) - return StartStream(); +void Scanner::ScanNextToken() { + if (m_endedStream) { + return; + } - // get rid of whitespace, etc. (in between tokens it should be irrelevent) - ScanToNextToken(); + if (!m_startedStream) { + return StartStream(); + } - // maybe need to end some blocks - PopIndentToHere(); + // get rid of whitespace, etc. (in between tokens it should be irrelevent) + ScanToNextToken(); - // ***** - // And now branch based on the next few characters! - // ***** + // maybe need to end some blocks + PopIndentToHere(); - // end of stream - if(!INPUT) - return EndStream(); + // ***** + // And now branch based on the next few characters! + // ***** - if(INPUT.column() == 0 && INPUT.peek() == Keys::Directive) - return ScanDirective(); + // end of stream + if (!INPUT) { + return EndStream(); + } - // document token - if(INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) - return ScanDocStart(); + if (INPUT.column() == 0 && INPUT.peek() == Keys::Directive) { + return ScanDirective(); + } - if(INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) - return ScanDocEnd(); + // document token + if (INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) { + return ScanDocStart(); + } - // flow start/end/entry - if(INPUT.peek() == Keys::FlowSeqStart || INPUT.peek() == Keys::FlowMapStart) - return ScanFlowStart(); + if (INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) { + return ScanDocEnd(); + } - if(INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) - return ScanFlowEnd(); + // flow start/end/entry + if (INPUT.peek() == Keys::FlowSeqStart || + INPUT.peek() == Keys::FlowMapStart) { + return ScanFlowStart(); + } - if(INPUT.peek() == Keys::FlowEntry) - return ScanFlowEntry(); + if (INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) { + return ScanFlowEnd(); + } - // block/map stuff - if(Exp::BlockEntry().Matches(INPUT)) - return ScanBlockEntry(); + if (INPUT.peek() == Keys::FlowEntry) { + return ScanFlowEntry(); + } - if((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) - return ScanKey(); + // block/map stuff + if (Exp::BlockEntry().Matches(INPUT)) { + return ScanBlockEntry(); + } - if(GetValueRegex().Matches(INPUT)) - return ScanValue(); + if ((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) { + return ScanKey(); + } - // alias/anchor - if(INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) - return ScanAnchorOrAlias(); + if (GetValueRegex().Matches(INPUT)) { + return ScanValue(); + } - // tag - if(INPUT.peek() == Keys::Tag) - return ScanTag(); + // alias/anchor + if (INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) { + return ScanAnchorOrAlias(); + } - // special scalars - if(InBlockContext() && (INPUT.peek() == Keys::LiteralScalar || INPUT.peek() == Keys::FoldedScalar)) - return ScanBlockScalar(); + // tag + if (INPUT.peek() == Keys::Tag) { + return ScanTag(); + } - if(INPUT.peek() == '\'' || INPUT.peek() == '\"') - return ScanQuotedScalar(); + // special scalars + if (InBlockContext() && (INPUT.peek() == Keys::LiteralScalar || + INPUT.peek() == Keys::FoldedScalar)) { + return ScanBlockScalar(); + } - // plain scalars - if((InBlockContext() ? Exp::PlainScalar() : Exp::PlainScalarInFlow()).Matches(INPUT)) - return ScanPlainScalar(); + if (INPUT.peek() == '\'' || INPUT.peek() == '\"') { + return ScanQuotedScalar(); + } - // don't know what it is! - throw ParserException(INPUT.mark(), ErrorMsg::UNKNOWN_TOKEN); - } + // plain scalars + if ((InBlockContext() ? Exp::PlainScalar() : Exp::PlainScalarInFlow()) + .Matches(INPUT)) { + return ScanPlainScalar(); + } - // ScanToNextToken - // . Eats input until we reach the next token-like thing. - void Scanner::ScanToNextToken() - { - while(1) { - // first eat whitespace - while(INPUT && IsWhitespaceToBeEaten(INPUT.peek())) { - if(InBlockContext() && Exp::Tab().Matches(INPUT)) - m_simpleKeyAllowed = false; - INPUT.eat(1); - } + // don't know what it is! + throw ParserException(INPUT.mark(), ErrorMsg::UNKNOWN_TOKEN); +} - // then eat a comment - if(Exp::Comment().Matches(INPUT)) { - // eat until line break - while(INPUT && !Exp::Break().Matches(INPUT)) - INPUT.eat(1); - } +void Scanner::ScanToNextToken() { + while (1) { + // first eat whitespace + while (INPUT && IsWhitespaceToBeEaten(INPUT.peek())) { + if (InBlockContext() && Exp::Tab().Matches(INPUT)) { + m_simpleKeyAllowed = false; + } + INPUT.eat(1); + } - // if it's NOT a line break, then we're done! - if(!Exp::Break().Matches(INPUT)) - break; + // then eat a comment + if (Exp::Comment().Matches(INPUT)) { + // eat until line break + while (INPUT && !Exp::Break().Matches(INPUT)) { + INPUT.eat(1); + } + } - // otherwise, let's eat the line break and keep going - int n = Exp::Break().Match(INPUT); - INPUT.eat(n); + // if it's NOT a line break, then we're done! + if (!Exp::Break().Matches(INPUT)) { + break; + } - // oh yeah, and let's get rid of that simple key - InvalidateSimpleKey(); + // otherwise, let's eat the line break and keep going + int n = Exp::Break().Match(INPUT); + INPUT.eat(n); - // new line - we may be able to accept a simple key now - if(InBlockContext()) - m_simpleKeyAllowed = true; - } - } + // oh yeah, and let's get rid of that simple key + InvalidateSimpleKey(); - /////////////////////////////////////////////////////////////////////// - // Misc. helpers + // new line - we may be able to accept a simple key now + if (InBlockContext()) { + m_simpleKeyAllowed = true; + } + } +} - // IsWhitespaceToBeEaten - // . We can eat whitespace if it's a space or tab - // . Note: originally tabs in block context couldn't be eaten - // "where a simple key could be allowed - // (i.e., not at the beginning of a line, or following '-', '?', or ':')" - // I think this is wrong, since tabs can be non-content whitespace; it's just - // that they can't contribute to indentation, so once you've seen a tab in a - // line, you can't start a simple key - bool Scanner::IsWhitespaceToBeEaten(char ch) - { - if(ch == ' ') - return true; +/////////////////////////////////////////////////////////////////////// +// Misc. helpers - if(ch == '\t') - return true; +// IsWhitespaceToBeEaten +// . We can eat whitespace if it's a space or tab +// . Note: originally tabs in block context couldn't be eaten +// "where a simple key could be allowed +// (i.e., not at the beginning of a line, or following '-', '?', or +// ':')" +// I think this is wrong, since tabs can be non-content whitespace; it's just +// that they can't contribute to indentation, so once you've seen a tab in a +// line, you can't start a simple key +bool Scanner::IsWhitespaceToBeEaten(char ch) { + if (ch == ' ') { + return true; + } - return false; - } + if (ch == '\t') { + return true; + } - // GetValueRegex - // . Get the appropriate regex to check if it's a value token - const RegEx& Scanner::GetValueRegex() const - { - if(InBlockContext()) - return Exp::Value(); + return false; +} - return m_canBeJSONFlow ? Exp::ValueInJSONFlow() : Exp::ValueInFlow(); - } +const RegEx& Scanner::GetValueRegex() const { + if (InBlockContext()) { + return Exp::Value(); + } - // StartStream - // . Set the initial conditions for starting a stream. - void Scanner::StartStream() - { - m_startedStream = true; - m_simpleKeyAllowed = true; - std::unique_ptr pIndent(new IndentMarker(-1, IndentMarker::NONE)); - m_indentRefs.push_back(std::move(pIndent)); - m_indents.push(&m_indentRefs.back()); - } + return m_canBeJSONFlow ? Exp::ValueInJSONFlow() : Exp::ValueInFlow(); +} - // EndStream - // . Close out the stream, finish up, etc. - void Scanner::EndStream() - { - // force newline - if(INPUT.column() > 0) - INPUT.ResetColumn(); +void Scanner::StartStream() { + m_startedStream = true; + m_simpleKeyAllowed = true; + std::unique_ptr pIndent( + new IndentMarker(-1, IndentMarker::NONE)); + m_indentRefs.push_back(std::move(pIndent)); + m_indents.push(&m_indentRefs.back()); +} - PopAllIndents(); - PopAllSimpleKeys(); +void Scanner::EndStream() { + // force newline + if (INPUT.column() > 0) { + INPUT.ResetColumn(); + } - m_simpleKeyAllowed = false; - m_endedStream = true; - } + PopAllIndents(); + PopAllSimpleKeys(); - Token *Scanner::PushToken(Token::TYPE type) - { - m_tokens.push(Token(type, INPUT.mark())); - return &m_tokens.back(); - } + m_simpleKeyAllowed = false; + m_endedStream = true; +} - Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) const - { - switch(type) { - case IndentMarker::SEQ: return Token::BLOCK_SEQ_START; - case IndentMarker::MAP: return Token::BLOCK_MAP_START; - case IndentMarker::NONE: assert(false); break; - } - assert(false); - throw std::runtime_error("yaml-cpp: internal error, invalid indent type"); - } +Token* Scanner::PushToken(Token::TYPE type) { + m_tokens.push(Token(type, INPUT.mark())); + return &m_tokens.back(); +} - // PushIndentTo - // . Pushes an indentation onto the stack, and enqueues the - // proper token (sequence start or mapping start). - // . Returns the indent marker it generates (if any). - Scanner::IndentMarker *Scanner::PushIndentTo(int column, IndentMarker::INDENT_TYPE type) - { - // are we in flow? - if(InFlowContext()) - return 0; +Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) const { + switch (type) { + case IndentMarker::SEQ: + return Token::BLOCK_SEQ_START; + case IndentMarker::MAP: + return Token::BLOCK_MAP_START; + case IndentMarker::NONE: + assert(false); + break; + } + assert(false); + throw std::runtime_error("yaml-cpp: internal error, invalid indent type"); +} - std::unique_ptr pIndent(new IndentMarker(column, type)); - IndentMarker& indent = *pIndent; - const IndentMarker& lastIndent = *m_indents.top(); +Scanner::IndentMarker* Scanner::PushIndentTo(int column, + IndentMarker::INDENT_TYPE type) { + // are we in flow? + if (InFlowContext()) { + return 0; + } - // is this actually an indentation? - if(indent.column < lastIndent.column) - return 0; - if(indent.column == lastIndent.column && !(indent.type == IndentMarker::SEQ && lastIndent.type == IndentMarker::MAP)) - return 0; + std::unique_ptr pIndent(new IndentMarker(column, type)); + IndentMarker& indent = *pIndent; + const IndentMarker& lastIndent = *m_indents.top(); - // push a start token - indent.pStartToken = PushToken(GetStartTokenFor(type)); + // is this actually an indentation? + if (indent.column < lastIndent.column) { + return 0; + } + if (indent.column == lastIndent.column && + !(indent.type == IndentMarker::SEQ && + lastIndent.type == IndentMarker::MAP)) { + return 0; + } - // and then the indent - m_indents.push(&indent); - m_indentRefs.push_back(std::move(pIndent)); - return &m_indentRefs.back(); - } + // push a start token + indent.pStartToken = PushToken(GetStartTokenFor(type)); - // PopIndentToHere - // . Pops indentations off the stack until we reach the current indentation level, - // and enqueues the proper token each time. - // . Then pops all invalid indentations off. - void Scanner::PopIndentToHere() - { - // are we in flow? - if(InFlowContext()) - return; + // and then the indent + m_indents.push(&indent); + m_indentRefs.push_back(std::move(pIndent)); + return &m_indentRefs.back(); +} - // now pop away - while(!m_indents.empty()) { - const IndentMarker& indent = *m_indents.top(); - if(indent.column < INPUT.column()) - break; - if(indent.column == INPUT.column() && !(indent.type == IndentMarker::SEQ && !Exp::BlockEntry().Matches(INPUT))) - break; +void Scanner::PopIndentToHere() { + // are we in flow? + if (InFlowContext()) { + return; + } - PopIndent(); - } + // now pop away + while (!m_indents.empty()) { + const IndentMarker& indent = *m_indents.top(); + if (indent.column < INPUT.column()) { + break; + } + if (indent.column == INPUT.column() && + !(indent.type == IndentMarker::SEQ && + !Exp::BlockEntry().Matches(INPUT))) { + break; + } - while(!m_indents.empty() && m_indents.top()->status == IndentMarker::INVALID) - PopIndent(); - } + PopIndent(); + } - // PopAllIndents - // . Pops all indentations (except for the base empty one) off the stack, - // and enqueues the proper token each time. - void Scanner::PopAllIndents() - { - // are we in flow? - if(InFlowContext()) - return; + while (!m_indents.empty() && + m_indents.top()->status == IndentMarker::INVALID) { + PopIndent(); + } +} - // now pop away - while(!m_indents.empty()) { - const IndentMarker& indent = *m_indents.top(); - if(indent.type == IndentMarker::NONE) - break; +void Scanner::PopAllIndents() { + // are we in flow? + if (InFlowContext()) { + return; + } - PopIndent(); - } - } + // now pop away + while (!m_indents.empty()) { + const IndentMarker& indent = *m_indents.top(); + if (indent.type == IndentMarker::NONE) { + break; + } - // PopIndent - // . Pops a single indent, pushing the proper token - void Scanner::PopIndent() - { - const IndentMarker& indent = *m_indents.top(); - m_indents.pop(); + PopIndent(); + } +} - if(indent.status != IndentMarker::VALID) { - InvalidateSimpleKey(); - return; - } +void Scanner::PopIndent() { + const IndentMarker& indent = *m_indents.top(); + m_indents.pop(); - if(indent.type == IndentMarker::SEQ) - m_tokens.push(Token(Token::BLOCK_SEQ_END, INPUT.mark())); - else if(indent.type == IndentMarker::MAP) - m_tokens.push(Token(Token::BLOCK_MAP_END, INPUT.mark())); - } + if (indent.status != IndentMarker::VALID) { + InvalidateSimpleKey(); + return; + } - // GetTopIndent - int Scanner::GetTopIndent() const - { - if(m_indents.empty()) - return 0; - return m_indents.top()->column; - } + if (indent.type == IndentMarker::SEQ) { + m_tokens.push(Token(Token::BLOCK_SEQ_END, INPUT.mark())); + } else if (indent.type == IndentMarker::MAP) { + m_tokens.push(Token(Token::BLOCK_MAP_END, INPUT.mark())); + } +} - // ThrowParserException - // . Throws a ParserException with the current token location - // (if available). - // . Does not parse any more tokens. - void Scanner::ThrowParserException(const std::string& msg) const - { - Mark mark = Mark::null(); - if(!m_tokens.empty()) { - const Token& token = m_tokens.front(); - mark = token.mark; - } - throw ParserException(mark, msg); - } +int Scanner::GetTopIndent() const { + if (m_indents.empty()) { + return 0; + } + return m_indents.top()->column; } + +void Scanner::ThrowParserException(const std::string& msg) const { + Mark mark = Mark::null_mark(); + if (!m_tokens.empty()) { + const Token& token = m_tokens.front(); + mark = token.mark; + } + throw ParserException(mark, msg); +} +} // namespace YAML diff --git a/src/yamlcpp/scanner.h b/src/yamlcpp/scanner.h --- a/src/yamlcpp/scanner.h +++ b/src/yamlcpp/scanner.h @@ -1,132 +1,190 @@ #ifndef SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include #include "ptr_vector.h" #include "stream.h" #include "token.h" +#include "yaml-cpp/mark.h" -namespace LHAPDF_YAML -{ - class Node; - class RegEx; +namespace YAML { +class Node; +class RegEx; - class Scanner - { - public: - Scanner(std::istream& in); - ~Scanner(); +/** + * A scanner transforms a stream of characters into a stream of tokens. + */ +class Scanner { + public: + explicit Scanner(std::istream &in); + ~Scanner(); - // token queue management (hopefully this looks kinda stl-ish) - bool empty(); - void pop(); - Token& peek(); + /** Returns true if there are no more tokens to be read. */ + bool empty(); - private: - struct IndentMarker { - enum INDENT_TYPE { MAP, SEQ, NONE }; - enum STATUS { VALID, INVALID, UNKNOWN }; - IndentMarker(int column_, INDENT_TYPE type_): column(column_), type(type_), status(VALID), pStartToken(0) {} - - int column; - INDENT_TYPE type; - STATUS status; - Token *pStartToken; - }; - - enum FLOW_MARKER { FLOW_MAP, FLOW_SEQ }; - - private: - // scanning - void EnsureTokensInQueue(); - void ScanNextToken(); - void ScanToNextToken(); - void StartStream(); - void EndStream(); - Token *PushToken(Token::TYPE type); - - bool InFlowContext() const { return !m_flows.empty(); } - bool InBlockContext() const { return m_flows.empty(); } - int GetFlowLevel() const { return m_flows.size(); } - - Token::TYPE GetStartTokenFor(IndentMarker::INDENT_TYPE type) const; - IndentMarker *PushIndentTo(int column, IndentMarker::INDENT_TYPE type); - void PopIndentToHere(); - void PopAllIndents(); - void PopIndent(); - int GetTopIndent() const; + /** Removes the next token in the queue. */ + void pop(); - // checking input - bool CanInsertPotentialSimpleKey() const; - bool ExistsActiveSimpleKey() const; - void InsertPotentialSimpleKey(); - void InvalidateSimpleKey(); - bool VerifySimpleKey(); - void PopAllSimpleKeys(); - - void ThrowParserException(const std::string& msg) const; + /** Returns, but does not remove, the next token in the queue. */ + Token &peek(); - bool IsWhitespaceToBeEaten(char ch); - const RegEx& GetValueRegex() const; + /** Returns the current mark in the input stream. */ + Mark mark() const; - struct SimpleKey { - SimpleKey(const Mark& mark_, int flowLevel_); + private: + struct IndentMarker { + enum INDENT_TYPE { MAP, SEQ, NONE }; + enum STATUS { VALID, INVALID, UNKNOWN }; + IndentMarker(int column_, INDENT_TYPE type_) + : column(column_), type(type_), status(VALID), pStartToken(0) {} - void Validate(); - void Invalidate(); - - Mark mark; - int flowLevel; - IndentMarker *pIndent; - Token *pMapStart, *pKey; - }; + int column; + INDENT_TYPE type; + STATUS status; + Token *pStartToken; + }; - // and the tokens - void ScanDirective(); - void ScanDocStart(); - void ScanDocEnd(); - void ScanBlockSeqStart(); - void ScanBlockMapSTart(); - void ScanBlockEnd(); - void ScanBlockEntry(); - void ScanFlowStart(); - void ScanFlowEnd(); - void ScanFlowEntry(); - void ScanKey(); - void ScanValue(); - void ScanAnchorOrAlias(); - void ScanTag(); - void ScanPlainScalar(); - void ScanQuotedScalar(); - void ScanBlockScalar(); + enum FLOW_MARKER { FLOW_MAP, FLOW_SEQ }; - private: - // the stream - Stream INPUT; + private: + // scanning - // the output (tokens) - std::queue m_tokens; + /** + * Scans until there's a valid token at the front of the queue, or the queue + * is empty. The state can be checked by {@link #empty}, and the next token + * retrieved by {@link #peek}. + */ + void EnsureTokensInQueue(); - // state info - bool m_startedStream, m_endedStream; - bool m_simpleKeyAllowed; - bool m_canBeJSONFlow; - std::stack m_simpleKeys; - std::stack m_indents; - ptr_vector m_indentRefs; // for "garbage collection" - std::stack m_flows; - }; + /** + * The main scanning function; this method branches out to scan whatever the + * next token should be. + */ + void ScanNextToken(); + + /** Eats the input stream until it reaches the next token-like thing. */ + void ScanToNextToken(); + + /** Sets the initial conditions for starting a stream. */ + void StartStream(); + + /** Closes out the stream, finish up, etc. */ + void EndStream(); + + Token *PushToken(Token::TYPE type); + + bool InFlowContext() const { return !m_flows.empty(); } + bool InBlockContext() const { return m_flows.empty(); } + std::size_t GetFlowLevel() const { return m_flows.size(); } + + Token::TYPE GetStartTokenFor(IndentMarker::INDENT_TYPE type) const; + + /** + * Pushes an indentation onto the stack, and enqueues the proper token + * (sequence start or mapping start). + * + * @return the indent marker it generates (if any). + */ + IndentMarker *PushIndentTo(int column, IndentMarker::INDENT_TYPE type); + + /** + * Pops indentations off the stack until it reaches the current indentation + * level, and enqueues the proper token each time. Then pops all invalid + * indentations off. + */ + void PopIndentToHere(); + + /** + * Pops all indentations (except for the base empty one) off the stack, and + * enqueues the proper token each time. + */ + void PopAllIndents(); + + /** Pops a single indent, pushing the proper token. */ + void PopIndent(); + int GetTopIndent() const; + + // checking input + bool CanInsertPotentialSimpleKey() const; + bool ExistsActiveSimpleKey() const; + void InsertPotentialSimpleKey(); + void InvalidateSimpleKey(); + bool VerifySimpleKey(); + void PopAllSimpleKeys(); + + /** + * Throws a ParserException with the current token location (if available), + * and does not parse any more tokens. + */ + void ThrowParserException(const std::string &msg) const; + + bool IsWhitespaceToBeEaten(char ch); + + /** + * Returns the appropriate regex to check if the next token is a value token. + */ + const RegEx &GetValueRegex() const; + + struct SimpleKey { + SimpleKey(const Mark &mark_, std::size_t flowLevel_); + + void Validate(); + void Invalidate(); + + Mark mark; + std::size_t flowLevel; + IndentMarker *pIndent; + Token *pMapStart, *pKey; + }; + + // and the tokens + void ScanDirective(); + void ScanDocStart(); + void ScanDocEnd(); + void ScanBlockSeqStart(); + void ScanBlockMapSTart(); + void ScanBlockEnd(); + void ScanBlockEntry(); + void ScanFlowStart(); + void ScanFlowEnd(); + void ScanFlowEntry(); + void ScanKey(); + void ScanValue(); + void ScanAnchorOrAlias(); + void ScanTag(); + void ScanPlainScalar(); + void ScanQuotedScalar(); + void ScanBlockScalar(); + + private: + // the stream + Stream INPUT; + + // the output (tokens) + std::queue m_tokens; + + // state info + bool m_startedStream, m_endedStream; + bool m_simpleKeyAllowed; + bool m_canBeJSONFlow; + std::stack m_simpleKeys; + std::stack m_indents; + ptr_vector m_indentRefs; // for "garbage collection" + std::stack m_flows; +}; } -#endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/scanscalar.cpp b/src/yamlcpp/scanscalar.cpp --- a/src/yamlcpp/scanscalar.cpp +++ b/src/yamlcpp/scanscalar.cpp @@ -1,214 +1,250 @@ #include "scanscalar.h" -#include "scanner.h" + +#include + #include "exp.h" -#include "yaml-cpp/exceptions.h" -#include "token.h" +#include "regeximpl.h" +#include "stream.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep -namespace LHAPDF_YAML -{ - // ScanScalar - // . This is where the scalar magic happens. - // - // . We do the scanning in three phases: - // 1. Scan until newline - // 2. Eat newline - // 3. Scan leading blanks. - // - // . Depending on the parameters given, we store or stop - // and different places in the above flow. - std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) - { - bool foundNonEmptyLine = false; - bool pastOpeningBreak = (params.fold == FOLD_FLOW); - bool emptyLine = false, moreIndented = false; - int foldedNewlineCount = 0; - bool foldedNewlineStartedMoreIndented = false; - std::size_t lastEscapedChar = std::string::npos; - std::string scalar; - params.leadingSpaces = false; +namespace YAML { +// ScanScalar +// . This is where the scalar magic happens. +// +// . We do the scanning in three phases: +// 1. Scan until newline +// 2. Eat newline +// 3. Scan leading blanks. +// +// . Depending on the parameters given, we store or stop +// and different places in the above flow. +std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) { + bool foundNonEmptyLine = false; + bool pastOpeningBreak = (params.fold == FOLD_FLOW); + bool emptyLine = false, moreIndented = false; + int foldedNewlineCount = 0; + bool foldedNewlineStartedMoreIndented = false; + std::size_t lastEscapedChar = std::string::npos; + std::string scalar; + params.leadingSpaces = false; - while(INPUT) { - // ******************************** - // Phase #1: scan until line ending - - std::size_t lastNonWhitespaceChar = scalar.size(); - bool escapedNewline = false; - while(!params.end.Matches(INPUT) && !Exp::Break().Matches(INPUT)) { - if(!INPUT) - break; + if (!params.end) { + params.end = &Exp::Empty(); + } - // document indicator? - if(INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) { - if(params.onDocIndicator == BREAK) - break; - else if(params.onDocIndicator == THROW) - throw ParserException(INPUT.mark(), ErrorMsg::DOC_IN_SCALAR); - } + while (INPUT) { + // ******************************** + // Phase #1: scan until line ending - foundNonEmptyLine = true; - pastOpeningBreak = true; + std::size_t lastNonWhitespaceChar = scalar.size(); + bool escapedNewline = false; + while (!params.end->Matches(INPUT) && !Exp::Break().Matches(INPUT)) { + if (!INPUT) { + break; + } - // escaped newline? (only if we're escaping on slash) - if(params.escape == '\\' && Exp::EscBreak().Matches(INPUT)) { - // eat escape character and get out (but preserve trailing whitespace!) - INPUT.get(); - lastNonWhitespaceChar = scalar.size(); - lastEscapedChar = scalar.size(); - escapedNewline = true; - break; - } + // document indicator? + if (INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) { + if (params.onDocIndicator == BREAK) { + break; + } else if (params.onDocIndicator == THROW) { + throw ParserException(INPUT.mark(), ErrorMsg::DOC_IN_SCALAR); + } + } - // escape this? - if(INPUT.peek() == params.escape) { - scalar += Exp::Escape(INPUT); - lastNonWhitespaceChar = scalar.size(); - lastEscapedChar = scalar.size(); - continue; - } + foundNonEmptyLine = true; + pastOpeningBreak = true; - // otherwise, just add the damn character - char ch = INPUT.get(); - scalar += ch; - if(ch != ' ' && ch != '\t') - lastNonWhitespaceChar = scalar.size(); - } + // escaped newline? (only if we're escaping on slash) + if (params.escape == '\\' && Exp::EscBreak().Matches(INPUT)) { + // eat escape character and get out (but preserve trailing whitespace!) + INPUT.get(); + lastNonWhitespaceChar = scalar.size(); + lastEscapedChar = scalar.size(); + escapedNewline = true; + break; + } - // eof? if we're looking to eat something, then we throw - if(!INPUT) { - if(params.eatEnd) - throw ParserException(INPUT.mark(), ErrorMsg::EOF_IN_SCALAR); - break; - } + // escape this? + if (INPUT.peek() == params.escape) { + scalar += Exp::Escape(INPUT); + lastNonWhitespaceChar = scalar.size(); + lastEscapedChar = scalar.size(); + continue; + } - // doc indicator? - if(params.onDocIndicator == BREAK && INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) - break; + // otherwise, just add the damn character + char ch = INPUT.get(); + scalar += ch; + if (ch != ' ' && ch != '\t') { + lastNonWhitespaceChar = scalar.size(); + } + } - // are we done via character match? - int n = params.end.Match(INPUT); - if(n >= 0) { - if(params.eatEnd) - INPUT.eat(n); - break; - } - - // do we remove trailing whitespace? - if(params.fold == FOLD_FLOW) - scalar.erase(lastNonWhitespaceChar); - - // ******************************** - // Phase #2: eat line ending - n = Exp::Break().Match(INPUT); - INPUT.eat(n); + // eof? if we're looking to eat something, then we throw + if (!INPUT) { + if (params.eatEnd) { + throw ParserException(INPUT.mark(), ErrorMsg::EOF_IN_SCALAR); + } + break; + } - // ******************************** - // Phase #3: scan initial spaces + // doc indicator? + if (params.onDocIndicator == BREAK && INPUT.column() == 0 && + Exp::DocIndicator().Matches(INPUT)) { + break; + } - // first the required indentation - while(INPUT.peek() == ' ' && (INPUT.column() < params.indent || (params.detectIndent && !foundNonEmptyLine))) - INPUT.eat(1); + // are we done via character match? + int n = params.end->Match(INPUT); + if (n >= 0) { + if (params.eatEnd) { + INPUT.eat(n); + } + break; + } - // update indent if we're auto-detecting - if(params.detectIndent && !foundNonEmptyLine) - params.indent = std::max(params.indent, INPUT.column()); + // do we remove trailing whitespace? + if (params.fold == FOLD_FLOW) + scalar.erase(lastNonWhitespaceChar); - // and then the rest of the whitespace - while(Exp::Blank().Matches(INPUT)) { - // we check for tabs that masquerade as indentation - if(INPUT.peek() == '\t'&& INPUT.column() < params.indent && params.onTabInIndentation == THROW) - throw ParserException(INPUT.mark(), ErrorMsg::TAB_IN_INDENTATION); + // ******************************** + // Phase #2: eat line ending + n = Exp::Break().Match(INPUT); + INPUT.eat(n); - if(!params.eatLeadingWhitespace) - break; + // ******************************** + // Phase #3: scan initial spaces - INPUT.eat(1); - } + // first the required indentation + while (INPUT.peek() == ' ' && + (INPUT.column() < params.indent || + (params.detectIndent && !foundNonEmptyLine)) && + !params.end->Matches(INPUT)) { + INPUT.eat(1); + } - // was this an empty line? - bool nextEmptyLine = Exp::Break().Matches(INPUT); - bool nextMoreIndented = Exp::Blank().Matches(INPUT); - if(params.fold == FOLD_BLOCK && foldedNewlineCount == 0 && nextEmptyLine) - foldedNewlineStartedMoreIndented = moreIndented; + // update indent if we're auto-detecting + if (params.detectIndent && !foundNonEmptyLine) { + params.indent = std::max(params.indent, INPUT.column()); + } - // for block scalars, we always start with a newline, so we should ignore it (not fold or keep) - if(pastOpeningBreak) { - switch(params.fold) { - case DONT_FOLD: - scalar += "\n"; - break; - case FOLD_BLOCK: - if(!emptyLine && !nextEmptyLine && !moreIndented && !nextMoreIndented && INPUT.column() >= params.indent) - scalar += " "; - else if(nextEmptyLine) - foldedNewlineCount++; - else - scalar += "\n"; - - if(!nextEmptyLine && foldedNewlineCount > 0) { - scalar += std::string(foldedNewlineCount - 1, '\n'); - if(foldedNewlineStartedMoreIndented || nextMoreIndented | !foundNonEmptyLine) - scalar += "\n"; - foldedNewlineCount = 0; - } - break; - case FOLD_FLOW: - if(nextEmptyLine) - scalar += "\n"; - else if(!emptyLine && !nextEmptyLine && !escapedNewline) - scalar += " "; - break; - } - } + // and then the rest of the whitespace + while (Exp::Blank().Matches(INPUT)) { + // we check for tabs that masquerade as indentation + if (INPUT.peek() == '\t' && INPUT.column() < params.indent && + params.onTabInIndentation == THROW) { + throw ParserException(INPUT.mark(), ErrorMsg::TAB_IN_INDENTATION); + } - emptyLine = nextEmptyLine; - moreIndented = nextMoreIndented; - pastOpeningBreak = true; + if (!params.eatLeadingWhitespace) { + break; + } - // are we done via indentation? - if(!emptyLine && INPUT.column() < params.indent) { - params.leadingSpaces = true; - break; - } - } + if (params.end->Matches(INPUT)) { + break; + } - // post-processing - if(params.trimTrailingSpaces) { - std::size_t pos = scalar.find_last_not_of(' '); - if(lastEscapedChar != std::string::npos) { - if(pos < lastEscapedChar || pos == std::string::npos) - pos = lastEscapedChar; + INPUT.eat(1); + } + + // was this an empty line? + bool nextEmptyLine = Exp::Break().Matches(INPUT); + bool nextMoreIndented = Exp::Blank().Matches(INPUT); + if (params.fold == FOLD_BLOCK && foldedNewlineCount == 0 && nextEmptyLine) + foldedNewlineStartedMoreIndented = moreIndented; + + // for block scalars, we always start with a newline, so we should ignore it + // (not fold or keep) + if (pastOpeningBreak) { + switch (params.fold) { + case DONT_FOLD: + scalar += "\n"; + break; + case FOLD_BLOCK: + if (!emptyLine && !nextEmptyLine && !moreIndented && + !nextMoreIndented && INPUT.column() >= params.indent) { + scalar += " "; + } else if (nextEmptyLine) { + foldedNewlineCount++; + } else { + scalar += "\n"; + } + + if (!nextEmptyLine && foldedNewlineCount > 0) { + scalar += std::string(foldedNewlineCount - 1, '\n'); + if (foldedNewlineStartedMoreIndented || + nextMoreIndented | !foundNonEmptyLine) { + scalar += "\n"; } - if(pos < scalar.size()) - scalar.erase(pos + 1); - } + foldedNewlineCount = 0; + } + break; + case FOLD_FLOW: + if (nextEmptyLine) { + scalar += "\n"; + } else if (!emptyLine && !nextEmptyLine && !escapedNewline) { + scalar += " "; + } + break; + } + } - switch(params.chomp) { - case CLIP: { - std::size_t pos = scalar.find_last_not_of('\n'); - if(lastEscapedChar != std::string::npos) { - if(pos < lastEscapedChar || pos == std::string::npos) - pos = lastEscapedChar; - } - if(pos == std::string::npos) - scalar.erase(); - else if(pos + 1 < scalar.size()) - scalar.erase(pos + 2); - } break; - case STRIP: { - std::size_t pos = scalar.find_last_not_of('\n'); - if(lastEscapedChar != std::string::npos) { - if(pos < lastEscapedChar || pos == std::string::npos) - pos = lastEscapedChar; - } - if(pos == std::string::npos) - scalar.erase(); - else if(pos < scalar.size()) - scalar.erase(pos + 1); - } break; - default: - break; - } + emptyLine = nextEmptyLine; + moreIndented = nextMoreIndented; + pastOpeningBreak = true; - return scalar; - } + // are we done via indentation? + if (!emptyLine && INPUT.column() < params.indent) { + params.leadingSpaces = true; + break; + } + } + + // post-processing + if (params.trimTrailingSpaces) { + std::size_t pos = scalar.find_last_not_of(' '); + if (lastEscapedChar != std::string::npos) { + if (pos < lastEscapedChar || pos == std::string::npos) { + pos = lastEscapedChar; + } + } + if (pos < scalar.size()) { + scalar.erase(pos + 1); + } + } + + switch (params.chomp) { + case CLIP: { + std::size_t pos = scalar.find_last_not_of('\n'); + if (lastEscapedChar != std::string::npos) { + if (pos < lastEscapedChar || pos == std::string::npos) { + pos = lastEscapedChar; + } + } + if (pos == std::string::npos) { + scalar.erase(); + } else if (pos + 1 < scalar.size()) { + scalar.erase(pos + 2); + } + } break; + case STRIP: { + std::size_t pos = scalar.find_last_not_of('\n'); + if (lastEscapedChar != std::string::npos) { + if (pos < lastEscapedChar || pos == std::string::npos) { + pos = lastEscapedChar; + } + } + if (pos == std::string::npos) { + scalar.erase(); + } else if (pos < scalar.size()) { + scalar.erase(pos + 1); + } + } break; + default: + break; + } + + return scalar; } +} diff --git a/src/yamlcpp/scanscalar.h b/src/yamlcpp/scanscalar.h --- a/src/yamlcpp/scanscalar.h +++ b/src/yamlcpp/scanscalar.h @@ -1,45 +1,63 @@ #ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include -#include -#include "regex.h" +#include "regex_yaml.h" #include "stream.h" -namespace LHAPDF_YAML -{ - enum CHOMP { STRIP = -1, CLIP, KEEP }; - enum ACTION { NONE, BREAK, THROW }; - enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW }; +namespace YAML { +enum CHOMP { STRIP = -1, CLIP, KEEP }; +enum ACTION { NONE, BREAK, THROW }; +enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW }; - struct ScanScalarParams { - ScanScalarParams(): eatEnd(false), indent(0), detectIndent(false), eatLeadingWhitespace(0), escape(0), fold(DONT_FOLD), - trimTrailingSpaces(0), chomp(CLIP), onDocIndicator(NONE), onTabInIndentation(NONE), leadingSpaces(false) {} +struct ScanScalarParams { + ScanScalarParams() + : end(nullptr), + eatEnd(false), + indent(0), + detectIndent(false), + eatLeadingWhitespace(0), + escape(0), + fold(DONT_FOLD), + trimTrailingSpaces(0), + chomp(CLIP), + onDocIndicator(NONE), + onTabInIndentation(NONE), + leadingSpaces(false) {} - // input: - RegEx end; // what condition ends this scalar? - bool eatEnd; // should we eat that condition when we see it? - int indent; // what level of indentation should be eaten and ignored? - bool detectIndent; // should we try to autodetect the indent? - bool eatLeadingWhitespace; // should we continue eating this delicious indentation after 'indent' spaces? - char escape; // what character do we escape on (i.e., slash or single quote) (0 for none) - FOLD fold; // how do we fold line ends? - bool trimTrailingSpaces; // do we remove all trailing spaces (at the very end) - CHOMP chomp; // do we strip, clip, or keep trailing newlines (at the very end) - // Note: strip means kill all, clip means keep at most one, keep means keep all - ACTION onDocIndicator; // what do we do if we see a document indicator? - ACTION onTabInIndentation; // what do we do if we see a tab where we should be seeing indentation spaces + // input: + const RegEx* end; // what condition ends this scalar? + // unowned. + bool eatEnd; // should we eat that condition when we see it? + int indent; // what level of indentation should be eaten and ignored? + bool detectIndent; // should we try to autodetect the indent? + bool eatLeadingWhitespace; // should we continue eating this delicious + // indentation after 'indent' spaces? + char escape; // what character do we escape on (i.e., slash or single quote) + // (0 for none) + FOLD fold; // how do we fold line ends? + bool trimTrailingSpaces; // do we remove all trailing spaces (at the very + // end) + CHOMP chomp; // do we strip, clip, or keep trailing newlines (at the very + // end) + // Note: strip means kill all, clip means keep at most one, keep means keep + // all + ACTION onDocIndicator; // what do we do if we see a document indicator? + ACTION onTabInIndentation; // what do we do if we see a tab where we should + // be seeing indentation spaces - // output: - bool leadingSpaces; - }; + // output: + bool leadingSpaces; +}; - std::string ScanScalar(Stream& INPUT, ScanScalarParams& info); +std::string ScanScalar(Stream& INPUT, ScanScalarParams& info); } -#endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/scantag.cpp b/src/yamlcpp/scantag.cpp --- a/src/yamlcpp/scantag.cpp +++ b/src/yamlcpp/scantag.cpp @@ -1,84 +1,81 @@ -#include "scanner.h" -#include "regex.h" #include "exp.h" -#include "yaml-cpp/exceptions.h" +#include "regex_yaml.h" +#include "regeximpl.h" +#include "stream.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep +#include "yaml-cpp/mark.h" -namespace LHAPDF_YAML -{ - const std::string ScanVerbatimTag(Stream& INPUT) - { - std::string tag; - - // eat the start character - INPUT.get(); - - while(INPUT) { - if(INPUT.peek() == Keys::VerbatimTagEnd) { - // eat the end character - INPUT.get(); - return tag; - } - - int n = Exp::URI().Match(INPUT); - if(n <= 0) - break; - - tag += INPUT.get(n); - } +namespace YAML { +const std::string ScanVerbatimTag(Stream& INPUT) { + std::string tag; - throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG); - } - - const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle) - { - std::string tag; - canBeHandle = true; - Mark firstNonWordChar; - - while(INPUT) { - if(INPUT.peek() == Keys::Tag) { - if(!canBeHandle) - throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE); - break; - } + // eat the start character + INPUT.get(); - int n = 0; - if(canBeHandle) { - n = Exp::Word().Match(INPUT); - if(n <= 0) { - canBeHandle = false; - firstNonWordChar = INPUT.mark(); - } - } - - if(!canBeHandle) - n = Exp::Tag().Match(INPUT); + while (INPUT) { + if (INPUT.peek() == Keys::VerbatimTagEnd) { + // eat the end character + INPUT.get(); + return tag; + } - if(n <= 0) - break; - - tag += INPUT.get(n); - } + int n = Exp::URI().Match(INPUT); + if (n <= 0) + break; - return tag; - } - - const std::string ScanTagSuffix(Stream& INPUT) - { - std::string tag; - - while(INPUT) { - int n = Exp::Tag().Match(INPUT); - if(n <= 0) - break; - - tag += INPUT.get(n); - } - - if(tag.empty()) - throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX); - - return tag; - } + tag += INPUT.get(n); + } + + throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG); } +const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle) { + std::string tag; + canBeHandle = true; + Mark firstNonWordChar; + + while (INPUT) { + if (INPUT.peek() == Keys::Tag) { + if (!canBeHandle) + throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE); + break; + } + + int n = 0; + if (canBeHandle) { + n = Exp::Word().Match(INPUT); + if (n <= 0) { + canBeHandle = false; + firstNonWordChar = INPUT.mark(); + } + } + + if (!canBeHandle) + n = Exp::Tag().Match(INPUT); + + if (n <= 0) + break; + + tag += INPUT.get(n); + } + + return tag; +} + +const std::string ScanTagSuffix(Stream& INPUT) { + std::string tag; + + while (INPUT) { + int n = Exp::Tag().Match(INPUT); + if (n <= 0) + break; + + tag += INPUT.get(n); + } + + if (tag.empty()) + throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX); + + return tag; +} +} diff --git a/src/yamlcpp/scantag.h b/src/yamlcpp/scantag.h --- a/src/yamlcpp/scantag.h +++ b/src/yamlcpp/scantag.h @@ -1,20 +1,19 @@ #ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include #include "stream.h" -namespace LHAPDF_YAML -{ - const std::string ScanVerbatimTag(Stream& INPUT); - const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle); - const std::string ScanTagSuffix(Stream& INPUT); +namespace YAML { +const std::string ScanVerbatimTag(Stream& INPUT); +const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle); +const std::string ScanTagSuffix(Stream& INPUT); } -#endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/scantoken.cpp b/src/yamlcpp/scantoken.cpp --- a/src/yamlcpp/scantoken.cpp +++ b/src/yamlcpp/scantoken.cpp @@ -1,439 +1,437 @@ -#include "scanner.h" -#include "token.h" -#include "yaml-cpp/exceptions.h" -#include "exp.h" -#include "scanscalar.h" -#include "scantag.h" -#include "tag.h" #include -namespace LHAPDF_YAML -{ - /////////////////////////////////////////////////////////////////////// - // Specialization for scanning specific tokens +#include "exp.h" +#include "regex_yaml.h" +#include "regeximpl.h" +#include "scanner.h" +#include "scanscalar.h" +#include "scantag.h" // IWYU pragma: keep +#include "tag.h" // IWYU pragma: keep +#include "token.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep +#include "yaml-cpp/mark.h" - // Directive - // . Note: no semantic checking is done here (that's for the parser to do) - void Scanner::ScanDirective() - { - std::string name; - std::vector params; +namespace YAML { +/////////////////////////////////////////////////////////////////////// +// Specialization for scanning specific tokens - // pop indents and simple keys - PopAllIndents(); - PopAllSimpleKeys(); +// Directive +// . Note: no semantic checking is done here (that's for the parser to do) +void Scanner::ScanDirective() { + std::string name; + std::vector params; - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; + // pop indents and simple keys + PopAllIndents(); + PopAllSimpleKeys(); - // store pos and eat indicator - Token token(Token::DIRECTIVE, INPUT.mark()); - INPUT.eat(1); + m_simpleKeyAllowed = false; + m_canBeJSONFlow = false; - // read name - while(INPUT && !Exp::BlankOrBreak().Matches(INPUT)) - token.value += INPUT.get(); + // store pos and eat indicator + Token token(Token::DIRECTIVE, INPUT.mark()); + INPUT.eat(1); - // read parameters - while(1) { - // first get rid of whitespace - while(Exp::Blank().Matches(INPUT)) - INPUT.eat(1); + // read name + while (INPUT && !Exp::BlankOrBreak().Matches(INPUT)) + token.value += INPUT.get(); - // break on newline or comment - if(!INPUT || Exp::Break().Matches(INPUT) || Exp::Comment().Matches(INPUT)) - break; + // read parameters + while (1) { + // first get rid of whitespace + while (Exp::Blank().Matches(INPUT)) + INPUT.eat(1); - // now read parameter - std::string param; - while(INPUT && !Exp::BlankOrBreak().Matches(INPUT)) - param += INPUT.get(); + // break on newline or comment + if (!INPUT || Exp::Break().Matches(INPUT) || Exp::Comment().Matches(INPUT)) + break; - token.params.push_back(param); - } - - m_tokens.push(token); - } + // now read parameter + std::string param; + while (INPUT && !Exp::BlankOrBreak().Matches(INPUT)) + param += INPUT.get(); - // DocStart - void Scanner::ScanDocStart() - { - PopAllIndents(); - PopAllSimpleKeys(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; + token.params.push_back(param); + } - // eat - Mark mark = INPUT.mark(); - INPUT.eat(3); - m_tokens.push(Token(Token::DOC_START, mark)); - } + m_tokens.push(token); +} - // DocEnd - void Scanner::ScanDocEnd() - { - PopAllIndents(); - PopAllSimpleKeys(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; +// DocStart +void Scanner::ScanDocStart() { + PopAllIndents(); + PopAllSimpleKeys(); + m_simpleKeyAllowed = false; + m_canBeJSONFlow = false; - // eat - Mark mark = INPUT.mark(); - INPUT.eat(3); - m_tokens.push(Token(Token::DOC_END, mark)); - } + // eat + Mark mark = INPUT.mark(); + INPUT.eat(3); + m_tokens.push(Token(Token::DOC_START, mark)); +} - // FlowStart - void Scanner::ScanFlowStart() - { - // flows can be simple keys - InsertPotentialSimpleKey(); - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; +// DocEnd +void Scanner::ScanDocEnd() { + PopAllIndents(); + PopAllSimpleKeys(); + m_simpleKeyAllowed = false; + m_canBeJSONFlow = false; - // eat - Mark mark = INPUT.mark(); - char ch = INPUT.get(); - FLOW_MARKER flowType = (ch == Keys::FlowSeqStart ? FLOW_SEQ : FLOW_MAP); - m_flows.push(flowType); - Token::TYPE type = (flowType == FLOW_SEQ ? Token::FLOW_SEQ_START : Token::FLOW_MAP_START); - m_tokens.push(Token(type, mark)); - } + // eat + Mark mark = INPUT.mark(); + INPUT.eat(3); + m_tokens.push(Token(Token::DOC_END, mark)); +} - // FlowEnd - void Scanner::ScanFlowEnd() - { - if(InBlockContext()) - throw ParserException(INPUT.mark(), ErrorMsg::FLOW_END); +// FlowStart +void Scanner::ScanFlowStart() { + // flows can be simple keys + InsertPotentialSimpleKey(); + m_simpleKeyAllowed = true; + m_canBeJSONFlow = false; - // we might have a solo entry in the flow context - if(InFlowContext()) { - if(m_flows.top() == FLOW_MAP && VerifySimpleKey()) - m_tokens.push(Token(Token::VALUE, INPUT.mark())); - else if(m_flows.top() == FLOW_SEQ) - InvalidateSimpleKey(); - } + // eat + Mark mark = INPUT.mark(); + char ch = INPUT.get(); + FLOW_MARKER flowType = (ch == Keys::FlowSeqStart ? FLOW_SEQ : FLOW_MAP); + m_flows.push(flowType); + Token::TYPE type = + (flowType == FLOW_SEQ ? Token::FLOW_SEQ_START : Token::FLOW_MAP_START); + m_tokens.push(Token(type, mark)); +} - m_simpleKeyAllowed = false; - m_canBeJSONFlow = true; +// FlowEnd +void Scanner::ScanFlowEnd() { + if (InBlockContext()) + throw ParserException(INPUT.mark(), ErrorMsg::FLOW_END); - // eat - Mark mark = INPUT.mark(); - char ch = INPUT.get(); + // we might have a solo entry in the flow context + if (InFlowContext()) { + if (m_flows.top() == FLOW_MAP && VerifySimpleKey()) + m_tokens.push(Token(Token::VALUE, INPUT.mark())); + else if (m_flows.top() == FLOW_SEQ) + InvalidateSimpleKey(); + } - // check that it matches the start - FLOW_MARKER flowType = (ch == Keys::FlowSeqEnd ? FLOW_SEQ : FLOW_MAP); - if(m_flows.top() != flowType) - throw ParserException(mark, ErrorMsg::FLOW_END); - m_flows.pop(); - - Token::TYPE type = (flowType ? Token::FLOW_SEQ_END : Token::FLOW_MAP_END); - m_tokens.push(Token(type, mark)); - } + m_simpleKeyAllowed = false; + m_canBeJSONFlow = true; - // FlowEntry - void Scanner::ScanFlowEntry() - { - // we might have a solo entry in the flow context - if(InFlowContext()) { - if(m_flows.top() == FLOW_MAP && VerifySimpleKey()) - m_tokens.push(Token(Token::VALUE, INPUT.mark())); - else if(m_flows.top() == FLOW_SEQ) - InvalidateSimpleKey(); - } - - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; + // eat + Mark mark = INPUT.mark(); + char ch = INPUT.get(); - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::FLOW_ENTRY, mark)); - } + // check that it matches the start + FLOW_MARKER flowType = (ch == Keys::FlowSeqEnd ? FLOW_SEQ : FLOW_MAP); + if (m_flows.top() != flowType) + throw ParserException(mark, ErrorMsg::FLOW_END); + m_flows.pop(); - // BlockEntry - void Scanner::ScanBlockEntry() - { - // we better be in the block context! - if(InFlowContext()) - throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY); + Token::TYPE type = (flowType ? Token::FLOW_SEQ_END : Token::FLOW_MAP_END); + m_tokens.push(Token(type, mark)); +} - // can we put it here? - if(!m_simpleKeyAllowed) - throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY); +// FlowEntry +void Scanner::ScanFlowEntry() { + // we might have a solo entry in the flow context + if (InFlowContext()) { + if (m_flows.top() == FLOW_MAP && VerifySimpleKey()) + m_tokens.push(Token(Token::VALUE, INPUT.mark())); + else if (m_flows.top() == FLOW_SEQ) + InvalidateSimpleKey(); + } - PushIndentTo(INPUT.column(), IndentMarker::SEQ); - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; + m_simpleKeyAllowed = true; + m_canBeJSONFlow = false; - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::BLOCK_ENTRY, mark)); - } + // eat + Mark mark = INPUT.mark(); + INPUT.eat(1); + m_tokens.push(Token(Token::FLOW_ENTRY, mark)); +} - // Key - void Scanner::ScanKey() - { - // handle keys diffently in the block context (and manage indents) - if(InBlockContext()) { - if(!m_simpleKeyAllowed) - throw ParserException(INPUT.mark(), ErrorMsg::MAP_KEY); +// BlockEntry +void Scanner::ScanBlockEntry() { + // we better be in the block context! + if (InFlowContext()) + throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY); - PushIndentTo(INPUT.column(), IndentMarker::MAP); - } + // can we put it here? + if (!m_simpleKeyAllowed) + throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY); - // can only put a simple key here if we're in block context - m_simpleKeyAllowed = InBlockContext(); + PushIndentTo(INPUT.column(), IndentMarker::SEQ); + m_simpleKeyAllowed = true; + m_canBeJSONFlow = false; - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::KEY, mark)); - } + // eat + Mark mark = INPUT.mark(); + INPUT.eat(1); + m_tokens.push(Token(Token::BLOCK_ENTRY, mark)); +} - // Value - void Scanner::ScanValue() - { - // and check that simple key - bool isSimpleKey = VerifySimpleKey(); - m_canBeJSONFlow = false; - - if(isSimpleKey) { - // can't follow a simple key with another simple key (dunno why, though - it seems fine) - m_simpleKeyAllowed = false; - } else { - // handle values diffently in the block context (and manage indents) - if(InBlockContext()) { - if(!m_simpleKeyAllowed) - throw ParserException(INPUT.mark(), ErrorMsg::MAP_VALUE); +// Key +void Scanner::ScanKey() { + // handle keys diffently in the block context (and manage indents) + if (InBlockContext()) { + if (!m_simpleKeyAllowed) + throw ParserException(INPUT.mark(), ErrorMsg::MAP_KEY); - PushIndentTo(INPUT.column(), IndentMarker::MAP); - } + PushIndentTo(INPUT.column(), IndentMarker::MAP); + } - // can only put a simple key here if we're in block context - m_simpleKeyAllowed = InBlockContext(); - } + // can only put a simple key here if we're in block context + m_simpleKeyAllowed = InBlockContext(); - // eat - Mark mark = INPUT.mark(); - INPUT.eat(1); - m_tokens.push(Token(Token::VALUE, mark)); - } + // eat + Mark mark = INPUT.mark(); + INPUT.eat(1); + m_tokens.push(Token(Token::KEY, mark)); +} - // AnchorOrAlias - void Scanner::ScanAnchorOrAlias() - { - bool alias; - std::string name; +// Value +void Scanner::ScanValue() { + // and check that simple key + bool isSimpleKey = VerifySimpleKey(); + m_canBeJSONFlow = false; - // insert a potential simple key - InsertPotentialSimpleKey(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; + if (isSimpleKey) { + // can't follow a simple key with another simple key (dunno why, though - it + // seems fine) + m_simpleKeyAllowed = false; + } else { + // handle values diffently in the block context (and manage indents) + if (InBlockContext()) { + if (!m_simpleKeyAllowed) + throw ParserException(INPUT.mark(), ErrorMsg::MAP_VALUE); - // eat the indicator - Mark mark = INPUT.mark(); - char indicator = INPUT.get(); - alias = (indicator == Keys::Alias); + PushIndentTo(INPUT.column(), IndentMarker::MAP); + } - // now eat the content - while(INPUT && Exp::Anchor().Matches(INPUT)) - name += INPUT.get(); + // can only put a simple key here if we're in block context + m_simpleKeyAllowed = InBlockContext(); + } - // we need to have read SOMETHING! - if(name.empty()) - throw ParserException(INPUT.mark(), alias ? ErrorMsg::ALIAS_NOT_FOUND : ErrorMsg::ANCHOR_NOT_FOUND); + // eat + Mark mark = INPUT.mark(); + INPUT.eat(1); + m_tokens.push(Token(Token::VALUE, mark)); +} - // and needs to end correctly - if(INPUT && !Exp::AnchorEnd().Matches(INPUT)) - throw ParserException(INPUT.mark(), alias ? ErrorMsg::CHAR_IN_ALIAS : ErrorMsg::CHAR_IN_ANCHOR); +// AnchorOrAlias +void Scanner::ScanAnchorOrAlias() { + bool alias; + std::string name; - // and we're done - Token token(alias ? Token::ALIAS : Token::ANCHOR, mark); - token.value = name; - m_tokens.push(token); - } + // insert a potential simple key + InsertPotentialSimpleKey(); + m_simpleKeyAllowed = false; + m_canBeJSONFlow = false; - // Tag - void Scanner::ScanTag() - { - // insert a potential simple key - InsertPotentialSimpleKey(); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = false; + // eat the indicator + Mark mark = INPUT.mark(); + char indicator = INPUT.get(); + alias = (indicator == Keys::Alias); - Token token(Token::TAG, INPUT.mark()); + // now eat the content + while (INPUT && Exp::Anchor().Matches(INPUT)) + name += INPUT.get(); - // eat the indicator - INPUT.get(); - - if(INPUT && INPUT.peek() == Keys::VerbatimTagStart){ - std::string tag = ScanVerbatimTag(INPUT); + // we need to have read SOMETHING! + if (name.empty()) + throw ParserException(INPUT.mark(), alias ? ErrorMsg::ALIAS_NOT_FOUND + : ErrorMsg::ANCHOR_NOT_FOUND); - token.value = tag; - token.data = Tag::VERBATIM; - } else { - bool canBeHandle; - token.value = ScanTagHandle(INPUT, canBeHandle); - if(!canBeHandle && token.value.empty()) - token.data = Tag::NON_SPECIFIC; - else if(token.value.empty()) - token.data = Tag::SECONDARY_HANDLE; - else - token.data = Tag::PRIMARY_HANDLE; - - // is there a suffix? - if(canBeHandle && INPUT.peek() == Keys::Tag) { - // eat the indicator - INPUT.get(); - token.params.push_back(ScanTagSuffix(INPUT)); - token.data = Tag::NAMED_HANDLE; - } - } + // and needs to end correctly + if (INPUT && !Exp::AnchorEnd().Matches(INPUT)) + throw ParserException(INPUT.mark(), alias ? ErrorMsg::CHAR_IN_ALIAS + : ErrorMsg::CHAR_IN_ANCHOR); - m_tokens.push(token); - } + // and we're done + Token token(alias ? Token::ALIAS : Token::ANCHOR, mark); + token.value = name; + m_tokens.push(token); +} - // PlainScalar - void Scanner::ScanPlainScalar() - { - std::string scalar; +// Tag +void Scanner::ScanTag() { + // insert a potential simple key + InsertPotentialSimpleKey(); + m_simpleKeyAllowed = false; + m_canBeJSONFlow = false; - // set up the scanning parameters - ScanScalarParams params; - params.end = (InFlowContext() ? Exp::EndScalarInFlow() : Exp::EndScalar()) || (Exp::BlankOrBreak() + Exp::Comment()); - params.eatEnd = false; - params.indent = (InFlowContext() ? 0 : GetTopIndent() + 1); - params.fold = FOLD_FLOW; - params.eatLeadingWhitespace = true; - params.trimTrailingSpaces = true; - params.chomp = STRIP; - params.onDocIndicator = BREAK; - params.onTabInIndentation = THROW; + Token token(Token::TAG, INPUT.mark()); - // insert a potential simple key - InsertPotentialSimpleKey(); + // eat the indicator + INPUT.get(); - Mark mark = INPUT.mark(); - scalar = ScanScalar(INPUT, params); + if (INPUT && INPUT.peek() == Keys::VerbatimTagStart) { + std::string tag = ScanVerbatimTag(INPUT); - // can have a simple key only if we ended the scalar by starting a new line - m_simpleKeyAllowed = params.leadingSpaces; - m_canBeJSONFlow = false; + token.value = tag; + token.data = Tag::VERBATIM; + } else { + bool canBeHandle; + token.value = ScanTagHandle(INPUT, canBeHandle); + if (!canBeHandle && token.value.empty()) + token.data = Tag::NON_SPECIFIC; + else if (token.value.empty()) + token.data = Tag::SECONDARY_HANDLE; + else + token.data = Tag::PRIMARY_HANDLE; - // finally, check and see if we ended on an illegal character - //if(Exp::IllegalCharInScalar.Matches(INPUT)) - // throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_SCALAR); + // is there a suffix? + if (canBeHandle && INPUT.peek() == Keys::Tag) { + // eat the indicator + INPUT.get(); + token.params.push_back(ScanTagSuffix(INPUT)); + token.data = Tag::NAMED_HANDLE; + } + } - Token token(Token::PLAIN_SCALAR, mark); - token.value = scalar; - m_tokens.push(token); - } + m_tokens.push(token); +} - // QuotedScalar - void Scanner::ScanQuotedScalar() - { - std::string scalar; +// PlainScalar +void Scanner::ScanPlainScalar() { + std::string scalar; - // peek at single or double quote (don't eat because we need to preserve (for the time being) the input position) - char quote = INPUT.peek(); - bool single = (quote == '\''); + // set up the scanning parameters + ScanScalarParams params; + params.end = + (InFlowContext() ? &Exp::ScanScalarEndInFlow() : &Exp::ScanScalarEnd()); + params.eatEnd = false; + params.indent = (InFlowContext() ? 0 : GetTopIndent() + 1); + params.fold = FOLD_FLOW; + params.eatLeadingWhitespace = true; + params.trimTrailingSpaces = true; + params.chomp = STRIP; + params.onDocIndicator = BREAK; + params.onTabInIndentation = THROW; - // setup the scanning parameters - ScanScalarParams params; - params.end = (single ? RegEx(quote) && !Exp::EscSingleQuote() : RegEx(quote)); - params.eatEnd = true; - params.escape = (single ? '\'' : '\\'); - params.indent = 0; - params.fold = FOLD_FLOW; - params.eatLeadingWhitespace = true; - params.trimTrailingSpaces = false; - params.chomp = CLIP; - params.onDocIndicator = THROW; + // insert a potential simple key + InsertPotentialSimpleKey(); - // insert a potential simple key - InsertPotentialSimpleKey(); + Mark mark = INPUT.mark(); + scalar = ScanScalar(INPUT, params); - Mark mark = INPUT.mark(); + // can have a simple key only if we ended the scalar by starting a new line + m_simpleKeyAllowed = params.leadingSpaces; + m_canBeJSONFlow = false; - // now eat that opening quote - INPUT.get(); - - // and scan - scalar = ScanScalar(INPUT, params); - m_simpleKeyAllowed = false; - m_canBeJSONFlow = true; + // finally, check and see if we ended on an illegal character + // if(Exp::IllegalCharInScalar.Matches(INPUT)) + // throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_SCALAR); - Token token(Token::NON_PLAIN_SCALAR, mark); - token.value = scalar; - m_tokens.push(token); - } + Token token(Token::PLAIN_SCALAR, mark); + token.value = scalar; + m_tokens.push(token); +} - // BlockScalarToken - // . These need a little extra processing beforehand. - // . We need to scan the line where the indicator is (this doesn't count as part of the scalar), - // and then we need to figure out what level of indentation we'll be using. - void Scanner::ScanBlockScalar() - { - std::string scalar; +// QuotedScalar +void Scanner::ScanQuotedScalar() { + std::string scalar; - ScanScalarParams params; - params.indent = 1; - params.detectIndent = true; + // peek at single or double quote (don't eat because we need to preserve (for + // the time being) the input position) + char quote = INPUT.peek(); + bool single = (quote == '\''); - // eat block indicator ('|' or '>') - Mark mark = INPUT.mark(); - char indicator = INPUT.get(); - params.fold = (indicator == Keys::FoldedScalar ? FOLD_BLOCK : DONT_FOLD); + // setup the scanning parameters + ScanScalarParams params; + RegEx end = (single ? RegEx(quote) && !Exp::EscSingleQuote() : RegEx(quote)); + params.end = &end; + params.eatEnd = true; + params.escape = (single ? '\'' : '\\'); + params.indent = 0; + params.fold = FOLD_FLOW; + params.eatLeadingWhitespace = true; + params.trimTrailingSpaces = false; + params.chomp = CLIP; + params.onDocIndicator = THROW; - // eat chomping/indentation indicators - params.chomp = CLIP; - int n = Exp::Chomp().Match(INPUT); - for(int i=0;i= 0) - params.indent += GetTopIndent(); +// BlockScalarToken +// . These need a little extra processing beforehand. +// . We need to scan the line where the indicator is (this doesn't count as part +// of the scalar), +// and then we need to figure out what level of indentation we'll be using. +void Scanner::ScanBlockScalar() { + std::string scalar; - params.eatLeadingWhitespace = false; - params.trimTrailingSpaces = false; - params.onTabInIndentation = THROW; + ScanScalarParams params; + params.indent = 1; + params.detectIndent = true; - scalar = ScanScalar(INPUT, params); + // eat block indicator ('|' or '>') + Mark mark = INPUT.mark(); + char indicator = INPUT.get(); + params.fold = (indicator == Keys::FoldedScalar ? FOLD_BLOCK : DONT_FOLD); - // simple keys always ok after block scalars (since we're gonna start a new line anyways) - m_simpleKeyAllowed = true; - m_canBeJSONFlow = false; + // eat chomping/indentation indicators + params.chomp = CLIP; + int n = Exp::Chomp().Match(INPUT); + for (int i = 0; i < n; i++) { + char ch = INPUT.get(); + if (ch == '+') + params.chomp = KEEP; + else if (ch == '-') + params.chomp = STRIP; + else if (Exp::Digit().Matches(ch)) { + if (ch == '0') + throw ParserException(INPUT.mark(), ErrorMsg::ZERO_INDENT_IN_BLOCK); - Token token(Token::NON_PLAIN_SCALAR, mark); - token.value = scalar; - m_tokens.push(token); - } + params.indent = ch - '0'; + params.detectIndent = false; + } + } + + // now eat whitespace + while (Exp::Blank().Matches(INPUT)) + INPUT.eat(1); + + // and comments to the end of the line + if (Exp::Comment().Matches(INPUT)) + while (INPUT && !Exp::Break().Matches(INPUT)) + INPUT.eat(1); + + // if it's not a line break, then we ran into a bad character inline + if (INPUT && !Exp::Break().Matches(INPUT)) + throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_BLOCK); + + // set the initial indentation + if (GetTopIndent() >= 0) + params.indent += GetTopIndent(); + + params.eatLeadingWhitespace = false; + params.trimTrailingSpaces = false; + params.onTabInIndentation = THROW; + + scalar = ScanScalar(INPUT, params); + + // simple keys always ok after block scalars (since we're gonna start a new + // line anyways) + m_simpleKeyAllowed = true; + m_canBeJSONFlow = false; + + Token token(Token::NON_PLAIN_SCALAR, mark); + token.value = scalar; + m_tokens.push(token); } +} diff --git a/src/yamlcpp/setting.h b/src/yamlcpp/setting.h --- a/src/yamlcpp/setting.h +++ b/src/yamlcpp/setting.h @@ -1,105 +1,95 @@ #ifndef SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include #include #include "yaml-cpp/noncopyable.h" -namespace LHAPDF_YAML -{ - class SettingChangeBase; +namespace YAML { +class SettingChangeBase; - template - class Setting - { - public: - Setting(): m_value() {} +template +class Setting { + public: + Setting() : m_value() {} - const T get() const { return m_value; } - std::unique_ptr set(const T& value); - void restore(const Setting& oldSetting) { - m_value = oldSetting.get(); - } + const T get() const { return m_value; } + std::unique_ptr set(const T& value); + void restore(const Setting& oldSetting) { m_value = oldSetting.get(); } - private: - T m_value; - }; + private: + T m_value; +}; - class SettingChangeBase - { - public: - virtual ~SettingChangeBase() {} - virtual void pop() = 0; - }; +class SettingChangeBase { + public: + virtual ~SettingChangeBase() {} + virtual void pop() = 0; +}; - template - class SettingChange: public SettingChangeBase - { - public: - SettingChange(Setting *pSetting): m_pCurSetting(pSetting) { - // copy old setting to save its state - m_oldSetting = *pSetting; - } +template +class SettingChange : public SettingChangeBase { + public: + SettingChange(Setting* pSetting) : m_pCurSetting(pSetting) { + // copy old setting to save its state + m_oldSetting = *pSetting; + } - virtual void pop() { - m_pCurSetting->restore(m_oldSetting); - } + virtual void pop() { m_pCurSetting->restore(m_oldSetting); } - private: - Setting *m_pCurSetting; - Setting m_oldSetting; - }; + private: + Setting* m_pCurSetting; + Setting m_oldSetting; +}; - template - inline std::unique_ptr Setting::set(const T& value) { - std::unique_ptr pChange(new SettingChange (this)); - m_value = value; - return pChange; - } - - class SettingChanges: private noncopyable - { - public: - SettingChanges() {} - ~SettingChanges() { clear(); } - - void clear() { - restore(); - - for(setting_changes::const_iterator it=m_settingChanges.begin();it!=m_settingChanges.end();++it) - delete *it; - m_settingChanges.clear(); - } - - void restore() { - for(setting_changes::const_iterator it=m_settingChanges.begin();it!=m_settingChanges.end();++it) - (*it)->pop(); - } - - void push(std::unique_ptr pSettingChange) { - m_settingChanges.push_back(pSettingChange.release()); - } - - // like std::auto_ptr - assignment is transfer of ownership - SettingChanges& operator = (SettingChanges& rhs) { - if(this == &rhs) - return *this; - - clear(); - m_settingChanges = rhs.m_settingChanges; - rhs.m_settingChanges.clear(); - return *this; - } - - private: - typedef std::vector setting_changes; - setting_changes m_settingChanges; - }; +template +inline std::unique_ptr Setting::set(const T& value) { + std::unique_ptr pChange(new SettingChange(this)); + m_value = value; + return pChange; } -#endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +class SettingChanges : private noncopyable { + public: + SettingChanges() {} + ~SettingChanges() { clear(); } + + void clear() { + restore(); + m_settingChanges.clear(); + } + + void restore() { + for (setting_changes::const_iterator it = m_settingChanges.begin(); + it != m_settingChanges.end(); ++it) + (*it)->pop(); + } + + void push(std::unique_ptr pSettingChange) { + m_settingChanges.push_back(std::move(pSettingChange)); + } + + // like std::unique_ptr - assignment is transfer of ownership + SettingChanges& operator=(SettingChanges&& rhs) { + if (this == &rhs) + return *this; + + clear(); + std::swap(m_settingChanges, rhs.m_settingChanges); + + return *this; + } + + private: + typedef std::vector> setting_changes; + setting_changes m_settingChanges; +}; +} + +#endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/simplekey.cpp b/src/yamlcpp/simplekey.cpp --- a/src/yamlcpp/simplekey.cpp +++ b/src/yamlcpp/simplekey.cpp @@ -1,139 +1,128 @@ #include "scanner.h" #include "token.h" -#include "yaml-cpp/exceptions.h" -#include "exp.h" -namespace LHAPDF_YAML -{ - Scanner::SimpleKey::SimpleKey(const Mark& mark_, int flowLevel_) - : mark(mark_), flowLevel(flowLevel_), pIndent(0), pMapStart(0), pKey(0) - { - } +namespace YAML { +struct Mark; - void Scanner::SimpleKey::Validate() - { - // Note: pIndent will *not* be garbage here; - // we "garbage collect" them so we can - // always refer to them - if(pIndent) - pIndent->status = IndentMarker::VALID; - if(pMapStart) - pMapStart->status = Token::VALID; - if(pKey) - pKey->status = Token::VALID; - } +Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_) + : mark(mark_), flowLevel(flowLevel_), pIndent(0), pMapStart(0), pKey(0) {} - void Scanner::SimpleKey::Invalidate() - { - if(pIndent) - pIndent->status = IndentMarker::INVALID; - if(pMapStart) - pMapStart->status = Token::INVALID; - if(pKey) - pKey->status = Token::INVALID; - } - - // CanInsertPotentialSimpleKey - bool Scanner::CanInsertPotentialSimpleKey() const - { - if(!m_simpleKeyAllowed) - return false; - - return !ExistsActiveSimpleKey(); - } - - // ExistsActiveSimpleKey - // . Returns true if there's a potential simple key at our flow level - // (there's allowed at most one per flow level, i.e., at the start of the flow start token) - bool Scanner::ExistsActiveSimpleKey() const - { - if(m_simpleKeys.empty()) - return false; - - const SimpleKey& key = m_simpleKeys.top(); - return key.flowLevel == GetFlowLevel(); - } - - // InsertPotentialSimpleKey - // . If we can, add a potential simple key to the queue, - // and save it on a stack. - void Scanner::InsertPotentialSimpleKey() - { - if(!CanInsertPotentialSimpleKey()) - return; - - SimpleKey key(INPUT.mark(), GetFlowLevel()); - - // first add a map start, if necessary - if(InBlockContext()) { - key.pIndent = PushIndentTo(INPUT.column(), IndentMarker::MAP); - if(key.pIndent) { - key.pIndent->status = IndentMarker::UNKNOWN; - key.pMapStart = key.pIndent->pStartToken; - key.pMapStart->status = Token::UNVERIFIED; - } - } - - // then add the (now unverified) key - m_tokens.push(Token(Token::KEY, INPUT.mark())); - key.pKey = &m_tokens.back(); - key.pKey->status = Token::UNVERIFIED; - - m_simpleKeys.push(key); - } - - // InvalidateSimpleKey - // . Automatically invalidate the simple key in our flow level - void Scanner::InvalidateSimpleKey() - { - if(m_simpleKeys.empty()) - return; - - // grab top key - SimpleKey& key = m_simpleKeys.top(); - if(key.flowLevel != GetFlowLevel()) - return; - - key.Invalidate(); - m_simpleKeys.pop(); - } - - // VerifySimpleKey - // . Determines whether the latest simple key to be added is valid, - // and if so, makes it valid. - bool Scanner::VerifySimpleKey() - { - if(m_simpleKeys.empty()) - return false; - - // grab top key - SimpleKey key = m_simpleKeys.top(); - - // only validate if we're in the correct flow level - if(key.flowLevel != GetFlowLevel()) - return false; - - m_simpleKeys.pop(); - - bool isValid = true; - - // needs to be less than 1024 characters and inline - if(INPUT.line() != key.mark.line || INPUT.pos() - key.mark.pos > 1024) - isValid = false; - - // invalidate key - if(isValid) - key.Validate(); - else - key.Invalidate(); - - return isValid; - } - - void Scanner::PopAllSimpleKeys() - { - while(!m_simpleKeys.empty()) - m_simpleKeys.pop(); - } +void Scanner::SimpleKey::Validate() { + // Note: pIndent will *not* be garbage here; + // we "garbage collect" them so we can + // always refer to them + if (pIndent) + pIndent->status = IndentMarker::VALID; + if (pMapStart) + pMapStart->status = Token::VALID; + if (pKey) + pKey->status = Token::VALID; } +void Scanner::SimpleKey::Invalidate() { + if (pIndent) + pIndent->status = IndentMarker::INVALID; + if (pMapStart) + pMapStart->status = Token::INVALID; + if (pKey) + pKey->status = Token::INVALID; +} + +// CanInsertPotentialSimpleKey +bool Scanner::CanInsertPotentialSimpleKey() const { + if (!m_simpleKeyAllowed) + return false; + + return !ExistsActiveSimpleKey(); +} + +// ExistsActiveSimpleKey +// . Returns true if there's a potential simple key at our flow level +// (there's allowed at most one per flow level, i.e., at the start of the flow +// start token) +bool Scanner::ExistsActiveSimpleKey() const { + if (m_simpleKeys.empty()) + return false; + + const SimpleKey& key = m_simpleKeys.top(); + return key.flowLevel == GetFlowLevel(); +} + +// InsertPotentialSimpleKey +// . If we can, add a potential simple key to the queue, +// and save it on a stack. +void Scanner::InsertPotentialSimpleKey() { + if (!CanInsertPotentialSimpleKey()) + return; + + SimpleKey key(INPUT.mark(), GetFlowLevel()); + + // first add a map start, if necessary + if (InBlockContext()) { + key.pIndent = PushIndentTo(INPUT.column(), IndentMarker::MAP); + if (key.pIndent) { + key.pIndent->status = IndentMarker::UNKNOWN; + key.pMapStart = key.pIndent->pStartToken; + key.pMapStart->status = Token::UNVERIFIED; + } + } + + // then add the (now unverified) key + m_tokens.push(Token(Token::KEY, INPUT.mark())); + key.pKey = &m_tokens.back(); + key.pKey->status = Token::UNVERIFIED; + + m_simpleKeys.push(key); +} + +// InvalidateSimpleKey +// . Automatically invalidate the simple key in our flow level +void Scanner::InvalidateSimpleKey() { + if (m_simpleKeys.empty()) + return; + + // grab top key + SimpleKey& key = m_simpleKeys.top(); + if (key.flowLevel != GetFlowLevel()) + return; + + key.Invalidate(); + m_simpleKeys.pop(); +} + +// VerifySimpleKey +// . Determines whether the latest simple key to be added is valid, +// and if so, makes it valid. +bool Scanner::VerifySimpleKey() { + if (m_simpleKeys.empty()) + return false; + + // grab top key + SimpleKey key = m_simpleKeys.top(); + + // only validate if we're in the correct flow level + if (key.flowLevel != GetFlowLevel()) + return false; + + m_simpleKeys.pop(); + + bool isValid = true; + + // needs to be less than 1024 characters and inline + if (INPUT.line() != key.mark.line || INPUT.pos() - key.mark.pos > 1024) + isValid = false; + + // invalidate key + if (isValid) + key.Validate(); + else + key.Invalidate(); + + return isValid; +} + +void Scanner::PopAllSimpleKeys() { + while (!m_simpleKeys.empty()) + m_simpleKeys.pop(); +} +} diff --git a/src/yamlcpp/singledocparser.cpp b/src/yamlcpp/singledocparser.cpp --- a/src/yamlcpp/singledocparser.cpp +++ b/src/yamlcpp/singledocparser.cpp @@ -1,381 +1,414 @@ +#include +#include +#include + +#include "collectionstack.h" // IWYU pragma: keep +#include "scanner.h" #include "singledocparser.h" -#include "collectionstack.h" -#include "directives.h" -#include "yaml-cpp/eventhandler.h" -#include "yaml-cpp/exceptions.h" -#include "scanner.h" #include "tag.h" #include "token.h" -#include -#include -#include +#include "yaml-cpp/emitterstyle.h" +#include "yaml-cpp/eventhandler.h" +#include "yaml-cpp/exceptions.h" // IWYU pragma: keep +#include "yaml-cpp/mark.h" +#include "yaml-cpp/null.h" -namespace LHAPDF_YAML -{ - SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives): m_scanner(scanner), m_directives(directives), m_pCollectionStack(new CollectionStack), m_curAnchor(0) - { - } +namespace YAML { +SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives) + : m_scanner(scanner), + m_directives(directives), + m_pCollectionStack(new CollectionStack), + m_curAnchor(0) {} - SingleDocParser::~SingleDocParser() - { - } +SingleDocParser::~SingleDocParser() {} - // HandleDocument - // . Handles the next document - // . Throws a ParserException on error. - void SingleDocParser::HandleDocument(EventHandler& eventHandler) - { - assert(!m_scanner.empty()); // guaranteed that there are tokens - assert(!m_curAnchor); +// HandleDocument +// . Handles the next document +// . Throws a ParserException on error. +void SingleDocParser::HandleDocument(EventHandler& eventHandler) { + assert(!m_scanner.empty()); // guaranteed that there are tokens + assert(!m_curAnchor); - eventHandler.OnDocumentStart(m_scanner.peek().mark); - - // eat doc start - if(m_scanner.peek().type == Token::DOC_START) - m_scanner.pop(); - - // recurse! - HandleNode(eventHandler); - - eventHandler.OnDocumentEnd(); - - // and finally eat any doc ends we see - while(!m_scanner.empty() && m_scanner.peek().type == Token::DOC_END) - m_scanner.pop(); - } - - void SingleDocParser::HandleNode(EventHandler& eventHandler) - { - // an empty node *is* a possibility - if(m_scanner.empty()) { - eventHandler.OnNull(Mark::null(), NullAnchor); - return; - } - - // save location - Mark mark = m_scanner.peek().mark; - - // special case: a value node by itself must be a map, with no header - if(m_scanner.peek().type == Token::VALUE) { - eventHandler.OnMapStart(mark, "", NullAnchor); - HandleMap(eventHandler); - eventHandler.OnMapEnd(); - return; - } - - // special case: an alias node - if(m_scanner.peek().type == Token::ALIAS) { - eventHandler.OnAlias(mark, LookupAnchor(mark, m_scanner.peek().value)); - m_scanner.pop(); - return; - } - - std::string tag; - anchor_t anchor; - ParseProperties(tag, anchor); - - const Token& token = m_scanner.peek(); - - // add non-specific tags - if(tag.empty()) - tag = (token.type == Token::NON_PLAIN_SCALAR ? "!" : "?"); - - // now split based on what kind of node we should be - switch(token.type) { - case Token::PLAIN_SCALAR: - case Token::NON_PLAIN_SCALAR: - eventHandler.OnScalar(mark, tag, anchor, token.value); - m_scanner.pop(); - return; - case Token::FLOW_SEQ_START: - case Token::BLOCK_SEQ_START: - eventHandler.OnSequenceStart(mark, tag, anchor); - HandleSequence(eventHandler); - eventHandler.OnSequenceEnd(); - return; - case Token::FLOW_MAP_START: - case Token::BLOCK_MAP_START: - eventHandler.OnMapStart(mark, tag, anchor); - HandleMap(eventHandler); - eventHandler.OnMapEnd(); - return; - case Token::KEY: - // compact maps can only go in a flow sequence - if(m_pCollectionStack->GetCurCollectionType() == CollectionType::FlowSeq) { - eventHandler.OnMapStart(mark, tag, anchor); - HandleMap(eventHandler); - eventHandler.OnMapEnd(); - return; - } - break; - default: - break; - } - - if(tag == "?") - eventHandler.OnNull(mark, anchor); - else - eventHandler.OnScalar(mark, tag, anchor, ""); - } - - void SingleDocParser::HandleSequence(EventHandler& eventHandler) - { - // split based on start token - switch(m_scanner.peek().type) { - case Token::BLOCK_SEQ_START: HandleBlockSequence(eventHandler); break; - case Token::FLOW_SEQ_START: HandleFlowSequence(eventHandler); break; - default: break; - } - } - - void SingleDocParser::HandleBlockSequence(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::BlockSeq); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_SEQ); - - Token token = m_scanner.peek(); - if(token.type != Token::BLOCK_ENTRY && token.type != Token::BLOCK_SEQ_END) - throw ParserException(token.mark, ErrorMsg::END_OF_SEQ); - - m_scanner.pop(); - if(token.type == Token::BLOCK_SEQ_END) - break; - - // check for null - if(!m_scanner.empty()) { - const Token& token = m_scanner.peek(); - if(token.type == Token::BLOCK_ENTRY || token.type == Token::BLOCK_SEQ_END) { - eventHandler.OnNull(token.mark, NullAnchor); - continue; - } - } - - HandleNode(eventHandler); - } - - m_pCollectionStack->PopCollectionType(CollectionType::BlockSeq); - } - - void SingleDocParser::HandleFlowSequence(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::FlowSeq); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_SEQ_FLOW); - - // first check for end - if(m_scanner.peek().type == Token::FLOW_SEQ_END) { - m_scanner.pop(); - break; - } - - // then read the node - HandleNode(eventHandler); - - // now eat the separator (or could be a sequence end, which we ignore - but if it's neither, then it's a bad node) - Token& token = m_scanner.peek(); - if(token.type == Token::FLOW_ENTRY) - m_scanner.pop(); - else if(token.type != Token::FLOW_SEQ_END) - throw ParserException(token.mark, ErrorMsg::END_OF_SEQ_FLOW); - } - - m_pCollectionStack->PopCollectionType(CollectionType::FlowSeq); - } - - void SingleDocParser::HandleMap(EventHandler& eventHandler) - { - // split based on start token - switch(m_scanner.peek().type) { - case Token::BLOCK_MAP_START: HandleBlockMap(eventHandler); break; - case Token::FLOW_MAP_START: HandleFlowMap(eventHandler); break; - case Token::KEY: HandleCompactMap(eventHandler); break; - case Token::VALUE: HandleCompactMapWithNoKey(eventHandler); break; - default: break; - } - } - - void SingleDocParser::HandleBlockMap(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::BlockMap); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_MAP); - - Token token = m_scanner.peek(); - if(token.type != Token::KEY && token.type != Token::VALUE && token.type != Token::BLOCK_MAP_END) - throw ParserException(token.mark, ErrorMsg::END_OF_MAP); - - if(token.type == Token::BLOCK_MAP_END) { - m_scanner.pop(); - break; - } - - // grab key (if non-null) - if(token.type == Token::KEY) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - - // now grab value (optional) - if(!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - } - - m_pCollectionStack->PopCollectionType(CollectionType::BlockMap); - } - - void SingleDocParser::HandleFlowMap(EventHandler& eventHandler) - { - // eat start token - m_scanner.pop(); - m_pCollectionStack->PushCollectionType(CollectionType::FlowMap); - - while(1) { - if(m_scanner.empty()) - throw ParserException(Mark::null(), ErrorMsg::END_OF_MAP_FLOW); - - Token& token = m_scanner.peek(); - // first check for end - if(token.type == Token::FLOW_MAP_END) { - m_scanner.pop(); - break; - } - - // grab key (if non-null) - if(token.type == Token::KEY) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - - // now grab value (optional) - if(!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(token.mark, NullAnchor); - } - - // now eat the separator (or could be a map end, which we ignore - but if it's neither, then it's a bad node) - Token& nextToken = m_scanner.peek(); - if(nextToken.type == Token::FLOW_ENTRY) - m_scanner.pop(); - else if(nextToken.type != Token::FLOW_MAP_END) - throw ParserException(nextToken.mark, ErrorMsg::END_OF_MAP_FLOW); - } - - m_pCollectionStack->PopCollectionType(CollectionType::FlowMap); - } - - // . Single "key: value" pair in a flow sequence - void SingleDocParser::HandleCompactMap(EventHandler& eventHandler) - { - m_pCollectionStack->PushCollectionType(CollectionType::CompactMap); - - // grab key - Mark mark = m_scanner.peek().mark; - m_scanner.pop(); - HandleNode(eventHandler); - - // now grab value (optional) - if(!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { - m_scanner.pop(); - HandleNode(eventHandler); - } else { - eventHandler.OnNull(mark, NullAnchor); - } - - m_pCollectionStack->PopCollectionType(CollectionType::CompactMap); - } - - // . Single ": value" pair in a flow sequence - void SingleDocParser::HandleCompactMapWithNoKey(EventHandler& eventHandler) - { - m_pCollectionStack->PushCollectionType(CollectionType::CompactMap); - - // null key - eventHandler.OnNull(m_scanner.peek().mark, NullAnchor); - - // grab value - m_scanner.pop(); - HandleNode(eventHandler); - - m_pCollectionStack->PopCollectionType(CollectionType::CompactMap); - } - - // ParseProperties - // . Grabs any tag or anchor tokens and deals with them. - void SingleDocParser::ParseProperties(std::string& tag, anchor_t& anchor) - { - tag.clear(); - anchor = NullAnchor; - - while(1) { - if(m_scanner.empty()) - return; - - switch(m_scanner.peek().type) { - case Token::TAG: ParseTag(tag); break; - case Token::ANCHOR: ParseAnchor(anchor); break; - default: return; - } - } - } - - void SingleDocParser::ParseTag(std::string& tag) - { - Token& token = m_scanner.peek(); - if(!tag.empty()) - throw ParserException(token.mark, ErrorMsg::MULTIPLE_TAGS); - - Tag tagInfo(token); - tag = tagInfo.Translate(m_directives); - m_scanner.pop(); - } - - void SingleDocParser::ParseAnchor(anchor_t& anchor) - { - Token& token = m_scanner.peek(); - if(anchor) - throw ParserException(token.mark, ErrorMsg::MULTIPLE_ANCHORS); - - anchor = RegisterAnchor(token.value); - m_scanner.pop(); - } - - anchor_t SingleDocParser::RegisterAnchor(const std::string& name) - { - if(name.empty()) - return NullAnchor; - - return m_anchors[name] = ++m_curAnchor; - } - - anchor_t SingleDocParser::LookupAnchor(const Mark& mark, const std::string& name) const - { - Anchors::const_iterator it = m_anchors.find(name); - if(it == m_anchors.end()) - throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR); - - return it->second; - } + eventHandler.OnDocumentStart(m_scanner.peek().mark); + + // eat doc start + if (m_scanner.peek().type == Token::DOC_START) + m_scanner.pop(); + + // recurse! + HandleNode(eventHandler); + + eventHandler.OnDocumentEnd(); + + // and finally eat any doc ends we see + while (!m_scanner.empty() && m_scanner.peek().type == Token::DOC_END) + m_scanner.pop(); } + +void SingleDocParser::HandleNode(EventHandler& eventHandler) { + // an empty node *is* a possibility + if (m_scanner.empty()) { + eventHandler.OnNull(m_scanner.mark(), NullAnchor); + return; + } + + // save location + Mark mark = m_scanner.peek().mark; + + // special case: a value node by itself must be a map, with no header + if (m_scanner.peek().type == Token::VALUE) { + eventHandler.OnMapStart(mark, "?", NullAnchor, EmitterStyle::Default); + HandleMap(eventHandler); + eventHandler.OnMapEnd(); + return; + } + + // special case: an alias node + if (m_scanner.peek().type == Token::ALIAS) { + eventHandler.OnAlias(mark, LookupAnchor(mark, m_scanner.peek().value)); + m_scanner.pop(); + return; + } + + std::string tag; + anchor_t anchor; + ParseProperties(tag, anchor); + + const Token& token = m_scanner.peek(); + + if (token.type == Token::PLAIN_SCALAR && IsNullString(token.value)) { + eventHandler.OnNull(mark, anchor); + m_scanner.pop(); + return; + } + + // add non-specific tags + if (tag.empty()) + tag = (token.type == Token::NON_PLAIN_SCALAR ? "!" : "?"); + + // now split based on what kind of node we should be + switch (token.type) { + case Token::PLAIN_SCALAR: + case Token::NON_PLAIN_SCALAR: + eventHandler.OnScalar(mark, tag, anchor, token.value); + m_scanner.pop(); + return; + case Token::FLOW_SEQ_START: + eventHandler.OnSequenceStart(mark, tag, anchor, EmitterStyle::Flow); + HandleSequence(eventHandler); + eventHandler.OnSequenceEnd(); + return; + case Token::BLOCK_SEQ_START: + eventHandler.OnSequenceStart(mark, tag, anchor, EmitterStyle::Block); + HandleSequence(eventHandler); + eventHandler.OnSequenceEnd(); + return; + case Token::FLOW_MAP_START: + eventHandler.OnMapStart(mark, tag, anchor, EmitterStyle::Flow); + HandleMap(eventHandler); + eventHandler.OnMapEnd(); + return; + case Token::BLOCK_MAP_START: + eventHandler.OnMapStart(mark, tag, anchor, EmitterStyle::Block); + HandleMap(eventHandler); + eventHandler.OnMapEnd(); + return; + case Token::KEY: + // compact maps can only go in a flow sequence + if (m_pCollectionStack->GetCurCollectionType() == + CollectionType::FlowSeq) { + eventHandler.OnMapStart(mark, tag, anchor, EmitterStyle::Flow); + HandleMap(eventHandler); + eventHandler.OnMapEnd(); + return; + } + break; + default: + break; + } + + if (tag == "?") + eventHandler.OnNull(mark, anchor); + else + eventHandler.OnScalar(mark, tag, anchor, ""); +} + +void SingleDocParser::HandleSequence(EventHandler& eventHandler) { + // split based on start token + switch (m_scanner.peek().type) { + case Token::BLOCK_SEQ_START: + HandleBlockSequence(eventHandler); + break; + case Token::FLOW_SEQ_START: + HandleFlowSequence(eventHandler); + break; + default: + break; + } +} + +void SingleDocParser::HandleBlockSequence(EventHandler& eventHandler) { + // eat start token + m_scanner.pop(); + m_pCollectionStack->PushCollectionType(CollectionType::BlockSeq); + + while (1) { + if (m_scanner.empty()) + throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_SEQ); + + Token token = m_scanner.peek(); + if (token.type != Token::BLOCK_ENTRY && token.type != Token::BLOCK_SEQ_END) + throw ParserException(token.mark, ErrorMsg::END_OF_SEQ); + + m_scanner.pop(); + if (token.type == Token::BLOCK_SEQ_END) + break; + + // check for null + if (!m_scanner.empty()) { + const Token& token = m_scanner.peek(); + if (token.type == Token::BLOCK_ENTRY || + token.type == Token::BLOCK_SEQ_END) { + eventHandler.OnNull(token.mark, NullAnchor); + continue; + } + } + + HandleNode(eventHandler); + } + + m_pCollectionStack->PopCollectionType(CollectionType::BlockSeq); +} + +void SingleDocParser::HandleFlowSequence(EventHandler& eventHandler) { + // eat start token + m_scanner.pop(); + m_pCollectionStack->PushCollectionType(CollectionType::FlowSeq); + + while (1) { + if (m_scanner.empty()) + throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_SEQ_FLOW); + + // first check for end + if (m_scanner.peek().type == Token::FLOW_SEQ_END) { + m_scanner.pop(); + break; + } + + // then read the node + HandleNode(eventHandler); + + if (m_scanner.empty()) + throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_SEQ_FLOW); + + // now eat the separator (or could be a sequence end, which we ignore - but + // if it's neither, then it's a bad node) + Token& token = m_scanner.peek(); + if (token.type == Token::FLOW_ENTRY) + m_scanner.pop(); + else if (token.type != Token::FLOW_SEQ_END) + throw ParserException(token.mark, ErrorMsg::END_OF_SEQ_FLOW); + } + + m_pCollectionStack->PopCollectionType(CollectionType::FlowSeq); +} + +void SingleDocParser::HandleMap(EventHandler& eventHandler) { + // split based on start token + switch (m_scanner.peek().type) { + case Token::BLOCK_MAP_START: + HandleBlockMap(eventHandler); + break; + case Token::FLOW_MAP_START: + HandleFlowMap(eventHandler); + break; + case Token::KEY: + HandleCompactMap(eventHandler); + break; + case Token::VALUE: + HandleCompactMapWithNoKey(eventHandler); + break; + default: + break; + } +} + +void SingleDocParser::HandleBlockMap(EventHandler& eventHandler) { + // eat start token + m_scanner.pop(); + m_pCollectionStack->PushCollectionType(CollectionType::BlockMap); + + while (1) { + if (m_scanner.empty()) + throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_MAP); + + Token token = m_scanner.peek(); + if (token.type != Token::KEY && token.type != Token::VALUE && + token.type != Token::BLOCK_MAP_END) + throw ParserException(token.mark, ErrorMsg::END_OF_MAP); + + if (token.type == Token::BLOCK_MAP_END) { + m_scanner.pop(); + break; + } + + // grab key (if non-null) + if (token.type == Token::KEY) { + m_scanner.pop(); + HandleNode(eventHandler); + } else { + eventHandler.OnNull(token.mark, NullAnchor); + } + + // now grab value (optional) + if (!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { + m_scanner.pop(); + HandleNode(eventHandler); + } else { + eventHandler.OnNull(token.mark, NullAnchor); + } + } + + m_pCollectionStack->PopCollectionType(CollectionType::BlockMap); +} + +void SingleDocParser::HandleFlowMap(EventHandler& eventHandler) { + // eat start token + m_scanner.pop(); + m_pCollectionStack->PushCollectionType(CollectionType::FlowMap); + + while (1) { + if (m_scanner.empty()) + throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_MAP_FLOW); + + Token& token = m_scanner.peek(); + const Mark mark = token.mark; + // first check for end + if (token.type == Token::FLOW_MAP_END) { + m_scanner.pop(); + break; + } + + // grab key (if non-null) + if (token.type == Token::KEY) { + m_scanner.pop(); + HandleNode(eventHandler); + } else { + eventHandler.OnNull(mark, NullAnchor); + } + + // now grab value (optional) + if (!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { + m_scanner.pop(); + HandleNode(eventHandler); + } else { + eventHandler.OnNull(mark, NullAnchor); + } + + if (m_scanner.empty()) + throw ParserException(m_scanner.mark(), ErrorMsg::END_OF_MAP_FLOW); + + // now eat the separator (or could be a map end, which we ignore - but if + // it's neither, then it's a bad node) + Token& nextToken = m_scanner.peek(); + if (nextToken.type == Token::FLOW_ENTRY) + m_scanner.pop(); + else if (nextToken.type != Token::FLOW_MAP_END) + throw ParserException(nextToken.mark, ErrorMsg::END_OF_MAP_FLOW); + } + + m_pCollectionStack->PopCollectionType(CollectionType::FlowMap); +} + +// . Single "key: value" pair in a flow sequence +void SingleDocParser::HandleCompactMap(EventHandler& eventHandler) { + m_pCollectionStack->PushCollectionType(CollectionType::CompactMap); + + // grab key + Mark mark = m_scanner.peek().mark; + m_scanner.pop(); + HandleNode(eventHandler); + + // now grab value (optional) + if (!m_scanner.empty() && m_scanner.peek().type == Token::VALUE) { + m_scanner.pop(); + HandleNode(eventHandler); + } else { + eventHandler.OnNull(mark, NullAnchor); + } + + m_pCollectionStack->PopCollectionType(CollectionType::CompactMap); +} + +// . Single ": value" pair in a flow sequence +void SingleDocParser::HandleCompactMapWithNoKey(EventHandler& eventHandler) { + m_pCollectionStack->PushCollectionType(CollectionType::CompactMap); + + // null key + eventHandler.OnNull(m_scanner.peek().mark, NullAnchor); + + // grab value + m_scanner.pop(); + HandleNode(eventHandler); + + m_pCollectionStack->PopCollectionType(CollectionType::CompactMap); +} + +// ParseProperties +// . Grabs any tag or anchor tokens and deals with them. +void SingleDocParser::ParseProperties(std::string& tag, anchor_t& anchor) { + tag.clear(); + anchor = NullAnchor; + + while (1) { + if (m_scanner.empty()) + return; + + switch (m_scanner.peek().type) { + case Token::TAG: + ParseTag(tag); + break; + case Token::ANCHOR: + ParseAnchor(anchor); + break; + default: + return; + } + } +} + +void SingleDocParser::ParseTag(std::string& tag) { + Token& token = m_scanner.peek(); + if (!tag.empty()) + throw ParserException(token.mark, ErrorMsg::MULTIPLE_TAGS); + + Tag tagInfo(token); + tag = tagInfo.Translate(m_directives); + m_scanner.pop(); +} + +void SingleDocParser::ParseAnchor(anchor_t& anchor) { + Token& token = m_scanner.peek(); + if (anchor) + throw ParserException(token.mark, ErrorMsg::MULTIPLE_ANCHORS); + + anchor = RegisterAnchor(token.value); + m_scanner.pop(); +} + +anchor_t SingleDocParser::RegisterAnchor(const std::string& name) { + if (name.empty()) + return NullAnchor; + + return m_anchors[name] = ++m_curAnchor; +} + +anchor_t SingleDocParser::LookupAnchor(const Mark& mark, + const std::string& name) const { + Anchors::const_iterator it = m_anchors.find(name); + if (it == m_anchors.end()) + throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR); + + return it->second; +} +} diff --git a/src/yamlcpp/singledocparser.h b/src/yamlcpp/singledocparser.h --- a/src/yamlcpp/singledocparser.h +++ b/src/yamlcpp/singledocparser.h @@ -1,65 +1,65 @@ #ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include +#include +#include #include "yaml-cpp/anchor.h" #include "yaml-cpp/noncopyable.h" -#include -#include -#include -namespace LHAPDF_YAML -{ - struct Directives; - struct Mark; - struct Token; - class CollectionStack; - class EventHandler; - class Node; - class Scanner; +namespace YAML { +class CollectionStack; +class EventHandler; +class Node; +class Scanner; +struct Directives; +struct Mark; +struct Token; - class SingleDocParser: private noncopyable - { - public: - SingleDocParser(Scanner& scanner, const Directives& directives); - ~SingleDocParser(); +class SingleDocParser : private noncopyable { + public: + SingleDocParser(Scanner& scanner, const Directives& directives); + ~SingleDocParser(); - void HandleDocument(EventHandler& eventHandler); + void HandleDocument(EventHandler& eventHandler); - private: - void HandleNode(EventHandler& eventHandler); + private: + void HandleNode(EventHandler& eventHandler); - void HandleSequence(EventHandler& eventHandler); - void HandleBlockSequence(EventHandler& eventHandler); - void HandleFlowSequence(EventHandler& eventHandler); + void HandleSequence(EventHandler& eventHandler); + void HandleBlockSequence(EventHandler& eventHandler); + void HandleFlowSequence(EventHandler& eventHandler); - void HandleMap(EventHandler& eventHandler); - void HandleBlockMap(EventHandler& eventHandler); - void HandleFlowMap(EventHandler& eventHandler); - void HandleCompactMap(EventHandler& eventHandler); - void HandleCompactMapWithNoKey(EventHandler& eventHandler); + void HandleMap(EventHandler& eventHandler); + void HandleBlockMap(EventHandler& eventHandler); + void HandleFlowMap(EventHandler& eventHandler); + void HandleCompactMap(EventHandler& eventHandler); + void HandleCompactMapWithNoKey(EventHandler& eventHandler); - void ParseProperties(std::string& tag, anchor_t& anchor); - void ParseTag(std::string& tag); - void ParseAnchor(anchor_t& anchor); + void ParseProperties(std::string& tag, anchor_t& anchor); + void ParseTag(std::string& tag); + void ParseAnchor(anchor_t& anchor); - anchor_t RegisterAnchor(const std::string& name); - anchor_t LookupAnchor(const Mark& mark, const std::string& name) const; + anchor_t RegisterAnchor(const std::string& name); + anchor_t LookupAnchor(const Mark& mark, const std::string& name) const; - private: - Scanner& m_scanner; - const Directives& m_directives; - std::unique_ptr m_pCollectionStack; + private: + Scanner& m_scanner; + const Directives& m_directives; + std::unique_ptr m_pCollectionStack; - typedef std::map Anchors; - Anchors m_anchors; + typedef std::map Anchors; + Anchors m_anchors; - anchor_t m_curAnchor; - }; + anchor_t m_curAnchor; +}; } -#endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/stream.cpp b/src/yamlcpp/stream.cpp --- a/src/yamlcpp/stream.cpp +++ b/src/yamlcpp/stream.cpp @@ -1,448 +1,448 @@ +#include + #include "stream.h" -#include -#include "exp.h" #ifndef YAML_PREFETCH_SIZE #define YAML_PREFETCH_SIZE 2048 #endif -#define S_ARRAY_SIZE( A ) (sizeof(A)/sizeof(*(A))) -#define S_ARRAY_END( A ) ((A) + S_ARRAY_SIZE(A)) +#define S_ARRAY_SIZE(A) (sizeof(A) / sizeof(*(A))) +#define S_ARRAY_END(A) ((A) + S_ARRAY_SIZE(A)) #define CP_REPLACEMENT_CHARACTER (0xFFFD) -namespace LHAPDF_YAML -{ - enum UtfIntroState { - uis_start, - uis_utfbe_b1, - uis_utf32be_b2, - uis_utf32be_bom3, - uis_utf32be, - uis_utf16be, - uis_utf16be_bom1, - uis_utfle_bom1, - uis_utf16le_bom2, - uis_utf32le_bom3, - uis_utf16le, - uis_utf32le, - uis_utf8_imp, - uis_utf16le_imp, - uis_utf32le_imp3, - uis_utf8_bom1, - uis_utf8_bom2, - uis_utf8, - uis_error - }; +namespace YAML { +enum UtfIntroState { + uis_start, + uis_utfbe_b1, + uis_utf32be_b2, + uis_utf32be_bom3, + uis_utf32be, + uis_utf16be, + uis_utf16be_bom1, + uis_utfle_bom1, + uis_utf16le_bom2, + uis_utf32le_bom3, + uis_utf16le, + uis_utf32le, + uis_utf8_imp, + uis_utf16le_imp, + uis_utf32le_imp3, + uis_utf8_bom1, + uis_utf8_bom2, + uis_utf8, + uis_error +}; - enum UtfIntroCharType { - uict00, - uictBB, - uictBF, - uictEF, - uictFE, - uictFF, - uictAscii, - uictOther, - uictMax - }; +enum UtfIntroCharType { + uict00, + uictBB, + uictBF, + uictEF, + uictFE, + uictFF, + uictAscii, + uictOther, + uictMax +}; - static bool s_introFinalState[] = { - false, //uis_start - false, //uis_utfbe_b1 - false, //uis_utf32be_b2 - false, //uis_utf32be_bom3 - true, //uis_utf32be - true, //uis_utf16be - false, //uis_utf16be_bom1 - false, //uis_utfle_bom1 - false, //uis_utf16le_bom2 - false, //uis_utf32le_bom3 - true, //uis_utf16le - true, //uis_utf32le - false, //uis_utf8_imp - false, //uis_utf16le_imp - false, //uis_utf32le_imp3 - false, //uis_utf8_bom1 - false, //uis_utf8_bom2 - true, //uis_utf8 - true, //uis_error - }; +static bool s_introFinalState[] = { + false, // uis_start + false, // uis_utfbe_b1 + false, // uis_utf32be_b2 + false, // uis_utf32be_bom3 + true, // uis_utf32be + true, // uis_utf16be + false, // uis_utf16be_bom1 + false, // uis_utfle_bom1 + false, // uis_utf16le_bom2 + false, // uis_utf32le_bom3 + true, // uis_utf16le + true, // uis_utf32le + false, // uis_utf8_imp + false, // uis_utf16le_imp + false, // uis_utf32le_imp3 + false, // uis_utf8_bom1 + false, // uis_utf8_bom2 + true, // uis_utf8 + true, // uis_error +}; - static UtfIntroState s_introTransitions[][uictMax] = { - // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther - {uis_utfbe_b1, uis_utf8, uis_utf8, uis_utf8_bom1, uis_utf16be_bom1, uis_utfle_bom1, uis_utf8_imp, uis_utf8}, - {uis_utf32be_b2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16be, uis_utf8}, - {uis_utf32be, uis_utf8, uis_utf8, uis_utf8, uis_utf32be_bom3, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf32be, uis_utf8, uis_utf8}, - {uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be}, - {uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16be, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16le_bom2, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf32le_bom3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le}, - {uis_utf16le_imp, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf32le_imp3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, - {uis_utf8, uis_utf8_bom2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8}, - }; +static UtfIntroState s_introTransitions[][uictMax] = { + // uict00, uictBB, uictBF, uictEF, + // uictFE, uictFF, uictAscii, uictOther + {uis_utfbe_b1, uis_utf8, uis_utf8, uis_utf8_bom1, uis_utf16be_bom1, + uis_utfle_bom1, uis_utf8_imp, uis_utf8}, + {uis_utf32be_b2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, + uis_utf16be, uis_utf8}, + {uis_utf32be, uis_utf8, uis_utf8, uis_utf8, uis_utf32be_bom3, uis_utf8, + uis_utf8, uis_utf8}, + {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf32be, uis_utf8, + uis_utf8}, + {uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, + uis_utf32be, uis_utf32be, uis_utf32be}, + {uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, + uis_utf16be, uis_utf16be, uis_utf16be}, + {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16be, uis_utf8, + uis_utf8}, + {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16le_bom2, uis_utf8, + uis_utf8, uis_utf8}, + {uis_utf32le_bom3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, + uis_utf16le, uis_utf16le, uis_utf16le}, + {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, + uis_utf16le, uis_utf16le, uis_utf16le}, + {uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, + uis_utf16le, uis_utf16le, uis_utf16le}, + {uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, + uis_utf32le, uis_utf32le, uis_utf32le}, + {uis_utf16le_imp, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, + uis_utf8, uis_utf8}, + {uis_utf32le_imp3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, + uis_utf16le, uis_utf16le, uis_utf16le}, + {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, + uis_utf16le, uis_utf16le, uis_utf16le}, + {uis_utf8, uis_utf8_bom2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, + uis_utf8}, + {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, + uis_utf8}, + {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, + uis_utf8}, +}; - static char s_introUngetCount[][uictMax] = { - // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther - {0, 1, 1, 0, 0, 0, 0, 1}, - {0, 2, 2, 2, 2, 2, 2, 2}, - {3, 3, 3, 3, 0, 3, 3, 3}, - {4, 4, 4, 4, 4, 0, 4, 4}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {2, 2, 2, 2, 2, 0, 2, 2}, - {2, 2, 2, 2, 0, 2, 2, 2}, - {0, 1, 1, 1, 1, 1, 1, 1}, - {0, 2, 2, 2, 2, 2, 2, 2}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1}, - {0, 2, 2, 2, 2, 2, 2, 2}, - {0, 3, 3, 3, 3, 3, 3, 3}, - {4, 4, 4, 4, 4, 4, 4, 4}, - {2, 0, 2, 2, 2, 2, 2, 2}, - {3, 3, 0, 3, 3, 3, 3, 3}, - {1, 1, 1, 1, 1, 1, 1, 1}, - }; +static char s_introUngetCount[][uictMax] = { + // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther + {0, 1, 1, 0, 0, 0, 0, 1}, + {0, 2, 2, 2, 2, 2, 2, 2}, + {3, 3, 3, 3, 0, 3, 3, 3}, + {4, 4, 4, 4, 4, 0, 4, 4}, + {1, 1, 1, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 1}, + {2, 2, 2, 2, 2, 0, 2, 2}, + {2, 2, 2, 2, 0, 2, 2, 2}, + {0, 1, 1, 1, 1, 1, 1, 1}, + {0, 2, 2, 2, 2, 2, 2, 2}, + {1, 1, 1, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 1}, + {0, 2, 2, 2, 2, 2, 2, 2}, + {0, 3, 3, 3, 3, 3, 3, 3}, + {4, 4, 4, 4, 4, 4, 4, 4}, + {2, 0, 2, 2, 2, 2, 2, 2}, + {3, 3, 0, 3, 3, 3, 3, 3}, + {1, 1, 1, 1, 1, 1, 1, 1}, +}; - inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) - { - if (std::istream::traits_type::eof() == ch) { - return uictOther; - } +inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) { + if (std::istream::traits_type::eof() == ch) { + return uictOther; + } - switch (ch) { - case 0: return uict00; - case 0xBB: return uictBB; - case 0xBF: return uictBF; - case 0xEF: return uictEF; - case 0xFE: return uictFE; - case 0xFF: return uictFF; - } + switch (ch) { + case 0: + return uict00; + case 0xBB: + return uictBB; + case 0xBF: + return uictBF; + case 0xEF: + return uictEF; + case 0xFE: + return uictFE; + case 0xFF: + return uictFF; + } - if ((ch > 0) && (ch < 0xFF)) { - return uictAscii; - } + if ((ch > 0) && (ch < 0xFF)) { + return uictAscii; + } - return uictOther; - } + return uictOther; +} - inline char Utf8Adjust(unsigned long ch, unsigned char lead_bits, unsigned char rshift) - { - const unsigned char header = ((1 << lead_bits) - 1) << (8 - lead_bits); - const unsigned char mask = (0xFF >> (lead_bits + 1)); - return static_cast(static_cast( - header | ((ch >> rshift) & mask) - )); - } +inline char Utf8Adjust(unsigned long ch, unsigned char lead_bits, + unsigned char rshift) { + const unsigned char header = ((1 << lead_bits) - 1) << (8 - lead_bits); + const unsigned char mask = (0xFF >> (lead_bits + 1)); + return static_cast( + static_cast(header | ((ch >> rshift) & mask))); +} - inline void QueueUnicodeCodepoint(std::deque& q, unsigned long ch) - { - // We are not allowed to queue the Stream::eof() codepoint, so - // replace it with CP_REPLACEMENT_CHARACTER - if (static_cast(Stream::eof()) == ch) - { - ch = CP_REPLACEMENT_CHARACTER; - } +inline void QueueUnicodeCodepoint(std::deque& q, unsigned long ch) { + // We are not allowed to queue the Stream::eof() codepoint, so + // replace it with CP_REPLACEMENT_CHARACTER + if (static_cast(Stream::eof()) == ch) { + ch = CP_REPLACEMENT_CHARACTER; + } - if (ch < 0x80) - { - q.push_back(Utf8Adjust(ch, 0, 0)); - } - else if (ch < 0x800) - { - q.push_back(Utf8Adjust(ch, 2, 6)); - q.push_back(Utf8Adjust(ch, 1, 0)); - } - else if (ch < 0x10000) - { - q.push_back(Utf8Adjust(ch, 3, 12)); - q.push_back(Utf8Adjust(ch, 1, 6)); - q.push_back(Utf8Adjust(ch, 1, 0)); - } - else - { - q.push_back(Utf8Adjust(ch, 4, 18)); - q.push_back(Utf8Adjust(ch, 1, 12)); - q.push_back(Utf8Adjust(ch, 1, 6)); - q.push_back(Utf8Adjust(ch, 1, 0)); - } - } + if (ch < 0x80) { + q.push_back(Utf8Adjust(ch, 0, 0)); + } else if (ch < 0x800) { + q.push_back(Utf8Adjust(ch, 2, 6)); + q.push_back(Utf8Adjust(ch, 1, 0)); + } else if (ch < 0x10000) { + q.push_back(Utf8Adjust(ch, 3, 12)); + q.push_back(Utf8Adjust(ch, 1, 6)); + q.push_back(Utf8Adjust(ch, 1, 0)); + } else { + q.push_back(Utf8Adjust(ch, 4, 18)); + q.push_back(Utf8Adjust(ch, 1, 12)); + q.push_back(Utf8Adjust(ch, 1, 6)); + q.push_back(Utf8Adjust(ch, 1, 0)); + } +} - Stream::Stream(std::istream& input) - : m_input(input), - m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]), - m_nPrefetchedAvailable(0), m_nPrefetchedUsed(0) - { - typedef std::istream::traits_type char_traits; +Stream::Stream(std::istream& input) + : m_input(input), + m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]), + m_nPrefetchedAvailable(0), + m_nPrefetchedUsed(0) { + typedef std::istream::traits_type char_traits; - if(!input) - return; + if (!input) + return; - // Determine (or guess) the character-set by reading the BOM, if any. See - // the YAML specification for the determination algorithm. - char_traits::int_type intro[4]; - int nIntroUsed = 0; - UtfIntroState state = uis_start; - for(; !s_introFinalState[state]; ) { - std::istream::int_type ch = input.get(); - intro[nIntroUsed++] = ch; - UtfIntroCharType charType = IntroCharTypeOf(ch); - UtfIntroState newState = s_introTransitions[state][charType]; - int nUngets = s_introUngetCount[state][charType]; - if(nUngets > 0) { - input.clear(); - for(; nUngets > 0; --nUngets) { - if(char_traits::eof() != intro[--nIntroUsed]) - input.putback(char_traits::to_char_type(intro[nIntroUsed])); - } - } - state = newState; - } + // Determine (or guess) the character-set by reading the BOM, if any. See + // the YAML specification for the determination algorithm. + char_traits::int_type intro[4]; + int nIntroUsed = 0; + UtfIntroState state = uis_start; + for (; !s_introFinalState[state];) { + std::istream::int_type ch = input.get(); + intro[nIntroUsed++] = ch; + UtfIntroCharType charType = IntroCharTypeOf(ch); + UtfIntroState newState = s_introTransitions[state][charType]; + int nUngets = s_introUngetCount[state][charType]; + if (nUngets > 0) { + input.clear(); + for (; nUngets > 0; --nUngets) { + if (char_traits::eof() != intro[--nIntroUsed]) + input.putback(char_traits::to_char_type(intro[nIntroUsed])); + } + } + state = newState; + } - switch (state) { - case uis_utf8: m_charSet = utf8; break; - case uis_utf16le: m_charSet = utf16le; break; - case uis_utf16be: m_charSet = utf16be; break; - case uis_utf32le: m_charSet = utf32le; break; - case uis_utf32be: m_charSet = utf32be; break; - default: m_charSet = utf8; break; - } + switch (state) { + case uis_utf8: + m_charSet = utf8; + break; + case uis_utf16le: + m_charSet = utf16le; + break; + case uis_utf16be: + m_charSet = utf16be; + break; + case uis_utf32le: + m_charSet = utf32le; + break; + case uis_utf32be: + m_charSet = utf32be; + break; + default: + m_charSet = utf8; + break; + } - ReadAheadTo(0); - } + ReadAheadTo(0); +} - Stream::~Stream() - { - delete[] m_pPrefetched; - } +Stream::~Stream() { delete[] m_pPrefetched; } - char Stream::peek() const - { - if (m_readahead.empty()) - { - return Stream::eof(); - } +char Stream::peek() const { + if (m_readahead.empty()) { + return Stream::eof(); + } - return m_readahead[0]; - } - - Stream::operator bool() const - { - return m_input.good() || (!m_readahead.empty() && m_readahead[0] != Stream::eof()); - } + return m_readahead[0]; +} - // get - // . Extracts a character from the stream and updates our position - char Stream::get() - { - char ch = peek(); - AdvanceCurrent(); - m_mark.column++; - - if(ch == '\n') { - m_mark.column = 0; - m_mark.line++; - } - - return ch; - } +Stream::operator bool() const { + return m_input.good() || + (!m_readahead.empty() && m_readahead[0] != Stream::eof()); +} - // get - // . Extracts 'n' characters from the stream and updates our position - std::string Stream::get(int n) - { - std::string ret; - ret.reserve(n); - for(int i=0;i i; - } +void Stream::AdvanceCurrent() { + if (!m_readahead.empty()) { + m_readahead.pop_front(); + m_mark.pos++; + } - void Stream::StreamInUtf8() const - { - unsigned char b = GetNextByte(); - if (m_input.good()) - { - m_readahead.push_back(b); - } - } + ReadAheadTo(0); +} - void Stream::StreamInUtf16() const - { - unsigned long ch = 0; - unsigned char bytes[2]; - int nBigEnd = (m_charSet == utf16be) ? 0 : 1; +bool Stream::_ReadAheadTo(size_t i) const { + while (m_input.good() && (m_readahead.size() <= i)) { + switch (m_charSet) { + case utf8: + StreamInUtf8(); + break; + case utf16le: + StreamInUtf16(); + break; + case utf16be: + StreamInUtf16(); + break; + case utf32le: + StreamInUtf32(); + break; + case utf32be: + StreamInUtf32(); + break; + } + } - bytes[0] = GetNextByte(); - bytes[1] = GetNextByte(); - if (!m_input.good()) - { - return; - } - ch = (static_cast(bytes[nBigEnd]) << 8) | - static_cast(bytes[1 ^ nBigEnd]); + // signal end of stream + if (!m_input.good()) + m_readahead.push_back(Stream::eof()); - if (ch >= 0xDC00 && ch < 0xE000) - { - // Trailing (low) surrogate...ugh, wrong order - QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); - return; - } - else if (ch >= 0xD800 && ch < 0xDC00) - { - // ch is a leading (high) surrogate + return m_readahead.size() > i; +} - // Four byte UTF-8 code point +void Stream::StreamInUtf8() const { + unsigned char b = GetNextByte(); + if (m_input.good()) { + m_readahead.push_back(b); + } +} - // Read the trailing (low) surrogate - for (;;) - { - bytes[0] = GetNextByte(); - bytes[1] = GetNextByte(); - if (!m_input.good()) - { - QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); - return; - } - unsigned long chLow = (static_cast(bytes[nBigEnd]) << 8) | - static_cast(bytes[1 ^ nBigEnd]); - if (chLow < 0xDC00 || ch >= 0xE000) - { - // Trouble...not a low surrogate. Dump a REPLACEMENT CHARACTER into the stream. - QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); +void Stream::StreamInUtf16() const { + unsigned long ch = 0; + unsigned char bytes[2]; + int nBigEnd = (m_charSet == utf16be) ? 0 : 1; - // Deal with the next UTF-16 unit - if (chLow < 0xD800 || ch >= 0xE000) - { - // Easiest case: queue the codepoint and return - QueueUnicodeCodepoint(m_readahead, ch); - return; - } - else - { - // Start the loop over with the new high surrogate - ch = chLow; - continue; - } - } + bytes[0] = GetNextByte(); + bytes[1] = GetNextByte(); + if (!m_input.good()) { + return; + } + ch = (static_cast(bytes[nBigEnd]) << 8) | + static_cast(bytes[1 ^ nBigEnd]); - // Select the payload bits from the high surrogate - ch &= 0x3FF; - ch <<= 10; + if (ch >= 0xDC00 && ch < 0xE000) { + // Trailing (low) surrogate...ugh, wrong order + QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); + return; + } else if (ch >= 0xD800 && ch < 0xDC00) { + // ch is a leading (high) surrogate - // Include bits from low surrogate - ch |= (chLow & 0x3FF); + // Four byte UTF-8 code point - // Add the surrogacy offset - ch += 0x10000; - } - } + // Read the trailing (low) surrogate + for (;;) { + bytes[0] = GetNextByte(); + bytes[1] = GetNextByte(); + if (!m_input.good()) { + QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); + return; + } + unsigned long chLow = (static_cast(bytes[nBigEnd]) << 8) | + static_cast(bytes[1 ^ nBigEnd]); + if (chLow < 0xDC00 || chLow >= 0xE000) { + // Trouble...not a low surrogate. Dump a REPLACEMENT CHARACTER into the + // stream. + QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); - QueueUnicodeCodepoint(m_readahead, ch); - } + // Deal with the next UTF-16 unit + if (chLow < 0xD800 || chLow >= 0xE000) { + // Easiest case: queue the codepoint and return + QueueUnicodeCodepoint(m_readahead, ch); + return; + } else { + // Start the loop over with the new high surrogate + ch = chLow; + continue; + } + } - inline char* ReadBuffer(unsigned char* pBuffer) - { - return reinterpret_cast(pBuffer); - } + // Select the payload bits from the high surrogate + ch &= 0x3FF; + ch <<= 10; - unsigned char Stream::GetNextByte() const - { - if (m_nPrefetchedUsed >= m_nPrefetchedAvailable) - { - std::streambuf *pBuf = m_input.rdbuf(); - m_nPrefetchedAvailable = pBuf->sgetn(ReadBuffer(m_pPrefetched), - YAML_PREFETCH_SIZE); - m_nPrefetchedUsed = 0; - if (!m_nPrefetchedAvailable) - { - m_input.setstate(std::ios_base::eofbit); - } + // Include bits from low surrogate + ch |= (chLow & 0x3FF); - if (0 == m_nPrefetchedAvailable) - { - return 0; - } - } + // Add the surrogacy offset + ch += 0x10000; + break; + } + } - return m_pPrefetched[m_nPrefetchedUsed++]; - } + QueueUnicodeCodepoint(m_readahead, ch); +} - void Stream::StreamInUtf32() const - { - static int indexes[2][4] = { - {3, 2, 1, 0}, - {0, 1, 2, 3} - }; +inline char* ReadBuffer(unsigned char* pBuffer) { + return reinterpret_cast(pBuffer); +} - unsigned long ch = 0; - unsigned char bytes[4]; - int* pIndexes = (m_charSet == utf32be) ? indexes[1] : indexes[0]; +unsigned char Stream::GetNextByte() const { + if (m_nPrefetchedUsed >= m_nPrefetchedAvailable) { + std::streambuf* pBuf = m_input.rdbuf(); + m_nPrefetchedAvailable = static_cast( + pBuf->sgetn(ReadBuffer(m_pPrefetched), YAML_PREFETCH_SIZE)); + m_nPrefetchedUsed = 0; + if (!m_nPrefetchedAvailable) { + m_input.setstate(std::ios_base::eofbit); + } - bytes[0] = GetNextByte(); - bytes[1] = GetNextByte(); - bytes[2] = GetNextByte(); - bytes[3] = GetNextByte(); - if (!m_input.good()) - { - return; - } + if (0 == m_nPrefetchedAvailable) { + return 0; + } + } - for (int i = 0; i < 4; ++i) - { - ch <<= 8; - ch |= bytes[pIndexes[i]]; - } + return m_pPrefetched[m_nPrefetchedUsed++]; +} - QueueUnicodeCodepoint(m_readahead, ch); - } +void Stream::StreamInUtf32() const { + static int indexes[2][4] = {{3, 2, 1, 0}, {0, 1, 2, 3}}; + + unsigned long ch = 0; + unsigned char bytes[4]; + int* pIndexes = (m_charSet == utf32be) ? indexes[1] : indexes[0]; + + bytes[0] = GetNextByte(); + bytes[1] = GetNextByte(); + bytes[2] = GetNextByte(); + bytes[3] = GetNextByte(); + if (!m_input.good()) { + return; + } + + for (int i = 0; i < 4; ++i) { + ch <<= 8; + ch |= bytes[pIndexes[i]]; + } + + QueueUnicodeCodepoint(m_readahead, ch); } +} diff --git a/src/yamlcpp/stream.h b/src/yamlcpp/stream.h --- a/src/yamlcpp/stream.h +++ b/src/yamlcpp/stream.h @@ -1,79 +1,76 @@ #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include "yaml-cpp/noncopyable.h" #include "yaml-cpp/mark.h" #include #include #include #include #include #include -namespace LHAPDF_YAML -{ - class Stream: private noncopyable - { - public: - friend class StreamCharSource; - - Stream(std::istream& input); - ~Stream(); +namespace YAML { +class Stream : private noncopyable { + public: + friend class StreamCharSource; - operator bool() const; - bool operator !() const { return !static_cast (*this); } + Stream(std::istream& input); + ~Stream(); - char peek() const; - char get(); - std::string get(int n); - void eat(int n = 1); + operator bool() const; + bool operator!() const { return !static_cast(*this); } - static char eof() { return 0x04; } - - const Mark mark() const { return m_mark; } - int pos() const { return m_mark.pos; } - int line() const { return m_mark.line; } - int column() const { return m_mark.column; } - void ResetColumn() { m_mark.column = 0; } + char peek() const; + char get(); + std::string get(int n); + void eat(int n = 1); - private: - enum CharacterSet {utf8, utf16le, utf16be, utf32le, utf32be}; + static char eof() { return 0x04; } - std::istream& m_input; - Mark m_mark; - - CharacterSet m_charSet; - mutable std::deque m_readahead; - unsigned char* const m_pPrefetched; - mutable size_t m_nPrefetchedAvailable; - mutable size_t m_nPrefetchedUsed; - - void AdvanceCurrent(); - char CharAt(size_t i) const; - bool ReadAheadTo(size_t i) const; - bool _ReadAheadTo(size_t i) const; - void StreamInUtf8() const; - void StreamInUtf16() const; - void StreamInUtf32() const; - unsigned char GetNextByte() const; - }; + const Mark mark() const { return m_mark; } + int pos() const { return m_mark.pos; } + int line() const { return m_mark.line; } + int column() const { return m_mark.column; } + void ResetColumn() { m_mark.column = 0; } - // CharAt - // . Unchecked access - inline char Stream::CharAt(size_t i) const { - return m_readahead[i]; - } - - inline bool Stream::ReadAheadTo(size_t i) const { - if(m_readahead.size() > i) - return true; - return _ReadAheadTo(i); - } + private: + enum CharacterSet { utf8, utf16le, utf16be, utf32le, utf32be }; + + std::istream& m_input; + Mark m_mark; + + CharacterSet m_charSet; + mutable std::deque m_readahead; + unsigned char* const m_pPrefetched; + mutable size_t m_nPrefetchedAvailable; + mutable size_t m_nPrefetchedUsed; + + void AdvanceCurrent(); + char CharAt(size_t i) const; + bool ReadAheadTo(size_t i) const; + bool _ReadAheadTo(size_t i) const; + void StreamInUtf8() const; + void StreamInUtf16() const; + void StreamInUtf32() const; + unsigned char GetNextByte() const; +}; + +// CharAt +// . Unchecked access +inline char Stream::CharAt(size_t i) const { return m_readahead[i]; } + +inline bool Stream::ReadAheadTo(size_t i) const { + if (m_readahead.size() > i) + return true; + return _ReadAheadTo(i); +} } -#endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/streamcharsource.h b/src/yamlcpp/streamcharsource.h --- a/src/yamlcpp/streamcharsource.h +++ b/src/yamlcpp/streamcharsource.h @@ -1,48 +1,48 @@ #ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include "yaml-cpp/noncopyable.h" #include -namespace LHAPDF_YAML -{ - class StreamCharSource - { - public: - StreamCharSource(const Stream& stream): m_offset(0), m_stream(stream) {} - StreamCharSource(const StreamCharSource& source): m_offset(source.m_offset), m_stream(source.m_stream) {} - ~StreamCharSource() {} +namespace YAML { +class StreamCharSource { + public: + StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {} + StreamCharSource(const StreamCharSource& source) + : m_offset(source.m_offset), m_stream(source.m_stream) {} + ~StreamCharSource() {} - operator bool() const; - char operator [] (std::size_t i) const { return m_stream.CharAt(m_offset + i); } - bool operator !() const { return !static_cast(*this); } + operator bool() const; + char operator[](std::size_t i) const { return m_stream.CharAt(m_offset + i); } + bool operator!() const { return !static_cast(*this); } - const StreamCharSource operator + (int i) const; - - private: - std::size_t m_offset; - const Stream& m_stream; + const StreamCharSource operator+(int i) const; - StreamCharSource& operator = (const StreamCharSource&); // non-assignable - }; - - inline StreamCharSource::operator bool() const { - return m_stream.ReadAheadTo(m_offset); - } - - inline const StreamCharSource StreamCharSource::operator + (int i) const { - StreamCharSource source(*this); - if(static_cast (source.m_offset) + i >= 0) - source.m_offset += i; - else - source.m_offset = 0; - return source; - } + private: + std::size_t m_offset; + const Stream& m_stream; + + StreamCharSource& operator=(const StreamCharSource&); // non-assignable +}; + +inline StreamCharSource::operator bool() const { + return m_stream.ReadAheadTo(m_offset); } -#endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +inline const StreamCharSource StreamCharSource::operator+(int i) const { + StreamCharSource source(*this); + if (static_cast(source.m_offset) + i >= 0) + source.m_offset += i; + else + source.m_offset = 0; + return source; +} +} + +#endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/stringsource.h b/src/yamlcpp/stringsource.h --- a/src/yamlcpp/stringsource.h +++ b/src/yamlcpp/stringsource.h @@ -1,47 +1,48 @@ #ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include -namespace LHAPDF_YAML -{ - class StringCharSource - { - public: - StringCharSource(const char *str, std::size_t size): m_str(str), m_size(size), m_offset(0) {} +namespace YAML { +class StringCharSource { + public: + StringCharSource(const char* str, std::size_t size) + : m_str(str), m_size(size), m_offset(0) {} - operator bool() const { return m_offset < m_size; } - char operator [] (std::size_t i) const { return m_str[m_offset + i]; } - bool operator !() const { return !static_cast(*this); } + operator bool() const { return m_offset < m_size; } + char operator[](std::size_t i) const { return m_str[m_offset + i]; } + bool operator!() const { return !static_cast(*this); } - const StringCharSource operator + (int i) const { - StringCharSource source(*this); - if(static_cast (source.m_offset) + i >= 0) - source.m_offset += i; - else - source.m_offset = 0; - return source; - } - - StringCharSource& operator ++ () { - ++m_offset; - return *this; - } - - StringCharSource& operator += (std::size_t offset) { - m_offset += offset; - return *this; - } - private: - const char *m_str; - std::size_t m_size; - std::size_t m_offset; - }; + const StringCharSource operator+(int i) const { + StringCharSource source(*this); + if (static_cast(source.m_offset) + i >= 0) + source.m_offset += i; + else + source.m_offset = 0; + return source; + } + + StringCharSource& operator++() { + ++m_offset; + return *this; + } + + StringCharSource& operator+=(std::size_t offset) { + m_offset += offset; + return *this; + } + + private: + const char* m_str; + std::size_t m_size; + std::size_t m_offset; +}; } -#endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/tag.cpp b/src/yamlcpp/tag.cpp --- a/src/yamlcpp/tag.cpp +++ b/src/yamlcpp/tag.cpp @@ -1,52 +1,49 @@ -#include "tag.h" -#include "directives.h" -#include "token.h" #include #include -namespace LHAPDF_YAML -{ - Tag::Tag(const Token& token): type(static_cast(token.data)) - { - switch(type) { - case VERBATIM: - value = token.value; - break; - case PRIMARY_HANDLE: - value = token.value; - break; - case SECONDARY_HANDLE: - value = token.value; - break; - case NAMED_HANDLE: - handle = token.value; - value = token.params[0]; - break; - case NON_SPECIFIC: - break; - default: - assert(false); - } - } +#include "directives.h" // IWYU pragma: keep +#include "tag.h" +#include "token.h" - const std::string Tag::Translate(const Directives& directives) - { - switch(type) { - case VERBATIM: - return value; - case PRIMARY_HANDLE: - return directives.TranslateTagHandle("!") + value; - case SECONDARY_HANDLE: - return directives.TranslateTagHandle("!!") + value; - case NAMED_HANDLE: - return directives.TranslateTagHandle("!" + handle + "!") + value; - case NON_SPECIFIC: - // TODO: - return "!"; - default: - assert(false); - } - throw std::runtime_error("yaml-cpp: internal error, bad tag type"); - } +namespace YAML { +Tag::Tag(const Token& token) : type(static_cast(token.data)) { + switch (type) { + case VERBATIM: + value = token.value; + break; + case PRIMARY_HANDLE: + value = token.value; + break; + case SECONDARY_HANDLE: + value = token.value; + break; + case NAMED_HANDLE: + handle = token.value; + value = token.params[0]; + break; + case NON_SPECIFIC: + break; + default: + assert(false); + } } +const std::string Tag::Translate(const Directives& directives) { + switch (type) { + case VERBATIM: + return value; + case PRIMARY_HANDLE: + return directives.TranslateTagHandle("!") + value; + case SECONDARY_HANDLE: + return directives.TranslateTagHandle("!!") + value; + case NAMED_HANDLE: + return directives.TranslateTagHandle("!" + handle + "!") + value; + case NON_SPECIFIC: + // TODO: + return "!"; + default: + assert(false); + } + throw std::runtime_error("yaml-cpp: internal error, bad tag type"); +} +} diff --git a/src/yamlcpp/tag.h b/src/yamlcpp/tag.h --- a/src/yamlcpp/tag.h +++ b/src/yamlcpp/tag.h @@ -1,28 +1,33 @@ #ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include -namespace LHAPDF_YAML -{ - struct Token; - struct Directives; +namespace YAML { +struct Directives; +struct Token; - struct Tag { - enum TYPE { - VERBATIM, PRIMARY_HANDLE, SECONDARY_HANDLE, NAMED_HANDLE, NON_SPECIFIC - }; - - Tag(const Token& token); - const std::string Translate(const Directives& directives); - - TYPE type; - std::string handle, value; - }; +struct Tag { + enum TYPE { + VERBATIM, + PRIMARY_HANDLE, + SECONDARY_HANDLE, + NAMED_HANDLE, + NON_SPECIFIC + }; + + Tag(const Token& token); + const std::string Translate(const Directives& directives); + + TYPE type; + std::string handle, value; +}; } -#endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/token.h b/src/yamlcpp/token.h --- a/src/yamlcpp/token.h +++ b/src/yamlcpp/token.h @@ -1,85 +1,69 @@ #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include "yaml-cpp/mark.h" #include #include #include -namespace LHAPDF_YAML -{ - const std::string TokenNames[] = { - "DIRECTIVE", - "DOC_START", - "DOC_END", - "BLOCK_SEQ_START", - "BLOCK_MAP_START", - "BLOCK_SEQ_END", - "BLOCK_MAP_END", - "BLOCK_ENTRY", - "FLOW_SEQ_START", - "FLOW_MAP_START", - "FLOW_SEQ_END", - "FLOW_MAP_END", - "FLOW_MAP_COMPACT", - "FLOW_ENTRY", - "KEY", - "VALUE", - "ANCHOR", - "ALIAS", - "TAG", - "SCALAR" - }; +namespace YAML { +const std::string TokenNames[] = { + "DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", "BLOCK_MAP_START", + "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", "FLOW_SEQ_START", + "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", "FLOW_MAP_COMPACT", + "FLOW_ENTRY", "KEY", "VALUE", "ANCHOR", "ALIAS", "TAG", "SCALAR"}; - struct Token { - // enums - enum STATUS { VALID, INVALID, UNVERIFIED }; - enum TYPE { - DIRECTIVE, - DOC_START, - DOC_END, - BLOCK_SEQ_START, - BLOCK_MAP_START, - BLOCK_SEQ_END, - BLOCK_MAP_END, - BLOCK_ENTRY, - FLOW_SEQ_START, - FLOW_MAP_START, - FLOW_SEQ_END, - FLOW_MAP_END, - FLOW_MAP_COMPACT, - FLOW_ENTRY, - KEY, - VALUE, - ANCHOR, - ALIAS, - TAG, - PLAIN_SCALAR, - NON_PLAIN_SCALAR - }; +struct Token { + // enums + enum STATUS { VALID, INVALID, UNVERIFIED }; + enum TYPE { + DIRECTIVE, + DOC_START, + DOC_END, + BLOCK_SEQ_START, + BLOCK_MAP_START, + BLOCK_SEQ_END, + BLOCK_MAP_END, + BLOCK_ENTRY, + FLOW_SEQ_START, + FLOW_MAP_START, + FLOW_SEQ_END, + FLOW_MAP_END, + FLOW_MAP_COMPACT, + FLOW_ENTRY, + KEY, + VALUE, + ANCHOR, + ALIAS, + TAG, + PLAIN_SCALAR, + NON_PLAIN_SCALAR + }; - // data - Token(TYPE type_, const Mark& mark_): status(VALID), type(type_), mark(mark_), data(0) {} + // data + Token(TYPE type_, const Mark& mark_) + : status(VALID), type(type_), mark(mark_), data(0) {} - friend std::ostream& operator << (std::ostream& out, const Token& token) { - out << TokenNames[token.type] << std::string(": ") << token.value; - for(std::size_t i=0;i params; - int data; - }; + STATUS status; + TYPE type; + Mark mark; + std::string value; + std::vector params; + int data; +}; } -#endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/aliasmanager.h b/src/yamlcpp/yaml-cpp/aliasmanager.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/aliasmanager.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/anchor.h" -#include - -namespace LHAPDF_YAML -{ - class Node; - - class AliasManager - { - public: - AliasManager(); - - void RegisterReference(const Node& node); - anchor_t LookupAnchor(const Node& node) const; - - private: - anchor_t _CreateNewAnchor(); - - private: - typedef std::map AnchorByIdentity; - AnchorByIdentity m_anchorByIdentity; - - anchor_t m_curAnchor; - }; -} - -#endif // ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/anchor.h b/src/yamlcpp/yaml-cpp/anchor.h --- a/src/yamlcpp/yaml-cpp/anchor.h +++ b/src/yamlcpp/yaml-cpp/anchor.h @@ -1,16 +1,17 @@ #ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include -namespace LHAPDF_YAML -{ - typedef std::size_t anchor_t; - const anchor_t NullAnchor = 0; +namespace YAML { +typedef std::size_t anchor_t; +const anchor_t NullAnchor = 0; } -#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/binary.h b/src/yamlcpp/yaml-cpp/binary.h --- a/src/yamlcpp/yaml-cpp/binary.h +++ b/src/yamlcpp/yaml-cpp/binary.h @@ -1,66 +1,67 @@ #ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include #include -namespace LHAPDF_YAML -{ - class Node; - - std::string EncodeBase64(const unsigned char *data, std::size_t size); - std::vector DecodeBase64(const std::string& input); - - class Binary { - public: - Binary(): m_unownedData(0), m_unownedSize(0) {} - Binary(const unsigned char *data, std::size_t size): m_unownedData(data), m_unownedSize(size) {} - - bool owned() const { return !m_unownedData; } - std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } - const unsigned char *data() const { return owned() ? &m_data[0] : m_unownedData; } - - void swap(std::vector& rhs) { - if(m_unownedData) { - m_data.swap(rhs); - rhs.clear(); - rhs.resize(m_unownedSize); - std::copy(m_unownedData, m_unownedData + m_unownedSize, &rhs[0]); - m_unownedData = 0; - m_unownedSize = 0; - } else { - m_data.swap(rhs); - } - } - - bool operator == (const Binary& rhs) const { - const std::size_t s = size(); - if(s != rhs.size()) - return false; - const unsigned char *d1 = data(); - const unsigned char *d2 = rhs.data(); - for(std::size_t i=0;i m_data; - const unsigned char *m_unownedData; - std::size_t m_unownedSize; - }; - - void operator >> (const Node& node, Binary& binary); +#include "yaml-cpp/dll.h" + +namespace YAML { +YAML_CPP_API std::string EncodeBase64(const unsigned char *data, + std::size_t size); +YAML_CPP_API std::vector DecodeBase64(const std::string &input); + +class YAML_CPP_API Binary { + public: + Binary() : m_unownedData(0), m_unownedSize(0) {} + Binary(const unsigned char *data_, std::size_t size_) + : m_unownedData(data_), m_unownedSize(size_) {} + + bool owned() const { return !m_unownedData; } + std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } + const unsigned char *data() const { + return owned() ? &m_data[0] : m_unownedData; + } + + void swap(std::vector &rhs) { + if (m_unownedData) { + m_data.swap(rhs); + rhs.clear(); + rhs.resize(m_unownedSize); + std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); + m_unownedData = 0; + m_unownedSize = 0; + } else { + m_data.swap(rhs); + } + } + + bool operator==(const Binary &rhs) const { + const std::size_t s = size(); + if (s != rhs.size()) + return false; + const unsigned char *d1 = data(); + const unsigned char *d2 = rhs.data(); + for (std::size_t i = 0; i < s; i++) { + if (*d1++ != *d2++) + return false; + } + return true; + } + + bool operator!=(const Binary &rhs) const { return !(*this == rhs); } + + private: + std::vector m_data; + const unsigned char *m_unownedData; + std::size_t m_unownedSize; +}; } -#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/contrib/anchordict.h b/src/yamlcpp/yaml-cpp/contrib/anchordict.h --- a/src/yamlcpp/yaml-cpp/contrib/anchordict.h +++ b/src/yamlcpp/yaml-cpp/contrib/anchordict.h @@ -1,42 +1,39 @@ #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include #include "../anchor.h" -namespace LHAPDF_YAML -{ - /// AnchorDict - /// . An object that stores and retrieves values correlating to anchor_t - /// values. - /// . Efficient implementation that can make assumptions about how anchor_t - /// values are assigned by the Parser class. - template - class AnchorDict - { - public: - void Register(anchor_t anchor, T value) - { - if (anchor > m_data.size()) - { - m_data.resize(anchor); - } - m_data[anchor - 1] = value; +namespace YAML { +/** + * An object that stores and retrieves values correlating to {@link anchor_t} + * values. + * + *

Efficient implementation that can make assumptions about how + * {@code anchor_t} values are assigned by the {@link Parser} class. + */ +template +class AnchorDict { + public: + void Register(anchor_t anchor, T value) { + if (anchor > m_data.size()) { + m_data.resize(anchor); } - - T Get(anchor_t anchor) const - { - return m_data[anchor - 1]; - } - - private: - std::vector m_data; - }; + m_data[anchor - 1] = value; + } + + T Get(anchor_t anchor) const { return m_data[anchor - 1]; } + + private: + std::vector m_data; +}; } -#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/contrib/graphbuilder.h b/src/yamlcpp/yaml-cpp/contrib/graphbuilder.h --- a/src/yamlcpp/yaml-cpp/contrib/graphbuilder.h +++ b/src/yamlcpp/yaml-cpp/contrib/graphbuilder.h @@ -1,133 +1,149 @@ #ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include "yaml-cpp/mark.h" #include -namespace LHAPDF_YAML -{ - class Parser; - - // GraphBuilderInterface - // . Abstraction of node creation - // . pParentNode is always NULL or the return value of one of the NewXXX() - // functions. - class GraphBuilderInterface - { - public: - // Create and return a new node with a null value. - virtual void *NewNull(const Mark& mark, void *pParentNode) = 0; - - // Create and return a new node with the given tag and value. - virtual void *NewScalar(const Mark& mark, const std::string& tag, void *pParentNode, const std::string& value) = 0; - - // Create and return a new sequence node - virtual void *NewSequence(const Mark& mark, const std::string& tag, void *pParentNode) = 0; - // Add pNode to pSequence. pNode was created with one of the NewXxx() - // functions and pSequence with NewSequence(). - virtual void AppendToSequence(void *pSequence, void *pNode) = 0; - // Note that no moew entries will be added to pSequence - virtual void SequenceComplete(void *pSequence) {(void)pSequence;} - - // Create and return a new map node - virtual void *NewMap(const Mark& mark, const std::string& tag, void *pParentNode) = 0; - // Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode - // were created with one of the NewXxx() methods and pMap with NewMap(). - virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0; - // Note that no more assignments will be made in pMap - virtual void MapComplete(void *pMap) {(void)pMap;} - - // Return the node that should be used in place of an alias referencing - // pNode (pNode by default) - virtual void *AnchorReference(const Mark& mark, void *pNode) {(void)mark; return pNode;} - }; - - // Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines - // Node, Sequence, and Map types. Sequence and Map must derive from Node - // (unless Node is defined as void). Impl must also implement function with - // all of the same names as the virtual functions in GraphBuilderInterface - // -- including the ones with default implementations -- but with the - // prototypes changed to accept an explicit Node*, Sequence*, or Map* where - // appropriate. - template - class GraphBuilder : public GraphBuilderInterface - { - public: - typedef typename Impl::Node Node; - typedef typename Impl::Sequence Sequence; - typedef typename Impl::Map Map; - - GraphBuilder(Impl& impl) : m_impl(impl) - { - Map* pMap = NULL; - Sequence* pSeq = NULL; - Node* pNode = NULL; - - // Type consistency checks - pNode = pMap; - pNode = pSeq; - } - - GraphBuilderInterface& AsBuilderInterface() {return *this;} - - virtual void *NewNull(const Mark& mark, void* pParentNode) { - return CheckType(m_impl.NewNull(mark, AsNode(pParentNode))); - } - - virtual void *NewScalar(const Mark& mark, const std::string& tag, void *pParentNode, const std::string& value) { - return CheckType(m_impl.NewScalar(mark, tag, AsNode(pParentNode), value)); - } - - virtual void *NewSequence(const Mark& mark, const std::string& tag, void *pParentNode) { - return CheckType(m_impl.NewSequence(mark, tag, AsNode(pParentNode))); - } - virtual void AppendToSequence(void *pSequence, void *pNode) { - m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode)); - } - virtual void SequenceComplete(void *pSequence) { - m_impl.SequenceComplete(AsSequence(pSequence)); - } - - virtual void *NewMap(const Mark& mark, const std::string& tag, void *pParentNode) { - return CheckType(m_impl.NewMap(mark, tag, AsNode(pParentNode))); - } - virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) { - m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode)); - } - virtual void MapComplete(void *pMap) { - m_impl.MapComplete(AsMap(pMap)); - } - - virtual void *AnchorReference(const Mark& mark, void *pNode) { - return CheckType(m_impl.AnchorReference(mark, AsNode(pNode))); - } - - private: - Impl& m_impl; - - // Static check for pointer to T - template - static T* CheckType(U* p) {return p;} - - static Node *AsNode(void *pNode) {return static_cast(pNode);} - static Sequence *AsSequence(void *pSeq) {return static_cast(pSeq);} - static Map *AsMap(void *pMap) {return static_cast(pMap);} - }; - - void *BuildGraphOfNextDocument(Parser& parser, GraphBuilderInterface& graphBuilder); - - template - typename Impl::Node *BuildGraphOfNextDocument(Parser& parser, Impl& impl) - { - GraphBuilder graphBuilder(impl); - return static_cast(BuildGraphOfNextDocument( - parser, graphBuilder - )); +namespace YAML { +class Parser; + +// GraphBuilderInterface +// . Abstraction of node creation +// . pParentNode is always NULL or the return value of one of the NewXXX() +// functions. +class GraphBuilderInterface { + public: + virtual ~GraphBuilderInterface() = 0; + + // Create and return a new node with a null value. + virtual void *NewNull(const Mark &mark, void *pParentNode) = 0; + + // Create and return a new node with the given tag and value. + virtual void *NewScalar(const Mark &mark, const std::string &tag, + void *pParentNode, const std::string &value) = 0; + + // Create and return a new sequence node + virtual void *NewSequence(const Mark &mark, const std::string &tag, + void *pParentNode) = 0; + + // Add pNode to pSequence. pNode was created with one of the NewXxx() + // functions and pSequence with NewSequence(). + virtual void AppendToSequence(void *pSequence, void *pNode) = 0; + + // Note that no moew entries will be added to pSequence + virtual void SequenceComplete(void *pSequence) { (void)pSequence; } + + // Create and return a new map node + virtual void *NewMap(const Mark &mark, const std::string &tag, + void *pParentNode) = 0; + + // Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode + // were created with one of the NewXxx() methods and pMap with NewMap(). + virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0; + + // Note that no more assignments will be made in pMap + virtual void MapComplete(void *pMap) { (void)pMap; } + + // Return the node that should be used in place of an alias referencing + // pNode (pNode by default) + virtual void *AnchorReference(const Mark &mark, void *pNode) { + (void)mark; + return pNode; } +}; + +// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines +// Node, Sequence, and Map types. Sequence and Map must derive from Node +// (unless Node is defined as void). Impl must also implement function with +// all of the same names as the virtual functions in GraphBuilderInterface +// -- including the ones with default implementations -- but with the +// prototypes changed to accept an explicit Node*, Sequence*, or Map* where +// appropriate. +template +class GraphBuilder : public GraphBuilderInterface { + public: + typedef typename Impl::Node Node; + typedef typename Impl::Sequence Sequence; + typedef typename Impl::Map Map; + + GraphBuilder(Impl &impl) : m_impl(impl) { + Map *pMap = NULL; + Sequence *pSeq = NULL; + Node *pNode = NULL; + + // Type consistency checks + pNode = pMap; + pNode = pSeq; + } + + GraphBuilderInterface &AsBuilderInterface() { return *this; } + + virtual void *NewNull(const Mark &mark, void *pParentNode) { + return CheckType(m_impl.NewNull(mark, AsNode(pParentNode))); + } + + virtual void *NewScalar(const Mark &mark, const std::string &tag, + void *pParentNode, const std::string &value) { + return CheckType( + m_impl.NewScalar(mark, tag, AsNode(pParentNode), value)); + } + + virtual void *NewSequence(const Mark &mark, const std::string &tag, + void *pParentNode) { + return CheckType( + m_impl.NewSequence(mark, tag, AsNode(pParentNode))); + } + virtual void AppendToSequence(void *pSequence, void *pNode) { + m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode)); + } + virtual void SequenceComplete(void *pSequence) { + m_impl.SequenceComplete(AsSequence(pSequence)); + } + + virtual void *NewMap(const Mark &mark, const std::string &tag, + void *pParentNode) { + return CheckType(m_impl.NewMap(mark, tag, AsNode(pParentNode))); + } + virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) { + m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode)); + } + virtual void MapComplete(void *pMap) { m_impl.MapComplete(AsMap(pMap)); } + + virtual void *AnchorReference(const Mark &mark, void *pNode) { + return CheckType(m_impl.AnchorReference(mark, AsNode(pNode))); + } + + private: + Impl &m_impl; + + // Static check for pointer to T + template + static T *CheckType(U *p) { + return p; + } + + static Node *AsNode(void *pNode) { return static_cast(pNode); } + static Sequence *AsSequence(void *pSeq) { + return static_cast(pSeq); + } + static Map *AsMap(void *pMap) { return static_cast(pMap); } +}; + +void *BuildGraphOfNextDocument(Parser &parser, + GraphBuilderInterface &graphBuilder); + +template +typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) { + GraphBuilder graphBuilder(impl); + return static_cast( + BuildGraphOfNextDocument(parser, graphBuilder)); +} } -#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/conversion.h b/src/yamlcpp/yaml-cpp/conversion.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/conversion.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp/null.h" -#include "yaml-cpp/traits.h" -#include -#include -#include - -namespace LHAPDF_YAML -{ - // traits for conversion - - template - struct is_scalar_convertible { enum { value = is_numeric::value }; }; - - template<> struct is_scalar_convertible { enum { value = true }; }; - template<> struct is_scalar_convertible { enum { value = true }; }; - template<> struct is_scalar_convertible<_Null> { enum { value = true }; }; - - // actual conversion - - inline bool Convert(const std::string& input, std::string& output) { - output = input; - return true; - } - - YAML_CPP_API bool Convert(const std::string& input, bool& output); - YAML_CPP_API bool Convert(const std::string& input, _Null& output); - - inline bool IsInfinity(const std::string& input) { - return input == ".inf" || input == ".Inf" || input == ".INF" || input == "+.inf" || input == "+.Inf" || input == "+.INF"; - } - - inline bool IsNegativeInfinity(const std::string& input) { - return input == "-.inf" || input == "-.Inf" || input == "-.INF"; - } - - inline bool IsNaN(const std::string& input) { - return input == ".nan" || input == ".NaN" || input == ".NAN"; - } - - - template - inline bool Convert(const std::string& input, T& output, typename enable_if >::type * = 0) { - std::stringstream stream(input); - stream.unsetf(std::ios::dec); - if((stream >> output) && (stream >> std::ws).eof()) - return true; - - if(std::numeric_limits::has_infinity) { - if(IsInfinity(input)) { - output = std::numeric_limits::infinity(); - return true; - } else if(IsNegativeInfinity(input)) { - output = -std::numeric_limits::infinity(); - return true; - } - } - - if(std::numeric_limits::has_quiet_NaN && IsNaN(input)) { - output = std::numeric_limits::quiet_NaN(); - return true; - } - - return false; - } -} - -#endif // CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/dll.h b/src/yamlcpp/yaml-cpp/dll.h --- a/src/yamlcpp/yaml-cpp/dll.h +++ b/src/yamlcpp/yaml-cpp/dll.h @@ -1,28 +1,33 @@ #ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the yaml_cpp_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// YAML_CPP_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. +// The following ifdef block is the standard way of creating macros which make +// exporting from a DLL simpler. All files within this DLL are compiled with the +// yaml_cpp_EXPORTS symbol defined on the command line. This symbol should not +// be defined on any project that uses this DLL. This way any other project +// whose source files include this file see YAML_CPP_API functions as being +// imported from a DLL, whereas this DLL sees symbols defined with this macro as +// being exported. #undef YAML_CPP_API -#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined manually) - #ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake or defined manually) - // #pragma message( "Defining YAML_CPP_API for DLL export" ) - #define YAML_CPP_API __declspec(dllexport) - #else // yaml_cpp_EXPORTS - // #pragma message( "Defining YAML_CPP_API for DLL import" ) - #define YAML_CPP_API __declspec(dllimport) - #endif // yaml_cpp_EXPORTS -#else //YAML_CPP_DLL +#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined + // manually) +#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake + // or defined manually) +// #pragma message( "Defining YAML_CPP_API for DLL export" ) +#define YAML_CPP_API __declspec(dllexport) +#else // yaml_cpp_EXPORTS +// #pragma message( "Defining YAML_CPP_API for DLL import" ) +#define YAML_CPP_API __declspec(dllimport) +#endif // yaml_cpp_EXPORTS +#else // YAML_CPP_DLL #define YAML_CPP_API -#endif // YAML_CPP_DLL +#endif // YAML_CPP_DLL -#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/emitfromevents.h b/src/yamlcpp/yaml-cpp/emitfromevents.h --- a/src/yamlcpp/yaml-cpp/emitfromevents.h +++ b/src/yamlcpp/yaml-cpp/emitfromevents.h @@ -1,45 +1,57 @@ #ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif -#include "yaml-cpp/eventhandler.h" #include -namespace LHAPDF_YAML -{ - class Emitter; - - class EmitFromEvents: public EventHandler - { - public: - EmitFromEvents(Emitter& emitter); - - virtual void OnDocumentStart(const Mark& mark); - virtual void OnDocumentEnd(); - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor); - virtual void OnMapEnd(); - - private: - void BeginNode(); - void EmitProps(const std::string& tag, anchor_t anchor); - - private: - Emitter& m_emitter; - - struct State { enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue }; }; - std::stack m_stateStack; - }; +#include "yaml-cpp/anchor.h" +#include "yaml-cpp/emitterstyle.h" +#include "yaml-cpp/eventhandler.h" + +namespace YAML { +struct Mark; +} // namespace YAML + +namespace YAML { +class Emitter; + +class EmitFromEvents : public EventHandler { + public: + EmitFromEvents(Emitter& emitter); + + virtual void OnDocumentStart(const Mark& mark); + virtual void OnDocumentEnd(); + + virtual void OnNull(const Mark& mark, anchor_t anchor); + virtual void OnAlias(const Mark& mark, anchor_t anchor); + virtual void OnScalar(const Mark& mark, const std::string& tag, + anchor_t anchor, const std::string& value); + + virtual void OnSequenceStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style); + virtual void OnSequenceEnd(); + + virtual void OnMapStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style); + virtual void OnMapEnd(); + + private: + void BeginNode(); + void EmitProps(const std::string& tag, anchor_t anchor); + + private: + Emitter& m_emitter; + + struct State { + enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue }; + }; + std::stack m_stateStack; +}; } -#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/emitter.h b/src/yamlcpp/yaml-cpp/emitter.h --- a/src/yamlcpp/yaml-cpp/emitter.h +++ b/src/yamlcpp/yaml-cpp/emitter.h @@ -1,186 +1,254 @@ #ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include +#include +#include +#include +#include "yaml-cpp/binary.h" #include "yaml-cpp/dll.h" -#include "yaml-cpp/binary.h" +#include "yaml-cpp/emitterdef.h" #include "yaml-cpp/emittermanip.h" -#include "yaml-cpp/ostream.h" #include "yaml-cpp/noncopyable.h" #include "yaml-cpp/null.h" -#include -#include -#include +#include "yaml-cpp/ostream_wrapper.h" -namespace LHAPDF_YAML -{ - class EmitterState; +namespace YAML { +class Binary; +struct _Null; +} // namespace YAML - class YAML_CPP_API Emitter: private noncopyable - { - public: - Emitter(); - ~Emitter(); +namespace YAML { +class EmitterState; - // output - const char *c_str() const; - unsigned size() const; +class YAML_CPP_API Emitter : private noncopyable { + public: + Emitter(); + explicit Emitter(std::ostream& stream); + ~Emitter(); - // state checking - bool good() const; - const std::string GetLastError() const; + // output + const char* c_str() const; + std::size_t size() const; - // global setters - bool SetOutputCharset(EMITTER_MANIP value); - bool SetStringFormat(EMITTER_MANIP value); - bool SetBoolFormat(EMITTER_MANIP value); - bool SetIntBase(EMITTER_MANIP value); - bool SetSeqFormat(EMITTER_MANIP value); - bool SetMapFormat(EMITTER_MANIP value); - bool SetIndent(unsigned n); - bool SetPreCommentIndent(unsigned n); - bool SetPostCommentIndent(unsigned n); - bool SetFloatPrecision(unsigned n); - bool SetDoublePrecision(unsigned n); + // state checking + bool good() const; + const std::string GetLastError() const; - // local setters - Emitter& SetLocalValue(EMITTER_MANIP value); - Emitter& SetLocalIndent(const _Indent& indent); - Emitter& SetLocalPrecision(const _Precision& precision); + // global setters + bool SetOutputCharset(EMITTER_MANIP value); + bool SetStringFormat(EMITTER_MANIP value); + bool SetBoolFormat(EMITTER_MANIP value); + bool SetIntBase(EMITTER_MANIP value); + bool SetSeqFormat(EMITTER_MANIP value); + bool SetMapFormat(EMITTER_MANIP value); + bool SetIndent(std::size_t n); + bool SetPreCommentIndent(std::size_t n); + bool SetPostCommentIndent(std::size_t n); + bool SetFloatPrecision(std::size_t n); + bool SetDoublePrecision(std::size_t n); - // overloads of write - Emitter& Write(const std::string& str); - Emitter& Write(bool b); - Emitter& Write(char ch); - Emitter& Write(const _Alias& alias); - Emitter& Write(const _Anchor& anchor); - Emitter& Write(const _Tag& tag); - Emitter& Write(const _Comment& comment); - Emitter& Write(const _Null& null); - Emitter& Write(const Binary& binary); + // local setters + Emitter& SetLocalValue(EMITTER_MANIP value); + Emitter& SetLocalIndent(const _Indent& indent); + Emitter& SetLocalPrecision(const _Precision& precision); - template - Emitter& WriteIntegralType(T value); + // overloads of write + Emitter& Write(const std::string& str); + Emitter& Write(bool b); + Emitter& Write(char ch); + Emitter& Write(const _Alias& alias); + Emitter& Write(const _Anchor& anchor); + Emitter& Write(const _Tag& tag); + Emitter& Write(const _Comment& comment); + Emitter& Write(const _Null& n); + Emitter& Write(const Binary& binary); - template - Emitter& WriteStreamable(T value); + template + Emitter& WriteIntegralType(T value); - private: - void PreWriteIntegralType(std::stringstream& str); - void PreWriteStreamable(std::stringstream& str); - void PostWriteIntegralType(const std::stringstream& str); - void PostWriteStreamable(const std::stringstream& str); + template + Emitter& WriteStreamable(T value); - template void SetStreamablePrecision(std::stringstream&) {} - unsigned GetFloatPrecision() const; - unsigned GetDoublePrecision() const; + private: + template + void SetStreamablePrecision(std::stringstream&) {} + std::size_t GetFloatPrecision() const; + std::size_t GetDoublePrecision() const; - private: - void PreAtomicWrite(); - bool GotoNextPreAtomicState(); - void PostAtomicWrite(); - void EmitSeparationIfNecessary(); + void PrepareIntegralStream(std::stringstream& stream) const; + void StartedScalar(); - void EmitBeginDoc(); - void EmitEndDoc(); - void EmitBeginSeq(); - void EmitEndSeq(); - void EmitBeginMap(); - void EmitEndMap(); - void EmitKey(); - void EmitValue(); - void EmitNewline(); - void EmitKindTag(); - void EmitTag(bool verbatim, const _Tag& tag); + private: + void EmitBeginDoc(); + void EmitEndDoc(); + void EmitBeginSeq(); + void EmitEndSeq(); + void EmitBeginMap(); + void EmitEndMap(); + void EmitNewline(); + void EmitKindTag(); + void EmitTag(bool verbatim, const _Tag& tag); - const char *ComputeFullBoolName(bool b) const; - bool CanEmitNewline() const; + void PrepareNode(EmitterNodeType::value child); + void PrepareTopNode(EmitterNodeType::value child); + void FlowSeqPrepareNode(EmitterNodeType::value child); + void BlockSeqPrepareNode(EmitterNodeType::value child); - private: - ostream m_stream; - std::unique_ptr m_pState; - }; + void FlowMapPrepareNode(EmitterNodeType::value child); - template - inline Emitter& Emitter::WriteIntegralType(T value) - { - if(!good()) - return *this; + void FlowMapPrepareLongKey(EmitterNodeType::value child); + void FlowMapPrepareLongKeyValue(EmitterNodeType::value child); + void FlowMapPrepareSimpleKey(EmitterNodeType::value child); + void FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child); - std::stringstream str; - PreWriteIntegralType(str); - str << value; - PostWriteIntegralType(str); - return *this; - } + void BlockMapPrepareNode(EmitterNodeType::value child); - template - inline Emitter& Emitter::WriteStreamable(T value) - { - if(!good()) - return *this; + void BlockMapPrepareLongKey(EmitterNodeType::value child); + void BlockMapPrepareLongKeyValue(EmitterNodeType::value child); + void BlockMapPrepareSimpleKey(EmitterNodeType::value child); + void BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child); - std::stringstream str; - PreWriteStreamable(str); - SetStreamablePrecision(str); - str << value; - PostWriteStreamable(str); - return *this; - } + void SpaceOrIndentTo(bool requireSpace, std::size_t indent); - template<> - inline void Emitter::SetStreamablePrecision(std::stringstream& str) - { - str.precision(GetFloatPrecision()); - } + const char* ComputeFullBoolName(bool b) const; + bool CanEmitNewline() const; - template<> - inline void Emitter::SetStreamablePrecision(std::stringstream& str) - { - str.precision(GetDoublePrecision()); - } + private: + std::unique_ptr m_pState; + ostream_wrapper m_stream; +}; - // overloads of insertion - inline Emitter& operator << (Emitter& emitter, const std::string& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, bool v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, char v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, unsigned char v) { return emitter.Write(static_cast(v)); } - inline Emitter& operator << (Emitter& emitter, const _Alias& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Anchor& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Tag& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Comment& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const _Null& v) { return emitter.Write(v); } - inline Emitter& operator << (Emitter& emitter, const Binary& b) { return emitter.Write(b); } +template +inline Emitter& Emitter::WriteIntegralType(T value) { + if (!good()) + return *this; - inline Emitter& operator << (Emitter& emitter, const char *v) { return emitter.Write(std::string(v)); } + PrepareNode(EmitterNodeType::Scalar); - inline Emitter& operator << (Emitter& emitter, int v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned int v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, short v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned short v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, long v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned long v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, long long v) { return emitter.WriteIntegralType(v); } - inline Emitter& operator << (Emitter& emitter, unsigned long long v) { return emitter.WriteIntegralType(v); } + std::stringstream stream; + PrepareIntegralStream(stream); + stream << value; + m_stream << stream.str(); - inline Emitter& operator << (Emitter& emitter, float v) { return emitter.WriteStreamable(v); } - inline Emitter& operator << (Emitter& emitter, double v) { return emitter.WriteStreamable(v); } + StartedScalar(); - inline Emitter& operator << (Emitter& emitter, EMITTER_MANIP value) { - return emitter.SetLocalValue(value); - } - - inline Emitter& operator << (Emitter& emitter, _Indent indent) { - return emitter.SetLocalIndent(indent); - } - - inline Emitter& operator << (Emitter& emitter, _Precision precision) { - return emitter.SetLocalPrecision(precision); - } + return *this; } -#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +template +inline Emitter& Emitter::WriteStreamable(T value) { + if (!good()) + return *this; + + PrepareNode(EmitterNodeType::Scalar); + + std::stringstream stream; + SetStreamablePrecision(stream); + stream << value; + m_stream << stream.str(); + + StartedScalar(); + + return *this; +} + +template <> +inline void Emitter::SetStreamablePrecision(std::stringstream& stream) { + stream.precision(static_cast(GetFloatPrecision())); +} + +template <> +inline void Emitter::SetStreamablePrecision(std::stringstream& stream) { + stream.precision(static_cast(GetDoublePrecision())); +} + +// overloads of insertion +inline Emitter& operator<<(Emitter& emitter, const std::string& v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, bool v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, char v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, unsigned char v) { + return emitter.Write(static_cast(v)); +} +inline Emitter& operator<<(Emitter& emitter, const _Alias& v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, const _Anchor& v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, const _Tag& v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, const _Comment& v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, const _Null& v) { + return emitter.Write(v); +} +inline Emitter& operator<<(Emitter& emitter, const Binary& b) { + return emitter.Write(b); +} + +inline Emitter& operator<<(Emitter& emitter, const char* v) { + return emitter.Write(std::string(v)); +} + +inline Emitter& operator<<(Emitter& emitter, int v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, unsigned int v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, short v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, unsigned short v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, long v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, unsigned long v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, long long v) { + return emitter.WriteIntegralType(v); +} +inline Emitter& operator<<(Emitter& emitter, unsigned long long v) { + return emitter.WriteIntegralType(v); +} + +inline Emitter& operator<<(Emitter& emitter, float v) { + return emitter.WriteStreamable(v); +} +inline Emitter& operator<<(Emitter& emitter, double v) { + return emitter.WriteStreamable(v); +} + +inline Emitter& operator<<(Emitter& emitter, EMITTER_MANIP value) { + return emitter.SetLocalValue(value); +} + +inline Emitter& operator<<(Emitter& emitter, _Indent indent) { + return emitter.SetLocalIndent(indent); +} + +inline Emitter& operator<<(Emitter& emitter, _Precision precision) { + return emitter.SetLocalPrecision(precision); +} +} + +#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/emitterdef.h b/src/yamlcpp/yaml-cpp/emitterdef.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/emitterdef.h @@ -0,0 +1,16 @@ +#ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +namespace YAML { +struct EmitterNodeType { + enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; +}; +} + +#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/emittermanip.h b/src/yamlcpp/yaml-cpp/emittermanip.h --- a/src/yamlcpp/yaml-cpp/emittermanip.h +++ b/src/yamlcpp/yaml-cpp/emittermanip.h @@ -1,149 +1,137 @@ #ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include -namespace LHAPDF_YAML -{ - enum EMITTER_MANIP { - // general manipulators - Auto, - TagByKind, - Newline, +namespace YAML { +enum EMITTER_MANIP { + // general manipulators + Auto, + TagByKind, + Newline, - // output character set - EmitNonAscii, - EscapeNonAscii, - - // string manipulators - // Auto, // duplicate - SingleQuoted, - DoubleQuoted, - Literal, - - // bool manipulators - YesNoBool, // yes, no - TrueFalseBool, // true, false - OnOffBool, // on, off - UpperCase, // TRUE, N - LowerCase, // f, yes - CamelCase, // No, Off - LongBool, // yes, On - ShortBool, // y, t - - // int manipulators - Dec, - Hex, - Oct, - - // document manipulators - BeginDoc, - EndDoc, - - // sequence manipulators - BeginSeq, - EndSeq, - Flow, - Block, - - // map manipulators - BeginMap, - EndMap, - Key, - Value, - // Flow, // duplicate - // Block, // duplicate - // Auto, // duplicate - LongKey - }; - - struct _Indent { - _Indent(int value_): value(value_) {} - int value; - }; - - inline _Indent Indent(int value) { - return _Indent(value); - } - - struct _Alias { - _Alias(const std::string& content_): content(content_) {} - std::string content; - }; - - inline _Alias Alias(const std::string content) { - return _Alias(content); - } - - struct _Anchor { - _Anchor(const std::string& content_): content(content_) {} - std::string content; - }; + // output character set + EmitNonAscii, + EscapeNonAscii, - inline _Anchor Anchor(const std::string content) { - return _Anchor(content); - } - - struct _Tag { - struct Type { enum value { Verbatim, PrimaryHandle, NamedHandle }; }; - - explicit _Tag(const std::string& prefix_, const std::string& content_, Type::value type_) - : prefix(prefix_), content(content_), type(type_) - { - } - std::string prefix; - std::string content; - Type::value type; - }; - - inline _Tag VerbatimTag(const std::string content) { - return _Tag("", content, _Tag::Type::Verbatim); - } + // string manipulators + // Auto, // duplicate + SingleQuoted, + DoubleQuoted, + Literal, - inline _Tag LocalTag(const std::string content) { - return _Tag("", content, _Tag::Type::PrimaryHandle); - } + // bool manipulators + YesNoBool, // yes, no + TrueFalseBool, // true, false + OnOffBool, // on, off + UpperCase, // TRUE, N + LowerCase, // f, yes + CamelCase, // No, Off + LongBool, // yes, On + ShortBool, // y, t - inline _Tag LocalTag(const std::string& prefix, const std::string content) { - return _Tag(prefix, content, _Tag::Type::NamedHandle); - } + // int manipulators + Dec, + Hex, + Oct, - inline _Tag SecondaryTag(const std::string content) { - return _Tag("", content, _Tag::Type::NamedHandle); - } + // document manipulators + BeginDoc, + EndDoc, - struct _Comment { - _Comment(const std::string& content_): content(content_) {} - std::string content; - }; - - inline _Comment Comment(const std::string content) { - return _Comment(content); - } - - struct _Precision { - _Precision(int floatPrecision_, int doublePrecision_): floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} - - int floatPrecision; - int doublePrecision; - }; - - inline _Precision FloatPrecision(int n) { - return _Precision(n, -1); - } + // sequence manipulators + BeginSeq, + EndSeq, + Flow, + Block, - inline _Precision DoublePrecision(int n) { - return _Precision(-1, n); - } + // map manipulators + BeginMap, + EndMap, + Key, + Value, + // Flow, // duplicate + // Block, // duplicate + // Auto, // duplicate + LongKey +}; - inline _Precision Precision(int n) { - return _Precision(n, n); - } +struct _Indent { + _Indent(int value_) : value(value_) {} + int value; +}; + +inline _Indent Indent(int value) { return _Indent(value); } + +struct _Alias { + _Alias(const std::string& content_) : content(content_) {} + std::string content; +}; + +inline _Alias Alias(const std::string content) { return _Alias(content); } + +struct _Anchor { + _Anchor(const std::string& content_) : content(content_) {} + std::string content; +}; + +inline _Anchor Anchor(const std::string content) { return _Anchor(content); } + +struct _Tag { + struct Type { + enum value { Verbatim, PrimaryHandle, NamedHandle }; + }; + + explicit _Tag(const std::string& prefix_, const std::string& content_, + Type::value type_) + : prefix(prefix_), content(content_), type(type_) {} + std::string prefix; + std::string content; + Type::value type; +}; + +inline _Tag VerbatimTag(const std::string content) { + return _Tag("", content, _Tag::Type::Verbatim); } -#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +inline _Tag LocalTag(const std::string content) { + return _Tag("", content, _Tag::Type::PrimaryHandle); +} + +inline _Tag LocalTag(const std::string& prefix, const std::string content) { + return _Tag(prefix, content, _Tag::Type::NamedHandle); +} + +inline _Tag SecondaryTag(const std::string content) { + return _Tag("", content, _Tag::Type::NamedHandle); +} + +struct _Comment { + _Comment(const std::string& content_) : content(content_) {} + std::string content; +}; + +inline _Comment Comment(const std::string content) { return _Comment(content); } + +struct _Precision { + _Precision(int floatPrecision_, int doublePrecision_) + : floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} + + int floatPrecision; + int doublePrecision; +}; + +inline _Precision FloatPrecision(int n) { return _Precision(n, -1); } + +inline _Precision DoublePrecision(int n) { return _Precision(-1, n); } + +inline _Precision Precision(int n) { return _Precision(n, n); } +} + +#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/emitterstyle.h b/src/yamlcpp/yaml-cpp/emitterstyle.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/emitterstyle.h @@ -0,0 +1,16 @@ +#ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +namespace YAML { +struct EmitterStyle { + enum value { Default, Block, Flow }; +}; +} + +#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/eventhandler.h b/src/yamlcpp/yaml-cpp/eventhandler.h --- a/src/yamlcpp/yaml-cpp/eventhandler.h +++ b/src/yamlcpp/yaml-cpp/eventhandler.h @@ -1,36 +1,40 @@ #ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif -#include "yaml-cpp/anchor.h" #include -namespace LHAPDF_YAML -{ - struct Mark; - - class EventHandler - { - public: - virtual ~EventHandler() {} +#include "yaml-cpp/anchor.h" +#include "yaml-cpp/emitterstyle.h" - virtual void OnDocumentStart(const Mark& mark) = 0; - virtual void OnDocumentEnd() = 0; - - virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; - virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; - virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value) = 0; +namespace YAML { +struct Mark; - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor) = 0; - virtual void OnSequenceEnd() = 0; +class EventHandler { + public: + virtual ~EventHandler() {} - virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor) = 0; - virtual void OnMapEnd() = 0; - }; + virtual void OnDocumentStart(const Mark& mark) = 0; + virtual void OnDocumentEnd() = 0; + + virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; + virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; + virtual void OnScalar(const Mark& mark, const std::string& tag, + anchor_t anchor, const std::string& value) = 0; + + virtual void OnSequenceStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style) = 0; + virtual void OnSequenceEnd() = 0; + + virtual void OnMapStart(const Mark& mark, const std::string& tag, + anchor_t anchor, EmitterStyle::value style) = 0; + virtual void OnMapEnd() = 0; +}; } -#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/exceptions.h b/src/yamlcpp/yaml-cpp/exceptions.h --- a/src/yamlcpp/yaml-cpp/exceptions.h +++ b/src/yamlcpp/yaml-cpp/exceptions.h @@ -1,164 +1,267 @@ #ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include "yaml-cpp/mark.h" #include "yaml-cpp/traits.h" +#include #include #include -#include -namespace LHAPDF_YAML -{ - // error messages - namespace ErrorMsg - { - const char * const YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument"; - const char * const YAML_VERSION = "bad YAML version: "; - const char * const YAML_MAJOR_VERSION = "YAML major version too large"; - const char * const REPEATED_YAML_DIRECTIVE= "repeated YAML directive"; - const char * const TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments"; - const char * const REPEATED_TAG_DIRECTIVE = "repeated TAG directive"; - const char * const CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle"; - const char * const TAG_WITH_NO_SUFFIX = "tag handle with no suffix"; - const char * const END_OF_VERBATIM_TAG = "end of verbatim tag not found"; - const char * const END_OF_MAP = "end of map not found"; - const char * const END_OF_MAP_FLOW = "end of map flow not found"; - const char * const END_OF_SEQ = "end of sequence not found"; - const char * const END_OF_SEQ_FLOW = "end of sequence flow not found"; - const char * const MULTIPLE_TAGS = "cannot assign multiple tags to the same node"; - const char * const MULTIPLE_ANCHORS = "cannot assign multiple anchors to the same node"; - const char * const MULTIPLE_ALIASES = "cannot assign multiple aliases to the same node"; - const char * const ALIAS_CONTENT = "aliases can't have any content, *including* tags"; - const char * const INVALID_HEX = "bad character found while scanning hex number"; - const char * const INVALID_UNICODE = "invalid unicode: "; - const char * const INVALID_ESCAPE = "unknown escape character: "; - const char * const UNKNOWN_TOKEN = "unknown token"; - const char * const DOC_IN_SCALAR = "illegal document indicator in scalar"; - const char * const EOF_IN_SCALAR = "illegal EOF in scalar"; - const char * const CHAR_IN_SCALAR = "illegal character in scalar"; - const char * const TAB_IN_INDENTATION = "illegal tab when looking for indentation"; - const char * const FLOW_END = "illegal flow end"; - const char * const BLOCK_ENTRY = "illegal block entry"; - const char * const MAP_KEY = "illegal map key"; - const char * const MAP_VALUE = "illegal map value"; - const char * const ALIAS_NOT_FOUND = "alias not found after *"; - const char * const ANCHOR_NOT_FOUND = "anchor not found after &"; - const char * const CHAR_IN_ALIAS = "illegal character found while scanning alias"; - const char * const CHAR_IN_ANCHOR = "illegal character found while scanning anchor"; - const char * const ZERO_INDENT_IN_BLOCK = "cannot set zero indentation for a block scalar"; - const char * const CHAR_IN_BLOCK = "unexpected character in block scalar"; - const char * const AMBIGUOUS_ANCHOR = "cannot assign the same alias to multiple nodes"; - const char * const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; +// This is here for compatibility with older versions of Visual Studio +// which don't support noexcept +#ifdef _MSC_VER + #define YAML_CPP_NOEXCEPT _NOEXCEPT +#else + #define YAML_CPP_NOEXCEPT noexcept +#endif - const char * const INVALID_SCALAR = "invalid scalar"; - const char * const KEY_NOT_FOUND = "key not found"; - const char * const BAD_DEREFERENCE = "bad dereference"; - - const char * const UNMATCHED_GROUP_TAG = "unmatched group tag"; - const char * const UNEXPECTED_END_SEQ = "unexpected end sequence token"; - const char * const UNEXPECTED_END_MAP = "unexpected end map token"; - const char * const SINGLE_QUOTED_CHAR = "invalid character in single-quoted string"; - const char * const INVALID_ANCHOR = "invalid anchor"; - const char * const INVALID_ALIAS = "invalid alias"; - const char * const INVALID_TAG = "invalid tag"; - const char * const EXPECTED_KEY_TOKEN = "expected key token"; - const char * const EXPECTED_VALUE_TOKEN = "expected value token"; - const char * const UNEXPECTED_KEY_TOKEN = "unexpected key token"; - const char * const UNEXPECTED_VALUE_TOKEN = "unexpected value token"; +namespace YAML { +// error messages +namespace ErrorMsg { +const char* const YAML_DIRECTIVE_ARGS = + "YAML directives must have exactly one argument"; +const char* const YAML_VERSION = "bad YAML version: "; +const char* const YAML_MAJOR_VERSION = "YAML major version too large"; +const char* const REPEATED_YAML_DIRECTIVE = "repeated YAML directive"; +const char* const TAG_DIRECTIVE_ARGS = + "TAG directives must have exactly two arguments"; +const char* const REPEATED_TAG_DIRECTIVE = "repeated TAG directive"; +const char* const CHAR_IN_TAG_HANDLE = + "illegal character found while scanning tag handle"; +const char* const TAG_WITH_NO_SUFFIX = "tag handle with no suffix"; +const char* const END_OF_VERBATIM_TAG = "end of verbatim tag not found"; +const char* const END_OF_MAP = "end of map not found"; +const char* const END_OF_MAP_FLOW = "end of map flow not found"; +const char* const END_OF_SEQ = "end of sequence not found"; +const char* const END_OF_SEQ_FLOW = "end of sequence flow not found"; +const char* const MULTIPLE_TAGS = + "cannot assign multiple tags to the same node"; +const char* const MULTIPLE_ANCHORS = + "cannot assign multiple anchors to the same node"; +const char* const MULTIPLE_ALIASES = + "cannot assign multiple aliases to the same node"; +const char* const ALIAS_CONTENT = + "aliases can't have any content, *including* tags"; +const char* const INVALID_HEX = "bad character found while scanning hex number"; +const char* const INVALID_UNICODE = "invalid unicode: "; +const char* const INVALID_ESCAPE = "unknown escape character: "; +const char* const UNKNOWN_TOKEN = "unknown token"; +const char* const DOC_IN_SCALAR = "illegal document indicator in scalar"; +const char* const EOF_IN_SCALAR = "illegal EOF in scalar"; +const char* const CHAR_IN_SCALAR = "illegal character in scalar"; +const char* const TAB_IN_INDENTATION = + "illegal tab when looking for indentation"; +const char* const FLOW_END = "illegal flow end"; +const char* const BLOCK_ENTRY = "illegal block entry"; +const char* const MAP_KEY = "illegal map key"; +const char* const MAP_VALUE = "illegal map value"; +const char* const ALIAS_NOT_FOUND = "alias not found after *"; +const char* const ANCHOR_NOT_FOUND = "anchor not found after &"; +const char* const CHAR_IN_ALIAS = + "illegal character found while scanning alias"; +const char* const CHAR_IN_ANCHOR = + "illegal character found while scanning anchor"; +const char* const ZERO_INDENT_IN_BLOCK = + "cannot set zero indentation for a block scalar"; +const char* const CHAR_IN_BLOCK = "unexpected character in block scalar"; +const char* const AMBIGUOUS_ANCHOR = + "cannot assign the same alias to multiple nodes"; +const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; - template - inline const std::string KEY_NOT_FOUND_WITH_KEY(const T&, typename disable_if >::type * = 0) { - return KEY_NOT_FOUND; - } +const char* const INVALID_NODE = + "invalid node; this may result from using a map iterator as a sequence " + "iterator, or vice-versa"; +const char* const INVALID_SCALAR = "invalid scalar"; +const char* const KEY_NOT_FOUND = "key not found"; +const char* const BAD_CONVERSION = "bad conversion"; +const char* const BAD_DEREFERENCE = "bad dereference"; +const char* const BAD_SUBSCRIPT = "operator[] call on a scalar"; +const char* const BAD_PUSHBACK = "appending to a non-sequence"; +const char* const BAD_INSERT = "inserting in a non-convertible-to-map"; - inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); - } - - template - inline const std::string KEY_NOT_FOUND_WITH_KEY(const T& key, typename enable_if >::type * = 0) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); - } - } +const char* const UNMATCHED_GROUP_TAG = "unmatched group tag"; +const char* const UNEXPECTED_END_SEQ = "unexpected end sequence token"; +const char* const UNEXPECTED_END_MAP = "unexpected end map token"; +const char* const SINGLE_QUOTED_CHAR = + "invalid character in single-quoted string"; +const char* const INVALID_ANCHOR = "invalid anchor"; +const char* const INVALID_ALIAS = "invalid alias"; +const char* const INVALID_TAG = "invalid tag"; +const char* const BAD_FILE = "bad file"; - class Exception: public std::runtime_error { - public: - Exception(const Mark& mark_, const std::string& msg_) - : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} - virtual ~Exception() throw() {} - - Mark mark; - std::string msg; - - private: - static const std::string build_what(const Mark& mark, const std::string& msg) { - std::stringstream output; - output << "yaml-cpp: error at line " << mark.line+1 << ", column " << mark.column+1 << ": " << msg; - return output.str(); - } - }; - - class ParserException: public Exception { - public: - ParserException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - }; - - class RepresentationException: public Exception { - public: - RepresentationException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - }; - - // representation exceptions - class InvalidScalar: public RepresentationException { - public: - InvalidScalar(const Mark& mark_) - : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} - }; - - class KeyNotFound: public RepresentationException { - public: - template - KeyNotFound(const Mark& mark_, const T& key_) - : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {} - }; - - template - class TypedKeyNotFound: public KeyNotFound { - public: - TypedKeyNotFound(const Mark& mark_, const T& key_) - : KeyNotFound(mark_, key_), key(key_) {} - virtual ~TypedKeyNotFound() throw() {} - - T key; - }; - - template - inline TypedKeyNotFound MakeTypedKeyNotFound(const Mark& mark, const T& key) { - return TypedKeyNotFound (mark, key); - } - - class BadDereference: public RepresentationException { - public: - BadDereference() - : RepresentationException(Mark::null(), ErrorMsg::BAD_DEREFERENCE) {} - }; - - class EmitterException: public Exception { - public: - EmitterException(const std::string& msg_) - : Exception(Mark::null(), msg_) {} - }; +template +inline const std::string KEY_NOT_FOUND_WITH_KEY( + const T&, typename disable_if>::type* = 0) { + return KEY_NOT_FOUND; } -#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { + std::stringstream stream; + stream << KEY_NOT_FOUND << ": " << key; + return stream.str(); +} + +template +inline const std::string KEY_NOT_FOUND_WITH_KEY( + const T& key, typename enable_if>::type* = 0) { + std::stringstream stream; + stream << KEY_NOT_FOUND << ": " << key; + return stream.str(); +} +} + +class YAML_CPP_API Exception : public std::runtime_error { + public: + Exception(const Mark& mark_, const std::string& msg_) + : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} + virtual ~Exception() YAML_CPP_NOEXCEPT; + + Exception(const Exception&) = default; + + Mark mark; + std::string msg; + + private: + static const std::string build_what(const Mark& mark, + const std::string& msg) { + if (mark.is_null()) { + return msg.c_str(); + } + + std::stringstream output; + output << "yaml-cpp: error at line " << mark.line + 1 << ", column " + << mark.column + 1 << ": " << msg; + return output.str(); + } +}; + +class YAML_CPP_API ParserException : public Exception { + public: + ParserException(const Mark& mark_, const std::string& msg_) + : Exception(mark_, msg_) {} + ParserException(const ParserException&) = default; + virtual ~ParserException() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API RepresentationException : public Exception { + public: + RepresentationException(const Mark& mark_, const std::string& msg_) + : Exception(mark_, msg_) {} + RepresentationException(const RepresentationException&) = default; + virtual ~RepresentationException() YAML_CPP_NOEXCEPT; +}; + +// representation exceptions +class YAML_CPP_API InvalidScalar : public RepresentationException { + public: + InvalidScalar(const Mark& mark_) + : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} + InvalidScalar(const InvalidScalar&) = default; + virtual ~InvalidScalar() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API KeyNotFound : public RepresentationException { + public: + template + KeyNotFound(const Mark& mark_, const T& key_) + : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) { + } + KeyNotFound(const KeyNotFound&) = default; + virtual ~KeyNotFound() YAML_CPP_NOEXCEPT; +}; + +template +class YAML_CPP_API TypedKeyNotFound : public KeyNotFound { + public: + TypedKeyNotFound(const Mark& mark_, const T& key_) + : KeyNotFound(mark_, key_), key(key_) {} + virtual ~TypedKeyNotFound() YAML_CPP_NOEXCEPT {} + + T key; +}; + +template +inline TypedKeyNotFound MakeTypedKeyNotFound(const Mark& mark, + const T& key) { + return TypedKeyNotFound(mark, key); +} + +class YAML_CPP_API InvalidNode : public RepresentationException { + public: + InvalidNode() + : RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {} + InvalidNode(const InvalidNode&) = default; + virtual ~InvalidNode() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API BadConversion : public RepresentationException { + public: + explicit BadConversion(const Mark& mark_) + : RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {} + BadConversion(const BadConversion&) = default; + virtual ~BadConversion() YAML_CPP_NOEXCEPT; +}; + +template +class TypedBadConversion : public BadConversion { + public: + explicit TypedBadConversion(const Mark& mark_) : BadConversion(mark_) {} +}; + +class YAML_CPP_API BadDereference : public RepresentationException { + public: + BadDereference() + : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {} + BadDereference(const BadDereference&) = default; + virtual ~BadDereference() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API BadSubscript : public RepresentationException { + public: + BadSubscript() + : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {} + BadSubscript(const BadSubscript&) = default; + virtual ~BadSubscript() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API BadPushback : public RepresentationException { + public: + BadPushback() + : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {} + BadPushback(const BadPushback&) = default; + virtual ~BadPushback() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API BadInsert : public RepresentationException { + public: + BadInsert() + : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {} + BadInsert(const BadInsert&) = default; + virtual ~BadInsert() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API EmitterException : public Exception { + public: + EmitterException(const std::string& msg_) + : Exception(Mark::null_mark(), msg_) {} + EmitterException(const EmitterException&) = default; + virtual ~EmitterException() YAML_CPP_NOEXCEPT; +}; + +class YAML_CPP_API BadFile : public Exception { + public: + BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {} + BadFile(const BadFile&) = default; + virtual ~BadFile() YAML_CPP_NOEXCEPT; +}; +} + +#undef YAML_CPP_NOEXCEPT + +#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/iterator.h b/src/yamlcpp/yaml-cpp/iterator.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/iterator.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include - -namespace LHAPDF_YAML -{ - class Node; - struct IterPriv; - - class YAML_CPP_API Iterator - { - public: - Iterator(); - Iterator(std::unique_ptr pData); - Iterator(const Iterator& rhs); - ~Iterator(); - - Iterator& operator = (const Iterator& rhs); - Iterator& operator ++ (); - Iterator operator ++ (int); - const Node& operator * () const; - const Node *operator -> () const; - const Node& first() const; - const Node& second() const; - - friend YAML_CPP_API bool operator == (const Iterator& it, const Iterator& jt); - friend YAML_CPP_API bool operator != (const Iterator& it, const Iterator& jt); - - private: - std::unique_ptr m_pData; - }; -} - -#endif // ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/ltnode.h b/src/yamlcpp/yaml-cpp/ltnode.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/ltnode.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace LHAPDF_YAML -{ - class Node; - - struct ltnode { - bool operator()(const Node *pNode1, const Node *pNode2) const; - }; -} - -#endif // LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/mark.h b/src/yamlcpp/yaml-cpp/mark.h --- a/src/yamlcpp/yaml-cpp/mark.h +++ b/src/yamlcpp/yaml-cpp/mark.h @@ -1,26 +1,29 @@ #ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include "yaml-cpp/dll.h" -namespace LHAPDF_YAML -{ - struct YAML_CPP_API Mark { - Mark(): pos(0), line(0), column(0) {} - - static const Mark null() { return Mark(-1, -1, -1); } - - int pos; - int line, column; - - private: - Mark(int pos_, int line_, int column_): pos(pos_), line(line_), column(column_) {} - }; +namespace YAML { +struct YAML_CPP_API Mark { + Mark() : pos(0), line(0), column(0) {} + + static const Mark null_mark() { return Mark(-1, -1, -1); } + + bool is_null() const { return pos == -1 && line == -1 && column == -1; } + + int pos; + int line, column; + + private: + Mark(int pos_, int line_, int column_) + : pos(pos_), line(line_), column(column_) {} +}; } -#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node.h b/src/yamlcpp/yaml-cpp/node.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/node.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/exceptions.h" -#include "yaml-cpp/mark.h" -#include "yaml-cpp/noncopyable.h" -#include "yaml-cpp/conversion.h" -#include "yaml-cpp/iterator.h" -#include "yaml-cpp/ltnode.h" -#include -#include -#include -#include -#include - -namespace LHAPDF_YAML -{ - class AliasManager; - class Content; - class NodeOwnership; - class Scanner; - class Emitter; - class EventHandler; - - struct NodeType { enum value { Null, Scalar, Sequence, Map }; }; - - class YAML_CPP_API Node: private noncopyable - { - public: - friend class NodeOwnership; - friend class NodeBuilder; - - Node(); - ~Node(); - - void Clear(); - std::unique_ptr Clone() const; - void EmitEvents(EventHandler& eventHandler) const; - void EmitEvents(AliasManager& am, EventHandler& eventHandler) const; - - NodeType::value Type() const { return m_type; } - bool IsAliased() const; - - // file location of start of this node - const Mark GetMark() const { return m_mark; } - - // accessors - Iterator begin() const; - Iterator end() const; - std::size_t size() const; - - // extraction of scalars - bool GetScalar(std::string& s) const; - - // we can specialize this for other values - template - bool Read(T& value) const; - - template - const T to() const; - - template - friend YAML_CPP_API typename enable_if >::type operator >> (const Node& node, T& value); - - // retrieval for maps and sequences - template - const Node *FindValue(const T& key) const; - - template - const Node& operator [] (const T& key) const; - - // specific to maps - const Node *FindValue(const char *key) const; - const Node *FindValue(char *key) const; - const Node& operator [] (const char *key) const; - const Node& operator [] (char *key) const; - - // for tags - const std::string& Tag() const { return m_tag; } - - // emitting - friend YAML_CPP_API Emitter& operator << (Emitter& out, const Node& node); - - // ordering - int Compare(const Node& rhs) const; - friend bool operator < (const Node& n1, const Node& n2); - - private: - explicit Node(NodeOwnership& owner); - Node& CreateNode(); - - void Init(NodeType::value type, const Mark& mark, const std::string& tag); - - void MarkAsAliased(); - void SetScalarData(const std::string& data); - void Append(Node& node); - void Insert(Node& key, Node& value); - - // helper for sequences - template friend struct _FindFromNodeAtIndex; - const Node *FindAtIndex(std::size_t i) const; - - // helper for maps - template - const Node& GetValue(const T& key) const; - - template - const Node *FindValueForKey(const T& key) const; - - private: - std::unique_ptr m_pOwnership; - - Mark m_mark; - std::string m_tag; - - typedef std::vector node_seq; - typedef std::map node_map; - - NodeType::value m_type; - std::string m_scalarData; - node_seq m_seqData; - node_map m_mapData; - }; -} - -#include "yaml-cpp/nodeimpl.h" -#include "yaml-cpp/nodereadimpl.h" - -#endif // NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/convert.h b/src/yamlcpp/yaml-cpp/node/convert.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/convert.h @@ -0,0 +1,331 @@ +#ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include +#include +#include +#include +#include + +#include "yaml-cpp/binary.h" +#include "yaml-cpp/node/impl.h" +#include "yaml-cpp/node/iterator.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/type.h" +#include "yaml-cpp/null.h" + +namespace YAML { +class Binary; +struct _Null; +template +struct convert; +} // namespace YAML + +namespace YAML { +namespace conversion { +inline bool IsInfinity(const std::string& input) { + return input == ".inf" || input == ".Inf" || input == ".INF" || + input == "+.inf" || input == "+.Inf" || input == "+.INF"; +} + +inline bool IsNegativeInfinity(const std::string& input) { + return input == "-.inf" || input == "-.Inf" || input == "-.INF"; +} + +inline bool IsNaN(const std::string& input) { + return input == ".nan" || input == ".NaN" || input == ".NAN"; +} +} + +// Node +template <> +struct convert { + static Node encode(const Node& rhs) { return rhs; } + + static bool decode(const Node& node, Node& rhs) { + rhs.reset(node); + return true; + } +}; + +// std::string +template <> +struct convert { + static Node encode(const std::string& rhs) { return Node(rhs); } + + static bool decode(const Node& node, std::string& rhs) { + if (!node.IsScalar()) + return false; + rhs = node.Scalar(); + return true; + } +}; + +// C-strings can only be encoded +template <> +struct convert { + static Node encode(const char*& rhs) { return Node(rhs); } +}; + +template +struct convert { + static Node encode(const char(&rhs)[N]) { return Node(rhs); } +}; + +template <> +struct convert<_Null> { + static Node encode(const _Null& /* rhs */) { return Node(); } + + static bool decode(const Node& node, _Null& /* rhs */) { + return node.IsNull(); + } +}; + +#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \ + template <> \ + struct convert { \ + static Node encode(const type& rhs) { \ + std::stringstream stream; \ + stream.precision(std::numeric_limits::digits10 + 1); \ + stream << rhs; \ + return Node(stream.str()); \ + } \ + \ + static bool decode(const Node& node, type& rhs) { \ + if (node.Type() != NodeType::Scalar) \ + return false; \ + const std::string& input = node.Scalar(); \ + std::stringstream stream(input); \ + stream.unsetf(std::ios::dec); \ + if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \ + return true; \ + if (std::numeric_limits::has_infinity) { \ + if (conversion::IsInfinity(input)) { \ + rhs = std::numeric_limits::infinity(); \ + return true; \ + } else if (conversion::IsNegativeInfinity(input)) { \ + rhs = negative_op std::numeric_limits::infinity(); \ + return true; \ + } \ + } \ + \ + if (std::numeric_limits::has_quiet_NaN && \ + conversion::IsNaN(input)) { \ + rhs = std::numeric_limits::quiet_NaN(); \ + return true; \ + } \ + \ + return false; \ + } \ + } + +#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \ + YAML_DEFINE_CONVERT_STREAMABLE(type, -) + +#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type) \ + YAML_DEFINE_CONVERT_STREAMABLE(type, +) + +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int); +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short); +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long); +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long); +YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned); +YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short); +YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long); +YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long); + +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char); +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(signed char); +YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char); + +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float); +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double); +YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double); + +#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED +#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED +#undef YAML_DEFINE_CONVERT_STREAMABLE + +// bool +template <> +struct convert { + static Node encode(bool rhs) { return rhs ? Node("true") : Node("false"); } + + YAML_CPP_API static bool decode(const Node& node, bool& rhs); +}; + +// std::map +template +struct convert> { + static Node encode(const std::map& rhs) { + Node node(NodeType::Map); + for (typename std::map::const_iterator it = rhs.begin(); + it != rhs.end(); ++it) + node.force_insert(it->first, it->second); + return node; + } + + static bool decode(const Node& node, std::map& rhs) { + if (!node.IsMap()) + return false; + + rhs.clear(); + for (const_iterator it = node.begin(); it != node.end(); ++it) +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs[it->first.template as()] = it->second.template as(); +#else + rhs[it->first.as()] = it->second.as(); +#endif + return true; + } +}; + +// std::vector +template +struct convert> { + static Node encode(const std::vector& rhs) { + Node node(NodeType::Sequence); + for (typename std::vector::const_iterator it = rhs.begin(); + it != rhs.end(); ++it) + node.push_back(*it); + return node; + } + + static bool decode(const Node& node, std::vector& rhs) { + if (!node.IsSequence()) + return false; + + rhs.clear(); + for (const_iterator it = node.begin(); it != node.end(); ++it) +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs.push_back(it->template as()); +#else + rhs.push_back(it->as()); +#endif + return true; + } +}; + +// std::list +template +struct convert> { + static Node encode(const std::list& rhs) { + Node node(NodeType::Sequence); + for (typename std::list::const_iterator it = rhs.begin(); + it != rhs.end(); ++it) + node.push_back(*it); + return node; + } + + static bool decode(const Node& node, std::list& rhs) { + if (!node.IsSequence()) + return false; + + rhs.clear(); + for (const_iterator it = node.begin(); it != node.end(); ++it) +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs.push_back(it->template as()); +#else + rhs.push_back(it->as()); +#endif + return true; + } +}; + +// std::array +template +struct convert> { + static Node encode(const std::array& rhs) { + Node node(NodeType::Sequence); + for (const auto& element : rhs) { + node.push_back(element); + } + return node; + } + + static bool decode(const Node& node, std::array& rhs) { + if (!isNodeValid(node)) { + return false; + } + + for (auto i = 0u; i < node.size(); ++i) { +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs[i] = node[i].template as(); +#else + rhs[i] = node[i].as(); +#endif + } + return true; + } + + private: + static bool isNodeValid(const Node& node) { + return node.IsSequence() && node.size() == N; + } +}; + +// std::pair +template +struct convert> { + static Node encode(const std::pair& rhs) { + Node node(NodeType::Sequence); + node.push_back(rhs.first); + node.push_back(rhs.second); + return node; + } + + static bool decode(const Node& node, std::pair& rhs) { + if (!node.IsSequence()) + return false; + if (node.size() != 2) + return false; + +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs.first = node[0].template as(); +#else + rhs.first = node[0].as(); +#endif +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs.second = node[1].template as(); +#else + rhs.second = node[1].as(); +#endif + return true; + } +}; + +// binary +template <> +struct convert { + static Node encode(const Binary& rhs) { + return Node(EncodeBase64(rhs.data(), rhs.size())); + } + + static bool decode(const Node& node, Binary& rhs) { + if (!node.IsScalar()) + return false; + + std::vector data = DecodeBase64(node.Scalar()); + if (data.empty() && !node.Scalar().empty()) + return false; + + rhs.swap(data); + return true; + } +}; +} + +#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/bool_type.h b/src/yamlcpp/yaml-cpp/node/detail/bool_type.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/bool_type.h @@ -0,0 +1,26 @@ +#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +namespace YAML { +namespace detail { +struct unspecified_bool { + struct NOT_ALLOWED; + static void true_value(NOT_ALLOWED*) {} +}; +typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*); +} +} + +#define YAML_CPP_OPERATOR_BOOL() \ + operator YAML::detail::unspecified_bool_type() const { \ + return this->operator!() ? 0 \ + : &YAML::detail::unspecified_bool::true_value; \ + } + +#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/impl.h b/src/yamlcpp/yaml-cpp/node/detail/impl.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/impl.h @@ -0,0 +1,185 @@ +#ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/node/detail/node.h" +#include "yaml-cpp/node/detail/node_data.h" +#include + +namespace YAML { +namespace detail { +template +struct get_idx { + static node* get(const std::vector& /* sequence */, + const Key& /* key */, shared_memory_holder /* pMemory */) { + return 0; + } +}; + +template +struct get_idx::value && + !std::is_same::value>::type> { + static node* get(const std::vector& sequence, const Key& key, + shared_memory_holder /* pMemory */) { + return key < sequence.size() ? sequence[key] : 0; + } + + static node* get(std::vector& sequence, const Key& key, + shared_memory_holder pMemory) { + if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined())) + return 0; + if (key == sequence.size()) + sequence.push_back(&pMemory->create_node()); + return sequence[key]; + } +}; + +template +struct get_idx::value>::type> { + static node* get(const std::vector& sequence, const Key& key, + shared_memory_holder pMemory) { + return key >= 0 ? get_idx::get( + sequence, static_cast(key), pMemory) + : 0; + } + static node* get(std::vector& sequence, const Key& key, + shared_memory_holder pMemory) { + return key >= 0 ? get_idx::get( + sequence, static_cast(key), pMemory) + : 0; + } +}; + +template +inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { + T lhs; + if (convert::decode(Node(*this, pMemory), lhs)) { + return lhs == rhs; + } + return false; +} + +inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { + return equals(rhs, pMemory); +} + +// indexing +template +inline node* node_data::get(const Key& key, + shared_memory_holder pMemory) const { + switch (m_type) { + case NodeType::Map: + break; + case NodeType::Undefined: + case NodeType::Null: + return NULL; + case NodeType::Sequence: + if (node* pNode = get_idx::get(m_sequence, key, pMemory)) + return pNode; + return NULL; + case NodeType::Scalar: + throw BadSubscript(); + } + + for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it->first->equals(key, pMemory)) { + return it->second; + } + } + + return NULL; +} + +template +inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { + switch (m_type) { + case NodeType::Map: + break; + case NodeType::Undefined: + case NodeType::Null: + case NodeType::Sequence: + if (node* pNode = get_idx::get(m_sequence, key, pMemory)) { + m_type = NodeType::Sequence; + return *pNode; + } + + convert_to_map(pMemory); + break; + case NodeType::Scalar: + throw BadSubscript(); + } + + for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it->first->equals(key, pMemory)) { + return *it->second; + } + } + + node& k = convert_to_node(key, pMemory); + node& v = pMemory->create_node(); + insert_map_pair(k, v); + return v; +} + +template +inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) { + if (m_type != NodeType::Map) + return false; + + for (kv_pairs::iterator it = m_undefinedPairs.begin(); + it != m_undefinedPairs.end();) { + kv_pairs::iterator jt = std::next(it); + if (it->first->equals(key, pMemory)) + m_undefinedPairs.erase(it); + it = jt; + } + + for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) { + if (it->first->equals(key, pMemory)) { + m_map.erase(it); + return true; + } + } + + return false; +} + +// map +template +inline void node_data::force_insert(const Key& key, const Value& value, + shared_memory_holder pMemory) { + switch (m_type) { + case NodeType::Map: + break; + case NodeType::Undefined: + case NodeType::Null: + case NodeType::Sequence: + convert_to_map(pMemory); + break; + case NodeType::Scalar: + throw BadInsert(); + } + + node& k = convert_to_node(key, pMemory); + node& v = convert_to_node(value, pMemory); + insert_map_pair(k, v); +} + +template +inline node& node_data::convert_to_node(const T& rhs, + shared_memory_holder pMemory) { + Node value = convert::encode(rhs); + value.EnsureNodeExists(); + pMemory->merge(*value.m_pMemory); + return *value.m_pNode; +} +} +} + +#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/iterator.h b/src/yamlcpp/yaml-cpp/node/detail/iterator.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/iterator.h @@ -0,0 +1,92 @@ +#ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/detail/node_iterator.h" +#include +#include + +namespace YAML { +namespace detail { +struct iterator_value; + +template +class iterator_base : public std::iterator { + + private: + template + friend class iterator_base; + struct enabler {}; + typedef node_iterator base_type; + + struct proxy { + explicit proxy(const V& x) : m_ref(x) {} + V* operator->() { return std::addressof(m_ref); } + operator V*() { return std::addressof(m_ref); } + + V m_ref; + }; + + public: + typedef typename iterator_base::value_type value_type; + + public: + iterator_base() : m_iterator(), m_pMemory() {} + explicit iterator_base(base_type rhs, shared_memory_holder pMemory) + : m_iterator(rhs), m_pMemory(pMemory) {} + + template + iterator_base(const iterator_base& rhs, + typename std::enable_if::value, + enabler>::type = enabler()) + : m_iterator(rhs.m_iterator), m_pMemory(rhs.m_pMemory) {} + + iterator_base& operator++() { + ++m_iterator; + return *this; + } + + iterator_base operator++(int) { + iterator_base iterator_pre(*this); + ++(*this); + return iterator_pre; + } + + template + bool operator==(const iterator_base& rhs) const { + return m_iterator == rhs.m_iterator; + } + + template + bool operator!=(const iterator_base& rhs) const { + return m_iterator != rhs.m_iterator; + } + + value_type operator*() const { + const typename base_type::value_type& v = *m_iterator; + if (v.pNode) + return value_type(Node(*v, m_pMemory)); + if (v.first && v.second) + return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory)); + return value_type(); + } + + proxy operator->() const { return proxy(**this); } + + private: + base_type m_iterator; + shared_memory_holder m_pMemory; +}; +} +} + +#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/iterator_fwd.h b/src/yamlcpp/yaml-cpp/node/detail/iterator_fwd.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/iterator_fwd.h @@ -0,0 +1,27 @@ +#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/dll.h" +#include +#include +#include + +namespace YAML { + +namespace detail { +struct iterator_value; +template +class iterator_base; +} + +typedef detail::iterator_base iterator; +typedef detail::iterator_base const_iterator; +} + +#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/memory.h b/src/yamlcpp/yaml-cpp/node/detail/memory.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/memory.h @@ -0,0 +1,46 @@ +#ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/ptr.h" + +namespace YAML { +namespace detail { +class node; +} // namespace detail +} // namespace YAML + +namespace YAML { +namespace detail { +class YAML_CPP_API memory { + public: + node& create_node(); + void merge(const memory& rhs); + + private: + typedef std::set Nodes; + Nodes m_nodes; +}; + +class YAML_CPP_API memory_holder { + public: + memory_holder() : m_pMemory(new memory) {} + + node& create_node() { return m_pMemory->create_node(); } + void merge(memory_holder& rhs); + + private: + shared_memory m_pMemory; +}; +} +} + +#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/node.h b/src/yamlcpp/yaml-cpp/node/detail/node.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/node.h @@ -0,0 +1,169 @@ +#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/emitterstyle.h" +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/type.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/detail/node_ref.h" +#include + +namespace YAML { +namespace detail { +class node { + public: + node() : m_pRef(new node_ref) {} + node(const node&) = delete; + node& operator=(const node&) = delete; + + bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; } + const node_ref* ref() const { return m_pRef.get(); } + + bool is_defined() const { return m_pRef->is_defined(); } + const Mark& mark() const { return m_pRef->mark(); } + NodeType::value type() const { return m_pRef->type(); } + + const std::string& scalar() const { return m_pRef->scalar(); } + const std::string& tag() const { return m_pRef->tag(); } + EmitterStyle::value style() const { return m_pRef->style(); } + + template + bool equals(const T& rhs, shared_memory_holder pMemory); + bool equals(const char* rhs, shared_memory_holder pMemory); + + void mark_defined() { + if (is_defined()) + return; + + m_pRef->mark_defined(); + for (nodes::iterator it = m_dependencies.begin(); + it != m_dependencies.end(); ++it) + (*it)->mark_defined(); + m_dependencies.clear(); + } + + void add_dependency(node& rhs) { + if (is_defined()) + rhs.mark_defined(); + else + m_dependencies.insert(&rhs); + } + + void set_ref(const node& rhs) { + if (rhs.is_defined()) + mark_defined(); + m_pRef = rhs.m_pRef; + } + void set_data(const node& rhs) { + if (rhs.is_defined()) + mark_defined(); + m_pRef->set_data(*rhs.m_pRef); + } + + void set_mark(const Mark& mark) { m_pRef->set_mark(mark); } + + void set_type(NodeType::value type) { + if (type != NodeType::Undefined) + mark_defined(); + m_pRef->set_type(type); + } + void set_null() { + mark_defined(); + m_pRef->set_null(); + } + void set_scalar(const std::string& scalar) { + mark_defined(); + m_pRef->set_scalar(scalar); + } + void set_tag(const std::string& tag) { + mark_defined(); + m_pRef->set_tag(tag); + } + + // style + void set_style(EmitterStyle::value style) { + mark_defined(); + m_pRef->set_style(style); + } + + // size/iterator + std::size_t size() const { return m_pRef->size(); } + + const_node_iterator begin() const { + return static_cast(*m_pRef).begin(); + } + node_iterator begin() { return m_pRef->begin(); } + + const_node_iterator end() const { + return static_cast(*m_pRef).end(); + } + node_iterator end() { return m_pRef->end(); } + + // sequence + void push_back(node& input, shared_memory_holder pMemory) { + m_pRef->push_back(input, pMemory); + input.add_dependency(*this); + } + void insert(node& key, node& value, shared_memory_holder pMemory) { + m_pRef->insert(key, value, pMemory); + key.add_dependency(*this); + value.add_dependency(*this); + } + + // indexing + template + node* get(const Key& key, shared_memory_holder pMemory) const { + // NOTE: this returns a non-const node so that the top-level Node can wrap + // it, and returns a pointer so that it can be NULL (if there is no such + // key). + return static_cast(*m_pRef).get(key, pMemory); + } + template + node& get(const Key& key, shared_memory_holder pMemory) { + node& value = m_pRef->get(key, pMemory); + value.add_dependency(*this); + return value; + } + template + bool remove(const Key& key, shared_memory_holder pMemory) { + return m_pRef->remove(key, pMemory); + } + + node* get(node& key, shared_memory_holder pMemory) const { + // NOTE: this returns a non-const node so that the top-level Node can wrap + // it, and returns a pointer so that it can be NULL (if there is no such + // key). + return static_cast(*m_pRef).get(key, pMemory); + } + node& get(node& key, shared_memory_holder pMemory) { + node& value = m_pRef->get(key, pMemory); + key.add_dependency(*this); + value.add_dependency(*this); + return value; + } + bool remove(node& key, shared_memory_holder pMemory) { + return m_pRef->remove(key, pMemory); + } + + // map + template + void force_insert(const Key& key, const Value& value, + shared_memory_holder pMemory) { + m_pRef->force_insert(key, value, pMemory); + } + + private: + shared_node_ref m_pRef; + typedef std::set nodes; + nodes m_dependencies; +}; +} +} + +#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/node_data.h b/src/yamlcpp/yaml-cpp/node/detail/node_data.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/node_data.h @@ -0,0 +1,127 @@ +#ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include +#include +#include +#include + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/detail/node_iterator.h" +#include "yaml-cpp/node/iterator.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/type.h" + +namespace YAML { +namespace detail { +class node; +} // namespace detail +} // namespace YAML + +namespace YAML { +namespace detail { +class YAML_CPP_API node_data { + public: + node_data(); + node_data(const node_data&) = delete; + node_data& operator=(const node_data&) = delete; + + void mark_defined(); + void set_mark(const Mark& mark); + void set_type(NodeType::value type); + void set_tag(const std::string& tag); + void set_null(); + void set_scalar(const std::string& scalar); + void set_style(EmitterStyle::value style); + + bool is_defined() const { return m_isDefined; } + const Mark& mark() const { return m_mark; } + NodeType::value type() const { + return m_isDefined ? m_type : NodeType::Undefined; + } + const std::string& scalar() const { return m_scalar; } + const std::string& tag() const { return m_tag; } + EmitterStyle::value style() const { return m_style; } + + // size/iterator + std::size_t size() const; + + const_node_iterator begin() const; + node_iterator begin(); + + const_node_iterator end() const; + node_iterator end(); + + // sequence + void push_back(node& node, shared_memory_holder pMemory); + void insert(node& key, node& value, shared_memory_holder pMemory); + + // indexing + template + node* get(const Key& key, shared_memory_holder pMemory) const; + template + node& get(const Key& key, shared_memory_holder pMemory); + template + bool remove(const Key& key, shared_memory_holder pMemory); + + node* get(node& key, shared_memory_holder pMemory) const; + node& get(node& key, shared_memory_holder pMemory); + bool remove(node& key, shared_memory_holder pMemory); + + // map + template + void force_insert(const Key& key, const Value& value, + shared_memory_holder pMemory); + + public: + static std::string empty_scalar; + + private: + void compute_seq_size() const; + void compute_map_size() const; + + void reset_sequence(); + void reset_map(); + + void insert_map_pair(node& key, node& value); + void convert_to_map(shared_memory_holder pMemory); + void convert_sequence_to_map(shared_memory_holder pMemory); + + template + static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); + + private: + bool m_isDefined; + Mark m_mark; + NodeType::value m_type; + std::string m_tag; + EmitterStyle::value m_style; + + // scalar + std::string m_scalar; + + // sequence + typedef std::vector node_seq; + node_seq m_sequence; + + mutable std::size_t m_seqSize; + + // map + typedef std::vector> node_map; + node_map m_map; + + typedef std::pair kv_pair; + typedef std::list kv_pairs; + mutable kv_pairs m_undefinedPairs; +}; +} +} + +#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/node_iterator.h b/src/yamlcpp/yaml-cpp/node/detail/node_iterator.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/node_iterator.h @@ -0,0 +1,180 @@ +#ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/ptr.h" +#include +#include +#include +#include +#include +#include + +namespace YAML { +namespace detail { +struct iterator_type { + enum value { NoneType, Sequence, Map }; +}; + +template +struct node_iterator_value : public std::pair { + typedef std::pair kv; + + node_iterator_value() : kv(), pNode(0) {} + explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {} + explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(0) {} + + V& operator*() const { return *pNode; } + V& operator->() const { return *pNode; } + + V* pNode; +}; + +typedef std::vector node_seq; +typedef std::vector> node_map; + +template +struct node_iterator_type { + typedef node_seq::iterator seq; + typedef node_map::iterator map; +}; + +template +struct node_iterator_type { + typedef node_seq::const_iterator seq; + typedef node_map::const_iterator map; +}; + +template +class node_iterator_base + : public std::iterator, + std::ptrdiff_t, node_iterator_value*, + node_iterator_value> { + private: + struct enabler {}; + + struct proxy { + explicit proxy(const node_iterator_value& x) : m_ref(x) {} + node_iterator_value* operator->() { return std::addressof(m_ref); } + operator node_iterator_value*() { return std::addressof(m_ref); } + + node_iterator_value m_ref; + }; + + public: + typedef typename node_iterator_type::seq SeqIter; + typedef typename node_iterator_type::map MapIter; + typedef node_iterator_value value_type; + + node_iterator_base() + : m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {} + explicit node_iterator_base(SeqIter seqIt) + : m_type(iterator_type::Sequence), + m_seqIt(seqIt), + m_mapIt(), + m_mapEnd() {} + explicit node_iterator_base(MapIter mapIt, MapIter mapEnd) + : m_type(iterator_type::Map), + m_seqIt(), + m_mapIt(mapIt), + m_mapEnd(mapEnd) { + m_mapIt = increment_until_defined(m_mapIt); + } + + template + node_iterator_base(const node_iterator_base& rhs, + typename std::enable_if::value, + enabler>::type = enabler()) + : m_type(rhs.m_type), + m_seqIt(rhs.m_seqIt), + m_mapIt(rhs.m_mapIt), + m_mapEnd(rhs.m_mapEnd) {} + + template + friend class node_iterator_base; + + template + bool operator==(const node_iterator_base& rhs) const { + if (m_type != rhs.m_type) + return false; + + switch (m_type) { + case iterator_type::NoneType: + return true; + case iterator_type::Sequence: + return m_seqIt == rhs.m_seqIt; + case iterator_type::Map: + return m_mapIt == rhs.m_mapIt; + } + return true; + } + + template + bool operator!=(const node_iterator_base& rhs) const { + return !(*this == rhs); + } + + node_iterator_base& operator++() { + switch (m_type) { + case iterator_type::NoneType: + break; + case iterator_type::Sequence: + ++m_seqIt; + break; + case iterator_type::Map: + ++m_mapIt; + m_mapIt = increment_until_defined(m_mapIt); + break; + } + return *this; + } + + node_iterator_base operator++(int) { + node_iterator_base iterator_pre(*this); + ++(*this); + return iterator_pre; + } + + value_type operator*() const { + switch (m_type) { + case iterator_type::NoneType: + return value_type(); + case iterator_type::Sequence: + return value_type(**m_seqIt); + case iterator_type::Map: + return value_type(*m_mapIt->first, *m_mapIt->second); + } + return value_type(); + } + + proxy operator->() const { return proxy(**this); } + + MapIter increment_until_defined(MapIter it) { + while (it != m_mapEnd && !is_defined(it)) + ++it; + return it; + } + + bool is_defined(MapIter it) const { + return it->first->is_defined() && it->second->is_defined(); + } + + private: + typename iterator_type::value m_type; + + SeqIter m_seqIt; + MapIter m_mapIt, m_mapEnd; +}; + +typedef node_iterator_base node_iterator; +typedef node_iterator_base const_node_iterator; +} +} + +#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/detail/node_ref.h b/src/yamlcpp/yaml-cpp/node/detail/node_ref.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/detail/node_ref.h @@ -0,0 +1,98 @@ +#ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/type.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/detail/node_data.h" + +namespace YAML { +namespace detail { +class node_ref { + public: + node_ref() : m_pData(new node_data) {} + node_ref(const node_ref&) = delete; + node_ref& operator=(const node_ref&) = delete; + + bool is_defined() const { return m_pData->is_defined(); } + const Mark& mark() const { return m_pData->mark(); } + NodeType::value type() const { return m_pData->type(); } + const std::string& scalar() const { return m_pData->scalar(); } + const std::string& tag() const { return m_pData->tag(); } + EmitterStyle::value style() const { return m_pData->style(); } + + void mark_defined() { m_pData->mark_defined(); } + void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; } + + void set_mark(const Mark& mark) { m_pData->set_mark(mark); } + void set_type(NodeType::value type) { m_pData->set_type(type); } + void set_tag(const std::string& tag) { m_pData->set_tag(tag); } + void set_null() { m_pData->set_null(); } + void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); } + void set_style(EmitterStyle::value style) { m_pData->set_style(style); } + + // size/iterator + std::size_t size() const { return m_pData->size(); } + + const_node_iterator begin() const { + return static_cast(*m_pData).begin(); + } + node_iterator begin() { return m_pData->begin(); } + + const_node_iterator end() const { + return static_cast(*m_pData).end(); + } + node_iterator end() { return m_pData->end(); } + + // sequence + void push_back(node& node, shared_memory_holder pMemory) { + m_pData->push_back(node, pMemory); + } + void insert(node& key, node& value, shared_memory_holder pMemory) { + m_pData->insert(key, value, pMemory); + } + + // indexing + template + node* get(const Key& key, shared_memory_holder pMemory) const { + return static_cast(*m_pData).get(key, pMemory); + } + template + node& get(const Key& key, shared_memory_holder pMemory) { + return m_pData->get(key, pMemory); + } + template + bool remove(const Key& key, shared_memory_holder pMemory) { + return m_pData->remove(key, pMemory); + } + + node* get(node& key, shared_memory_holder pMemory) const { + return static_cast(*m_pData).get(key, pMemory); + } + node& get(node& key, shared_memory_holder pMemory) { + return m_pData->get(key, pMemory); + } + bool remove(node& key, shared_memory_holder pMemory) { + return m_pData->remove(key, pMemory); + } + + // map + template + void force_insert(const Key& key, const Value& value, + shared_memory_holder pMemory) { + m_pData->force_insert(key, value, pMemory); + } + + private: + shared_node_data m_pData; +}; +} +} + +#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/emit.h b/src/yamlcpp/yaml-cpp/node/emit.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/emit.h @@ -0,0 +1,32 @@ +#ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include + +#include "yaml-cpp/dll.h" + +namespace YAML { +class Emitter; +class Node; + +/** + * Emits the node to the given {@link Emitter}. If there is an error in writing, + * {@link Emitter#good} will return false. + */ +YAML_CPP_API Emitter& operator<<(Emitter& out, const Node& node); + +/** Emits the node to the given output stream. */ +YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node); + +/** Converts the node to a YAML string. */ +YAML_CPP_API std::string Dump(const Node& node); +} // namespace YAML + +#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/impl.h b/src/yamlcpp/yaml-cpp/node/impl.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/impl.h @@ -0,0 +1,448 @@ +#ifndef NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/iterator.h" +#include "yaml-cpp/node/detail/memory.h" +#include "yaml-cpp/node/detail/node.h" +#include "yaml-cpp/exceptions.h" +#include + +namespace YAML { +inline Node::Node() : m_isValid(true), m_pNode(NULL) {} + +inline Node::Node(NodeType::value type) + : m_isValid(true), + m_pMemory(new detail::memory_holder), + m_pNode(&m_pMemory->create_node()) { + m_pNode->set_type(type); +} + +template +inline Node::Node(const T& rhs) + : m_isValid(true), + m_pMemory(new detail::memory_holder), + m_pNode(&m_pMemory->create_node()) { + Assign(rhs); +} + +inline Node::Node(const detail::iterator_value& rhs) + : m_isValid(rhs.m_isValid), + m_pMemory(rhs.m_pMemory), + m_pNode(rhs.m_pNode) {} + +inline Node::Node(const Node& rhs) + : m_isValid(rhs.m_isValid), + m_pMemory(rhs.m_pMemory), + m_pNode(rhs.m_pNode) {} + +inline Node::Node(Zombie) : m_isValid(false), m_pNode(NULL) {} + +inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory) + : m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {} + +inline Node::~Node() {} + +inline void Node::EnsureNodeExists() const { + if (!m_isValid) + throw InvalidNode(); + if (!m_pNode) { + m_pMemory.reset(new detail::memory_holder); + m_pNode = &m_pMemory->create_node(); + m_pNode->set_null(); + } +} + +inline bool Node::IsDefined() const { + if (!m_isValid) { + return false; + } + return m_pNode ? m_pNode->is_defined() : true; +} + +inline Mark Node::Mark() const { + if (!m_isValid) { + throw InvalidNode(); + } + return m_pNode ? m_pNode->mark() : Mark::null_mark(); +} + +inline NodeType::value Node::Type() const { + if (!m_isValid) + throw InvalidNode(); + return m_pNode ? m_pNode->type() : NodeType::Null; +} + +// access + +// template helpers +template +struct as_if { + explicit as_if(const Node& node_) : node(node_) {} + const Node& node; + + T operator()(const S& fallback) const { + if (!node.m_pNode) + return fallback; + + T t; + if (convert::decode(node, t)) + return t; + return fallback; + } +}; + +template +struct as_if { + explicit as_if(const Node& node_) : node(node_) {} + const Node& node; + + std::string operator()(const S& fallback) const { + if (node.Type() != NodeType::Scalar) + return fallback; + return node.Scalar(); + } +}; + +template +struct as_if { + explicit as_if(const Node& node_) : node(node_) {} + const Node& node; + + T operator()() const { + if (!node.m_pNode) + throw TypedBadConversion(node.Mark()); + + T t; + if (convert::decode(node, t)) + return t; + throw TypedBadConversion(node.Mark()); + } +}; + +template <> +struct as_if { + explicit as_if(const Node& node_) : node(node_) {} + const Node& node; + + std::string operator()() const { + if (node.Type() != NodeType::Scalar) + throw TypedBadConversion(node.Mark()); + return node.Scalar(); + } +}; + +// access functions +template +inline T Node::as() const { + if (!m_isValid) + throw InvalidNode(); + return as_if(*this)(); +} + +template +inline T Node::as(const S& fallback) const { + if (!m_isValid) + return fallback; + return as_if(*this)(fallback); +} + +inline const std::string& Node::Scalar() const { + if (!m_isValid) + throw InvalidNode(); + return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar; +} + +inline const std::string& Node::Tag() const { + if (!m_isValid) + throw InvalidNode(); + return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar; +} + +inline void Node::SetTag(const std::string& tag) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + m_pNode->set_tag(tag); +} + +inline EmitterStyle::value Node::Style() const { + if (!m_isValid) + throw InvalidNode(); + return m_pNode ? m_pNode->style() : EmitterStyle::Default; +} + +inline void Node::SetStyle(EmitterStyle::value style) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + m_pNode->set_style(style); +} + +// assignment +inline bool Node::is(const Node& rhs) const { + if (!m_isValid || !rhs.m_isValid) + throw InvalidNode(); + if (!m_pNode || !rhs.m_pNode) + return false; + return m_pNode->is(*rhs.m_pNode); +} + +template +inline Node& Node::operator=(const T& rhs) { + if (!m_isValid) + throw InvalidNode(); + Assign(rhs); + return *this; +} + +inline void Node::reset(const YAML::Node& rhs) { + if (!m_isValid || !rhs.m_isValid) + throw InvalidNode(); + m_pMemory = rhs.m_pMemory; + m_pNode = rhs.m_pNode; +} + +template +inline void Node::Assign(const T& rhs) { + if (!m_isValid) + throw InvalidNode(); + AssignData(convert::encode(rhs)); +} + +template <> +inline void Node::Assign(const std::string& rhs) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + m_pNode->set_scalar(rhs); +} + +inline void Node::Assign(const char* rhs) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + m_pNode->set_scalar(rhs); +} + +inline void Node::Assign(char* rhs) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + m_pNode->set_scalar(rhs); +} + +inline Node& Node::operator=(const Node& rhs) { + if (!m_isValid || !rhs.m_isValid) + throw InvalidNode(); + if (is(rhs)) + return *this; + AssignNode(rhs); + return *this; +} + +inline void Node::AssignData(const Node& rhs) { + if (!m_isValid || !rhs.m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + rhs.EnsureNodeExists(); + + m_pNode->set_data(*rhs.m_pNode); + m_pMemory->merge(*rhs.m_pMemory); +} + +inline void Node::AssignNode(const Node& rhs) { + if (!m_isValid || !rhs.m_isValid) + throw InvalidNode(); + rhs.EnsureNodeExists(); + + if (!m_pNode) { + m_pNode = rhs.m_pNode; + m_pMemory = rhs.m_pMemory; + return; + } + + m_pNode->set_ref(*rhs.m_pNode); + m_pMemory->merge(*rhs.m_pMemory); + m_pNode = rhs.m_pNode; +} + +// size/iterator +inline std::size_t Node::size() const { + if (!m_isValid) + throw InvalidNode(); + return m_pNode ? m_pNode->size() : 0; +} + +inline const_iterator Node::begin() const { + if (!m_isValid) + return const_iterator(); + return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory) + : const_iterator(); +} + +inline iterator Node::begin() { + if (!m_isValid) + return iterator(); + return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator(); +} + +inline const_iterator Node::end() const { + if (!m_isValid) + return const_iterator(); + return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator(); +} + +inline iterator Node::end() { + if (!m_isValid) + return iterator(); + return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator(); +} + +// sequence +template +inline void Node::push_back(const T& rhs) { + if (!m_isValid) + throw InvalidNode(); + push_back(Node(rhs)); +} + +inline void Node::push_back(const Node& rhs) { + if (!m_isValid || !rhs.m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + rhs.EnsureNodeExists(); + + m_pNode->push_back(*rhs.m_pNode, m_pMemory); + m_pMemory->merge(*rhs.m_pMemory); +} + +// helpers for indexing +namespace detail { +template +struct to_value_t { + explicit to_value_t(const T& t_) : t(t_) {} + const T& t; + typedef const T& return_type; + + const T& operator()() const { return t; } +}; + +template <> +struct to_value_t { + explicit to_value_t(const char* t_) : t(t_) {} + const char* t; + typedef std::string return_type; + + const std::string operator()() const { return t; } +}; + +template <> +struct to_value_t { + explicit to_value_t(char* t_) : t(t_) {} + const char* t; + typedef std::string return_type; + + const std::string operator()() const { return t; } +}; + +template +struct to_value_t { + explicit to_value_t(const char* t_) : t(t_) {} + const char* t; + typedef std::string return_type; + + const std::string operator()() const { return t; } +}; + +// converts C-strings to std::strings so they can be copied +template +inline typename to_value_t::return_type to_value(const T& t) { + return to_value_t(t)(); +} +} + +// indexing +template +inline const Node Node::operator[](const Key& key) const { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + detail::node* value = static_cast(*m_pNode) + .get(detail::to_value(key), m_pMemory); + if (!value) { + return Node(ZombieNode); + } + return Node(*value, m_pMemory); +} + +template +inline Node Node::operator[](const Key& key) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + detail::node& value = m_pNode->get(detail::to_value(key), m_pMemory); + return Node(value, m_pMemory); +} + +template +inline bool Node::remove(const Key& key) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + return m_pNode->remove(detail::to_value(key), m_pMemory); +} + +inline const Node Node::operator[](const Node& key) const { + if (!m_isValid || !key.m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + key.EnsureNodeExists(); + m_pMemory->merge(*key.m_pMemory); + detail::node* value = + static_cast(*m_pNode).get(*key.m_pNode, m_pMemory); + if (!value) { + return Node(ZombieNode); + } + return Node(*value, m_pMemory); +} + +inline Node Node::operator[](const Node& key) { + if (!m_isValid || !key.m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + key.EnsureNodeExists(); + m_pMemory->merge(*key.m_pMemory); + detail::node& value = m_pNode->get(*key.m_pNode, m_pMemory); + return Node(value, m_pMemory); +} + +inline bool Node::remove(const Node& key) { + if (!m_isValid || !key.m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + key.EnsureNodeExists(); + return m_pNode->remove(*key.m_pNode, m_pMemory); +} + +// map +template +inline void Node::force_insert(const Key& key, const Value& value) { + if (!m_isValid) + throw InvalidNode(); + EnsureNodeExists(); + m_pNode->force_insert(detail::to_value(key), detail::to_value(value), + m_pMemory); +} + +// free functions +inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); } +} + +#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/iterator.h b/src/yamlcpp/yaml-cpp/node/iterator.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/iterator.h @@ -0,0 +1,31 @@ +#ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/detail/iterator_fwd.h" +#include "yaml-cpp/node/detail/iterator.h" +#include +#include +#include + +namespace YAML { +namespace detail { +struct iterator_value : public Node, std::pair { + iterator_value() {} + explicit iterator_value(const Node& rhs) + : Node(rhs), + std::pair(Node(Node::ZombieNode), Node(Node::ZombieNode)) {} + explicit iterator_value(const Node& key, const Node& value) + : Node(Node::ZombieNode), std::pair(key, value) {} +}; +} +} + +#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/node.h b/src/yamlcpp/yaml-cpp/node/node.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/node.h @@ -0,0 +1,145 @@ +#ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/emitterstyle.h" +#include "yaml-cpp/mark.h" +#include "yaml-cpp/node/detail/bool_type.h" +#include "yaml-cpp/node/detail/iterator_fwd.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/type.h" + +namespace YAML { +namespace detail { +class node; +class node_data; +struct iterator_value; +} // namespace detail +} // namespace YAML + +namespace YAML { +class YAML_CPP_API Node { + public: + friend class NodeBuilder; + friend class NodeEvents; + friend struct detail::iterator_value; + friend class detail::node; + friend class detail::node_data; + template + friend class detail::iterator_base; + template + friend struct as_if; + + typedef YAML::iterator iterator; + typedef YAML::const_iterator const_iterator; + + Node(); + explicit Node(NodeType::value type); + template + explicit Node(const T& rhs); + explicit Node(const detail::iterator_value& rhs); + Node(const Node& rhs); + ~Node(); + + YAML::Mark Mark() const; + NodeType::value Type() const; + bool IsDefined() const; + bool IsNull() const { return Type() == NodeType::Null; } + bool IsScalar() const { return Type() == NodeType::Scalar; } + bool IsSequence() const { return Type() == NodeType::Sequence; } + bool IsMap() const { return Type() == NodeType::Map; } + + // bool conversions + YAML_CPP_OPERATOR_BOOL() + bool operator!() const { return !IsDefined(); } + + // access + template + T as() const; + template + T as(const S& fallback) const; + const std::string& Scalar() const; + + const std::string& Tag() const; + void SetTag(const std::string& tag); + + // style + // WARNING: This API might change in future releases. + EmitterStyle::value Style() const; + void SetStyle(EmitterStyle::value style); + + // assignment + bool is(const Node& rhs) const; + template + Node& operator=(const T& rhs); + Node& operator=(const Node& rhs); + void reset(const Node& rhs = Node()); + + // size/iterator + std::size_t size() const; + + const_iterator begin() const; + iterator begin(); + + const_iterator end() const; + iterator end(); + + // sequence + template + void push_back(const T& rhs); + void push_back(const Node& rhs); + + // indexing + template + const Node operator[](const Key& key) const; + template + Node operator[](const Key& key); + template + bool remove(const Key& key); + + const Node operator[](const Node& key) const; + Node operator[](const Node& key); + bool remove(const Node& key); + + // map + template + void force_insert(const Key& key, const Value& value); + + private: + enum Zombie { ZombieNode }; + explicit Node(Zombie); + explicit Node(detail::node& node, detail::shared_memory_holder pMemory); + + void EnsureNodeExists() const; + + template + void Assign(const T& rhs); + void Assign(const char* rhs); + void Assign(char* rhs); + + void AssignData(const Node& rhs); + void AssignNode(const Node& rhs); + + private: + bool m_isValid; + mutable detail::shared_memory_holder m_pMemory; + mutable detail::node* m_pNode; +}; + +YAML_CPP_API bool operator==(const Node& lhs, const Node& rhs); + +YAML_CPP_API Node Clone(const Node& node); + +template +struct convert; +} + +#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/parse.h b/src/yamlcpp/yaml-cpp/node/parse.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/parse.h @@ -0,0 +1,78 @@ +#ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include +#include + +#include "yaml-cpp/dll.h" + +namespace YAML { +class Node; + +/** + * Loads the input string as a single YAML document. + * + * @throws {@link ParserException} if it is malformed. + */ +YAML_CPP_API Node Load(const std::string& input); + +/** + * Loads the input string as a single YAML document. + * + * @throws {@link ParserException} if it is malformed. + */ +YAML_CPP_API Node Load(const char* input); + +/** + * Loads the input stream as a single YAML document. + * + * @throws {@link ParserException} if it is malformed. + */ +YAML_CPP_API Node Load(std::istream& input); + +/** + * Loads the input file as a single YAML document. + * + * @throws {@link ParserException} if it is malformed. + * @throws {@link BadFile} if the file cannot be loaded. + */ +YAML_CPP_API Node LoadFile(const std::string& filename); + +/** + * Loads the input string as a list of YAML documents. + * + * @throws {@link ParserException} if it is malformed. + */ +YAML_CPP_API std::vector LoadAll(const std::string& input); + +/** + * Loads the input string as a list of YAML documents. + * + * @throws {@link ParserException} if it is malformed. + */ +YAML_CPP_API std::vector LoadAll(const char* input); + +/** + * Loads the input stream as a list of YAML documents. + * + * @throws {@link ParserException} if it is malformed. + */ +YAML_CPP_API std::vector LoadAll(std::istream& input); + +/** + * Loads the input file as a list of YAML documents. + * + * @throws {@link ParserException} if it is malformed. + * @throws {@link BadFile} if the file cannot be loaded. + */ +YAML_CPP_API std::vector LoadAllFromFile(const std::string& filename); +} // namespace YAML + +#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/ptr.h b/src/yamlcpp/yaml-cpp/node/ptr.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/ptr.h @@ -0,0 +1,29 @@ +#ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include "yaml-cpp/dll.h" +#include + +namespace YAML { +namespace detail { +class node; +class node_ref; +class node_data; +class memory; +class memory_holder; + +typedef std::shared_ptr shared_node; +typedef std::shared_ptr shared_node_ref; +typedef std::shared_ptr shared_node_data; +typedef std::shared_ptr shared_memory_holder; +typedef std::shared_ptr shared_memory; +} +} + +#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/node/type.h b/src/yamlcpp/yaml-cpp/node/type.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/node/type.h @@ -0,0 +1,16 @@ +#ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +namespace YAML { +struct NodeType { + enum value { Undefined, Null, Scalar, Sequence, Map }; +}; +} + +#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/nodeimpl.h b/src/yamlcpp/yaml-cpp/nodeimpl.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/nodeimpl.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include "yaml-cpp/nodeutil.h" -#include - -namespace LHAPDF_YAML -{ - // implementation of templated things - template - inline const T Node::to() const { - T value; - *this >> value; - return value; - } - - template - inline typename enable_if >::type operator >> (const Node& node, T& value) { - if(!ConvertScalar(node, value)) - throw InvalidScalar(node.m_mark); - } - - template - inline const Node *Node::FindValue(const T& key) const { - switch(m_type) { - case NodeType::Null: - case NodeType::Scalar: - throw BadDereference(); - case NodeType::Sequence: - return FindFromNodeAtIndex(*this, key); - case NodeType::Map: - return FindValueForKey(key); - } - assert(false); - throw BadDereference(); - } - - template - inline const Node *Node::FindValueForKey(const T& key) const { - for(Iterator it=begin();it!=end();++it) { - T t; - if(it.first().Read(t)) { - if(key == t) - return &it.second(); - } - } - - return 0; - } - - template - inline const Node& Node::GetValue(const T& key) const { - if(const Node *pValue = FindValue(key)) - return *pValue; - throw MakeTypedKeyNotFound(m_mark, key); - } - - template - inline const Node& Node::operator [] (const T& key) const { - return GetValue(key); - } - - inline const Node *Node::FindValue(const char *key) const { - return FindValue(std::string(key)); - } - - inline const Node *Node::FindValue(char *key) const { - return FindValue(std::string(key)); - } - - inline const Node& Node::operator [] (const char *key) const { - return GetValue(std::string(key)); - } - - inline const Node& Node::operator [] (char *key) const { - return GetValue(std::string(key)); - } -} - -#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/nodereadimpl.h b/src/yamlcpp/yaml-cpp/nodereadimpl.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/nodereadimpl.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace LHAPDF_YAML -{ - // implementation for Node::Read - // (the goal is to call ConvertScalar if we can, and fall back to operator >> if not) - // thanks to litb from stackoverflow.com - // http://stackoverflow.com/questions/1386183/how-to-call-a-templated-function-if-it-exists-and-something-else-otherwise/1386390#1386390 - - // Note: this doesn't work on gcc 3.2, but does on gcc 3.4 and above. I'm not sure about 3.3. - -#if __GNUC__ && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)) - // trick doesn't work? Just fall back to ConvertScalar. - // This means that we can't use any user-defined types as keys in a map - template - inline bool Node::Read(T& value) const { - return ConvertScalar(*this, value); - } -#else - // usual case: the trick! - template - struct read_impl; - - // ConvertScalar available - template<> - struct read_impl { - template - static bool read(const Node& node, T& value) { - return ConvertScalar(node, value); - } - }; - - // ConvertScalar not available - template<> - struct read_impl { - template - static bool read(const Node& node, T& value) { - try { - node >> value; - } catch(const Exception&) { - return false; - } - return true; - } - }; - - namespace fallback { - // sizeof > 1 - struct flag { char c[2]; }; - flag Convert(...); - - int operator,(flag, flag); - - template - char operator,(flag, T const&); - - char operator,(int, flag); - int operator,(char, flag); - } - - template - inline bool Node::Read(T& value) const { - using namespace fallback; - - return read_impl::read(*this, value); - } -#endif // done with trick - - // the main conversion function - template - inline bool ConvertScalar(const Node& node, T& value) { - std::string scalar; - if(!node.GetScalar(scalar)) - return false; - - return Convert(scalar, value); - } -} - -#endif // NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/nodeutil.h b/src/yamlcpp/yaml-cpp/nodeutil.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/nodeutil.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -namespace LHAPDF_YAML -{ - template - struct is_same_type { - enum { value = false }; - }; - - template - struct is_same_type { - enum { value = true }; - }; - - template - struct is_index_type_with_check { - enum { value = false }; - }; - - template <> struct is_index_type_with_check { enum { value = true }; }; - -#define MAKE_INDEX_TYPE(Type) \ - template <> struct is_index_type_with_check::value> { enum { value = true }; } - - MAKE_INDEX_TYPE(int); - MAKE_INDEX_TYPE(unsigned); - MAKE_INDEX_TYPE(short); - MAKE_INDEX_TYPE(unsigned short); - MAKE_INDEX_TYPE(long); - MAKE_INDEX_TYPE(unsigned long); - -#undef MAKE_INDEX_TYPE - - template - struct is_index_type: public is_index_type_with_check {}; - - // messing around with template stuff to get the right overload for operator [] for a sequence - template - struct _FindFromNodeAtIndex { - const Node *pRet; - _FindFromNodeAtIndex(const Node&, const T&): pRet(0) {} - }; - - template - struct _FindFromNodeAtIndex { - const Node *pRet; - _FindFromNodeAtIndex(const Node& node, const T& key): pRet(node.FindAtIndex(static_cast(key))) {} - }; - - template - inline const Node *FindFromNodeAtIndex(const Node& node, const T& key) { - return _FindFromNodeAtIndex::value>(node, key).pRet; - } -} - -#endif // NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/noncopyable.h b/src/yamlcpp/yaml-cpp/noncopyable.h --- a/src/yamlcpp/yaml-cpp/noncopyable.h +++ b/src/yamlcpp/yaml-cpp/noncopyable.h @@ -1,25 +1,25 @@ #ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include "yaml-cpp/dll.h" -namespace LHAPDF_YAML -{ - // this is basically boost::noncopyable - class YAML_CPP_API noncopyable - { - protected: - noncopyable() {} - ~noncopyable() {} - - private: - noncopyable(const noncopyable&); - const noncopyable& operator = (const noncopyable&); - }; +namespace YAML { +// this is basically boost::noncopyable +class YAML_CPP_API noncopyable { + protected: + noncopyable() {} + ~noncopyable() {} + + private: + noncopyable(const noncopyable&); + const noncopyable& operator=(const noncopyable&); +}; } -#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/null.h b/src/yamlcpp/yaml-cpp/null.h --- a/src/yamlcpp/yaml-cpp/null.h +++ b/src/yamlcpp/yaml-cpp/null.h @@ -1,25 +1,26 @@ #ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include "yaml-cpp/dll.h" +#include -#include "yaml-cpp/dll.h" +namespace YAML { +class Node; -namespace LHAPDF_YAML -{ - class Node; - - struct YAML_CPP_API _Null {}; - inline bool operator == (const _Null&, const _Null&) { return true; } - inline bool operator != (const _Null&, const _Null&) { return false; } - - YAML_CPP_API bool IsNull(const Node& node); // old API only - - extern YAML_CPP_API _Null Null; +struct YAML_CPP_API _Null {}; +inline bool operator==(const _Null&, const _Null&) { return true; } +inline bool operator!=(const _Null&, const _Null&) { return false; } + +YAML_CPP_API bool IsNull(const Node& node); // old API only +YAML_CPP_API bool IsNullString(const std::string& str); + +extern YAML_CPP_API _Null Null; } -#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/ostream.h b/src/yamlcpp/yaml-cpp/ostream.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/ostream.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include - -namespace LHAPDF_YAML -{ - class ostream - { - public: - ostream(); - ~ostream(); - - void reserve(unsigned size); - void put(char ch); - const char *str() const { return m_buffer; } - - unsigned row() const { return m_row; } - unsigned col() const { return m_col; } - unsigned pos() const { return m_pos; } - - private: - char *m_buffer; - unsigned m_pos; - unsigned m_size; - - unsigned m_row, m_col; - }; - - ostream& operator << (ostream& out, const char *str); - ostream& operator << (ostream& out, const std::string& str); - ostream& operator << (ostream& out, char ch); -} - -#endif // OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/ostream_wrapper.h b/src/yamlcpp/yaml-cpp/ostream_wrapper.h new file mode 100644 --- /dev/null +++ b/src/yamlcpp/yaml-cpp/ostream_wrapper.h @@ -0,0 +1,72 @@ +#ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#pragma once +#endif + +#include +#include + +#include "yaml-cpp/dll.h" + +namespace YAML { +class YAML_CPP_API ostream_wrapper { + public: + ostream_wrapper(); + explicit ostream_wrapper(std::ostream& stream); + ~ostream_wrapper(); + + void write(const std::string& str); + void write(const char* str, std::size_t size); + + void set_comment() { m_comment = true; } + + const char* str() const { + if (m_pStream) { + return 0; + } else { + m_buffer[m_pos] = '\0'; + return &m_buffer[0]; + } + } + + std::size_t row() const { return m_row; } + std::size_t col() const { return m_col; } + std::size_t pos() const { return m_pos; } + bool comment() const { return m_comment; } + + private: + void update_pos(char ch); + + private: + mutable std::vector m_buffer; + std::ostream* const m_pStream; + + std::size_t m_pos; + std::size_t m_row, m_col; + bool m_comment; +}; + +template +inline ostream_wrapper& operator<<(ostream_wrapper& stream, + const char(&str)[N]) { + stream.write(str, N - 1); + return stream; +} + +inline ostream_wrapper& operator<<(ostream_wrapper& stream, + const std::string& str) { + stream.write(str); + return stream; +} + +inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) { + stream.write(&ch, 1); + return stream; +} +} + +#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/parser.h b/src/yamlcpp/yaml-cpp/parser.h --- a/src/yamlcpp/yaml-cpp/parser.h +++ b/src/yamlcpp/yaml-cpp/parser.h @@ -1,51 +1,86 @@ #ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +#include +#include #include "yaml-cpp/dll.h" #include "yaml-cpp/noncopyable.h" -#include -#include -namespace LHAPDF_YAML -{ - struct Directives; - struct Mark; - struct Token; - class EventHandler; - class Node; - class Scanner; +namespace YAML { +class EventHandler; +class Node; +class Scanner; +struct Directives; +struct Token; - class YAML_CPP_API Parser: private noncopyable - { - public: - Parser(); - Parser(std::istream& in); - ~Parser(); +/** + * A parser turns a stream of bytes into one stream of "events" per YAML + * document in the input stream. + */ +class YAML_CPP_API Parser : private noncopyable { + public: + /** Constructs an empty parser (with no input. */ + Parser(); - operator bool() const; + /** + * Constructs a parser from the given input stream. The input stream must + * live as long as the parser. + */ + explicit Parser(std::istream& in); - void Load(std::istream& in); - bool HandleNextDocument(EventHandler& eventHandler); + ~Parser(); - bool GetNextDocument(Node& document); // old API only + /** Evaluates to true if the parser has some valid input to be read. */ + explicit operator bool() const; - void PrintTokens(std::ostream& out); + /** + * Resets the parser with the given input stream. Any existing state is + * erased. + */ + void Load(std::istream& in); - private: - void ParseDirectives(); - void HandleDirective(const Token& token); - void HandleYamlDirective(const Token& token); - void HandleTagDirective(const Token& token); + /** + * Handles the next document by calling events on the {@code eventHandler}. + * + * @throw a ParserException on error. + * @return false if there are no more documents + */ + bool HandleNextDocument(EventHandler& eventHandler); - private: - std::unique_ptr m_pScanner; - std::unique_ptr m_pDirectives; - }; + void PrintTokens(std::ostream& out); + + private: + /** + * Reads any directives that are next in the queue, setting the internal + * {@code m_pDirectives} state. + */ + void ParseDirectives(); + + void HandleDirective(const Token& token); + + /** + * Handles a "YAML" directive, which should be of the form 'major.minor' (like + * a version number). + */ + void HandleYamlDirective(const Token& token); + + /** + * Handles a "TAG" directive, which should be of the form 'handle prefix', + * where 'handle' is converted to 'prefix' in the file. + */ + void HandleTagDirective(const Token& token); + + private: + std::unique_ptr m_pScanner; + std::unique_ptr m_pDirectives; +}; } -#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/stlemitter.h b/src/yamlcpp/yaml-cpp/stlemitter.h --- a/src/yamlcpp/yaml-cpp/stlemitter.h +++ b/src/yamlcpp/yaml-cpp/stlemitter.h @@ -1,51 +1,51 @@ #ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif - #include #include #include #include -namespace LHAPDF_YAML -{ - template - inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { - emitter << BeginSeq; - for(typename Seq::const_iterator it=seq.begin();it!=seq.end();++it) - emitter << *it; - emitter << EndSeq; - return emitter; - } - - template - inline Emitter& operator << (Emitter& emitter, const std::vector& v) { - return EmitSeq(emitter, v); - } - - template - inline Emitter& operator << (Emitter& emitter, const std::list& v) { - return EmitSeq(emitter, v); - } - - template - inline Emitter& operator << (Emitter& emitter, const std::set& v) { - return EmitSeq(emitter, v); - } - - template - inline Emitter& operator << (Emitter& emitter, const std::map& m) { - typedef typename std::map map; - emitter << BeginMap; - for(typename map::const_iterator it=m.begin();it!=m.end();++it) - emitter << Key << it->first << Value << it->second; - emitter << EndMap; - return emitter; - } +namespace YAML { +template +inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { + emitter << BeginSeq; + for (typename Seq::const_iterator it = seq.begin(); it != seq.end(); ++it) + emitter << *it; + emitter << EndSeq; + return emitter; } -#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +template +inline Emitter& operator<<(Emitter& emitter, const std::vector& v) { + return EmitSeq(emitter, v); +} + +template +inline Emitter& operator<<(Emitter& emitter, const std::list& v) { + return EmitSeq(emitter, v); +} + +template +inline Emitter& operator<<(Emitter& emitter, const std::set& v) { + return EmitSeq(emitter, v); +} + +template +inline Emitter& operator<<(Emitter& emitter, const std::map& m) { + typedef typename std::map map; + emitter << BeginMap; + for (typename map::const_iterator it = m.begin(); it != m.end(); ++it) + emitter << Key << it->first << Value << it->second; + emitter << EndMap; + return emitter; +} +} + +#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/stlnode.h b/src/yamlcpp/yaml-cpp/stlnode.h deleted file mode 100644 --- a/src/yamlcpp/yaml-cpp/stlnode.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - - -#include -#include - -namespace LHAPDF_YAML -{ - template - void operator >> (const Node& node, std::vector& v) - { - v.clear(); - v.resize(node.size()); - for(unsigned i=0;i> v[i]; - } - - - template - void operator >> (const Node& node, std::map& m) - { - m.clear(); - for(Iterator it=node.begin();it!=node.end();++it) { - K k; - V v; - it.first() >> k; - it.second() >> v; - m[k] = v; - } - } -} - -#endif // STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/traits.h b/src/yamlcpp/yaml-cpp/traits.h --- a/src/yamlcpp/yaml-cpp/traits.h +++ b/src/yamlcpp/yaml-cpp/traits.h @@ -1,57 +1,103 @@ #ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif +namespace YAML { +template +struct is_numeric { + enum { value = false }; +}; -namespace LHAPDF_YAML -{ - template - struct is_numeric { enum { value = false }; }; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +#if defined(_MSC_VER) && (_MSC_VER < 1310) +template <> +struct is_numeric<__int64> { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +#else +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +#endif +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; +template <> +struct is_numeric { + enum { value = true }; +}; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; -#if defined(_MSC_VER) && (_MSC_VER < 1310) - template <> struct is_numeric <__int64> { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; -#else - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; -#endif - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; - template <> struct is_numeric { enum { value = true }; }; +template +struct enable_if_c { + typedef T type; +}; - template - struct enable_if_c { - typedef T type; - }; +template +struct enable_if_c {}; - template - struct enable_if_c {}; +template +struct enable_if : public enable_if_c {}; - template - struct enable_if : public enable_if_c {}; +template +struct disable_if_c { + typedef T type; +}; - template - struct disable_if_c { - typedef T type; - }; +template +struct disable_if_c {}; - template - struct disable_if_c {}; - - template - struct disable_if : public disable_if_c {}; +template +struct disable_if : public disable_if_c {}; } -#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - +#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/yamlcpp/yaml-cpp/yaml.h b/src/yamlcpp/yaml-cpp/yaml.h --- a/src/yamlcpp/yaml-cpp/yaml.h +++ b/src/yamlcpp/yaml-cpp/yaml.h @@ -1,17 +1,24 @@ #ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || \ + (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif #include "yaml-cpp/parser.h" #include "yaml-cpp/emitter.h" +#include "yaml-cpp/emitterstyle.h" #include "yaml-cpp/stlemitter.h" #include "yaml-cpp/exceptions.h" -#include "yaml-cpp/node.h" -#include "yaml-cpp/stlnode.h" -#include "yaml-cpp/iterator.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/node/impl.h" +#include "yaml-cpp/node/convert.h" +#include "yaml-cpp/node/iterator.h" +#include "yaml-cpp/node/detail/impl.h" +#include "yaml-cpp/node/parse.h" +#include "yaml-cpp/node/emit.h" -#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66