diff options
Diffstat (limited to '')
-rw-r--r-- | examples/c++/Makefile.am | 18 | ||||
-rw-r--r-- | examples/c++/Makefile.in (renamed from samples/c++/Makefile.in) | 201 | ||||
-rw-r--r-- | examples/c++/cxx_example1.vcproj (renamed from libconfig++_stub.vcproj) | 45 | ||||
-rw-r--r-- | examples/c++/cxx_example2.vcproj | 185 | ||||
-rw-r--r-- | examples/c++/cxx_example3.vcproj | 185 | ||||
-rw-r--r-- | examples/c++/cxx_example4.vcproj | 181 | ||||
-rw-r--r-- | examples/c++/example.cfg | 46 | ||||
-rw-r--r-- | examples/c++/example1.cpp | 151 | ||||
-rw-r--r-- | examples/c++/example2.cpp | 97 | ||||
-rw-r--r-- | examples/c++/example3.cpp | 71 | ||||
-rw-r--r-- | examples/c++/example4.cpp | 57 | ||||
-rw-r--r-- | examples/c++/invalid.cfg | 8 |
12 files changed, 1142 insertions, 103 deletions
diff --git a/examples/c++/Makefile.am b/examples/c++/Makefile.am new file mode 100644 index 0000000..5e0ae0d --- /dev/null +++ b/examples/c++/Makefile.am @@ -0,0 +1,18 @@ + +noinst_PROGRAMS = example1 example2 example3 example4 + +example1_SOURCES = example1.cpp + +example2_SOURCES = example2.cpp + +example3_SOURCES = example3.cpp + +example4_SOURCES = example4.cpp + +AM_CPPFLAGS = -I $(top_srcdir)/lib + +LDADD = $(top_builddir)/lib/libconfig++.la + +EXTRA_DIST = \ + example.cfg invalid.cfg \ + *.vcproj diff --git a/samples/c++/Makefile.in b/examples/c++/Makefile.in index b84b8dc..798c5db 100644 --- a/samples/c++/Makefile.in +++ b/examples/c++/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. @@ -16,8 +17,9 @@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@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 @@ -33,37 +35,39 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -noinst_PROGRAMS = stubcpp$(EXEEXT) sample1$(EXEEXT) sample2$(EXEEXT) \ - sample3$(EXEEXT) -subdir = samples/c++ +noinst_PROGRAMS = example1$(EXEEXT) example2$(EXEEXT) \ + example3$(EXEEXT) example4$(EXEEXT) +subdir = examples/c++ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +mkinstalldirs = $(SHELL) $(top_srcdir)/aux-build/mkinstalldirs CONFIG_HEADER = $(top_builddir)/ac_config.h CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am_sample1_OBJECTS = sample1.$(OBJEXT) -sample1_OBJECTS = $(am_sample1_OBJECTS) -sample1_LDADD = $(LDADD) -sample1_DEPENDENCIES = -am_sample2_OBJECTS = sample2.$(OBJEXT) -sample2_OBJECTS = $(am_sample2_OBJECTS) -sample2_LDADD = $(LDADD) -sample2_DEPENDENCIES = -am_sample3_OBJECTS = sample3.$(OBJEXT) -sample3_OBJECTS = $(am_sample3_OBJECTS) -sample3_LDADD = $(LDADD) -sample3_DEPENDENCIES = -am_stubcpp_OBJECTS = stubcpp.$(OBJEXT) -stubcpp_OBJECTS = $(am_stubcpp_OBJECTS) -stubcpp_LDADD = $(LDADD) -stubcpp_DEPENDENCIES = +am_example1_OBJECTS = example1.$(OBJEXT) +example1_OBJECTS = $(am_example1_OBJECTS) +example1_LDADD = $(LDADD) +example1_DEPENDENCIES = $(top_builddir)/lib/libconfig++.la +am_example2_OBJECTS = example2.$(OBJEXT) +example2_OBJECTS = $(am_example2_OBJECTS) +example2_LDADD = $(LDADD) +example2_DEPENDENCIES = $(top_builddir)/lib/libconfig++.la +am_example3_OBJECTS = example3.$(OBJEXT) +example3_OBJECTS = $(am_example3_OBJECTS) +example3_LDADD = $(LDADD) +example3_DEPENDENCIES = $(top_builddir)/lib/libconfig++.la +am_example4_OBJECTS = example4.$(OBJEXT) +example4_OBJECTS = $(am_example4_OBJECTS) +example4_LDADD = $(LDADD) +example4_DEPENDENCIES = $(top_builddir)/lib/libconfig++.la DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp +depcomp = $(SHELL) $(top_srcdir)/aux-build/depcomp am__depfiles_maybe = depfiles +am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -73,10 +77,10 @@ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(sample1_SOURCES) $(sample2_SOURCES) $(sample3_SOURCES) \ - $(stubcpp_SOURCES) -DIST_SOURCES = $(sample1_SOURCES) $(sample2_SOURCES) \ - $(sample3_SOURCES) $(stubcpp_SOURCES) +SOURCES = $(example1_SOURCES) $(example2_SOURCES) $(example3_SOURCES) \ + $(example4_SOURCES) +DIST_SOURCES = $(example1_SOURCES) $(example2_SOURCES) \ + $(example3_SOURCES) $(example4_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -102,20 +106,20 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ -ECHO = @ECHO@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ +FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ @@ -123,18 +127,23 @@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +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@ RANLIB = @RANLIB@ @@ -151,7 +160,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -201,12 +210,16 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -stubcpp_SOURCES = stubcpp.cpp -sample1_SOURCES = sample1.cpp -sample2_SOURCES = sample2.cpp -sample3_SOURCES = sample3.cpp -AM_CPPFLAGS = -I $(top_srcdir) -LDADD = -L../../.libs -lconfig++ +example1_SOURCES = example1.cpp +example2_SOURCES = example2.cpp +example3_SOURCES = example3.cpp +example4_SOURCES = example4.cpp +AM_CPPFLAGS = -I $(top_srcdir)/lib +LDADD = $(top_builddir)/lib/libconfig++.la +EXTRA_DIST = \ + example.cfg invalid.cfg \ + *.vcproj + all: all-am .SUFFIXES: @@ -215,14 +228,14 @@ $(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 \ - && exit 0; \ + ( 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 samples/c++/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu samples/c++/Makefile + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/c++/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/c++/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -240,25 +253,28 @@ $(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-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done -sample1$(EXEEXT): $(sample1_OBJECTS) $(sample1_DEPENDENCIES) - @rm -f sample1$(EXEEXT) - $(CXXLINK) $(sample1_OBJECTS) $(sample1_LDADD) $(LIBS) -sample2$(EXEEXT): $(sample2_OBJECTS) $(sample2_DEPENDENCIES) - @rm -f sample2$(EXEEXT) - $(CXXLINK) $(sample2_OBJECTS) $(sample2_LDADD) $(LIBS) -sample3$(EXEEXT): $(sample3_OBJECTS) $(sample3_DEPENDENCIES) - @rm -f sample3$(EXEEXT) - $(CXXLINK) $(sample3_OBJECTS) $(sample3_LDADD) $(LIBS) -stubcpp$(EXEEXT): $(stubcpp_OBJECTS) $(stubcpp_DEPENDENCIES) - @rm -f stubcpp$(EXEEXT) - $(CXXLINK) $(stubcpp_OBJECTS) $(stubcpp_LDADD) $(LIBS) + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +example1$(EXEEXT): $(example1_OBJECTS) $(example1_DEPENDENCIES) + @rm -f example1$(EXEEXT) + $(CXXLINK) $(example1_OBJECTS) $(example1_LDADD) $(LIBS) +example2$(EXEEXT): $(example2_OBJECTS) $(example2_DEPENDENCIES) + @rm -f example2$(EXEEXT) + $(CXXLINK) $(example2_OBJECTS) $(example2_LDADD) $(LIBS) +example3$(EXEEXT): $(example3_OBJECTS) $(example3_DEPENDENCIES) + @rm -f example3$(EXEEXT) + $(CXXLINK) $(example3_OBJECTS) $(example3_LDADD) $(LIBS) +example4$(EXEEXT): $(example4_OBJECTS) $(example4_DEPENDENCIES) + @rm -f example4$(EXEEXT) + $(CXXLINK) $(example4_OBJECTS) $(example4_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -266,28 +282,28 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sample1.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sample2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sample3.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stubcpp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example3.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example4.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< @@ -303,14 +319,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ + set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -318,29 +334,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ + test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique + $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -361,13 +382,17 @@ distdir: $(DISTFILES) 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 -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @@ -395,6 +420,7 @@ 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" @@ -416,6 +442,8 @@ dvi-am: html: html-am +html-am: + info: info-am info-am: @@ -424,18 +452,28 @@ 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 @@ -473,6 +511,7 @@ uninstall-am: mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am + # 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/libconfig++_stub.vcproj b/examples/c++/cxx_example1.vcproj index c89b53e..0a9207f 100644 --- a/libconfig++_stub.vcproj +++ b/examples/c++/cxx_example1.vcproj @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
- Name="libconfig++_stub"
- ProjectGUID="{2A94C9E9-A7C7-4770-A24C-694312ADB850}"
- RootNamespace="libconfig_stub"
+ Version="9.00"
+ Name="c++_example1"
+ ProjectGUID="{A1DF518C-A515-45A3-9B67-7D49F616DECC}"
+ RootNamespace="cxx_example1"
Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -39,10 +40,10 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
+ AdditionalIncludeDirectories="..\..\lib"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
RuntimeLibrary="3"
- WarningLevel="0"
+ CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -55,9 +56,10 @@ />
<Tool
Name="VCLinkerTool"
- LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -79,9 +81,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -110,9 +109,11 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
+ AdditionalIncludeDirectories="..\..\lib"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -125,8 +126,9 @@ />
<Tool
Name="VCLinkerTool"
- GenerateDebugInformation="false"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -148,36 +150,35 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
- <ProjectReference
- ReferencedProjectIdentifier="{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
- RelativePathToProject=".\libconfig++.vcproj"
- />
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
- RelativePath=".\samples\c++\stubcpp.cpp"
+ RelativePath=".\example1.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
+ <Filter
+ Name="Data Files"
+ >
+ <File
+ RelativePath=".\example.cfg"
+ >
+ </File>
+ </Filter>
</Files>
<Globals>
</Globals>
diff --git a/examples/c++/cxx_example2.vcproj b/examples/c++/cxx_example2.vcproj new file mode 100644 index 0000000..9b0f7fc --- /dev/null +++ b/examples/c++/cxx_example2.vcproj @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="c++_example2"
+ ProjectGUID="{DEBD09F1-33A1-41A9-9506-BC3E6FD053FD}"
+ RootNamespace="cxx_example2"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ RuntimeLibrary="3"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ >
+ <File
+ RelativePath=".\example2.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ >
+ </Filter>
+ <Filter
+ Name="Data Files"
+ >
+ <File
+ RelativePath=".\example.cfg"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/c++/cxx_example3.vcproj b/examples/c++/cxx_example3.vcproj new file mode 100644 index 0000000..8c85b98 --- /dev/null +++ b/examples/c++/cxx_example3.vcproj @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="c++_example3"
+ ProjectGUID="{8F2C54DE-BCC8-4CC7-81F3-FD0C04E8D5AE}"
+ RootNamespace="cxx_example3"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ RuntimeLibrary="3"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ >
+ <File
+ RelativePath=".\example3.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ >
+ </Filter>
+ <Filter
+ Name="Data Files"
+ >
+ <File
+ RelativePath=".\example.cfg"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/c++/cxx_example4.vcproj b/examples/c++/cxx_example4.vcproj new file mode 100644 index 0000000..ad452ae --- /dev/null +++ b/examples/c++/cxx_example4.vcproj @@ -0,0 +1,181 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="c++_example4"
+ ProjectGUID="{F631BE25-B384-4061-B7D1-E0C0E77D3A0C}"
+ RootNamespace="cxx_example4"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ RuntimeLibrary="3"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\lib"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ >
+ <File
+ RelativePath=".\example4.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ >
+ </Filter>
+ <Filter
+ Name="Data Files"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/c++/example.cfg b/examples/c++/example.cfg new file mode 100644 index 0000000..8f11dc6 --- /dev/null +++ b/examples/c++/example.cfg @@ -0,0 +1,46 @@ +// An example configuration file that stores information about a store. + +// Basic store information: +name = "Books, Movies & More"; + +// Store inventory: +inventory = +{ + books = ( { title = "Treasure Island"; + author = "Robert Louis Stevenson"; + price = 29.99; + qty = 5; }, + { title = "Snow Crash"; + author = "Neal Stephenson"; + price = 9.99; + qty = 8; } + ); + + movies = ( { title = "Brazil"; + media = "DVD"; + price = 19.99; + qty = 11; }, + { title = "The City of Lost Children"; + media = "DVD"; + price = 18.99; + qty = 5; }, + { title = "Memento"; + media = "Blu-Ray"; + price = 24.99; + qty = 20; + }, + { title = "Howard the Duck"; } + ); +}; + +// Store hours: +hours = +{ + mon = { open = 9; close = 18; }; + tue = { open = 9; close = 18; }; + wed = { open = 9; close = 18; }; + thu = { open = 9; close = 18; }; + fri = { open = 9; close = 20; }; + sat = { open = 9; close = 20; }; + sun = { open = 11; close = 16; }; +}; diff --git a/examples/c++/example1.cpp b/examples/c++/example1.cpp new file mode 100644 index 0000000..1fb5ff6 --- /dev/null +++ b/examples/c++/example1.cpp @@ -0,0 +1,151 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#include <iostream> +#include <iomanip> +#include <cstdlib> +#include <libconfig.h++> + +using namespace std; +using namespace libconfig; + +// This example reads the configuration file 'example.cfg' and displays +// some of its contents. + +int main(int argc, char **argv) +{ + Config cfg; + + // Read the file. If there is an error, report it and exit. + try + { + cfg.readFile("example.cfg"); + } + catch(const FileIOException &fioex) + { + std::cerr << "I/O error while reading file." << std::endl; + return(EXIT_FAILURE); + } + catch(const ParseException &pex) + { + std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine() + << " - " << pex.getError() << std::endl; + return(EXIT_FAILURE); + } + + // Get the store name. + try + { + string name = cfg.lookup("name"); + cout << "Store name: " << name << endl << endl; + } + catch(const SettingNotFoundException &nfex) + { + cerr << "No 'name' setting in configuration file." << endl; + } + + const Setting& root = cfg.getRoot(); + + // Output a list of all books in the inventory. + try + { + const Setting &books = root["inventory"]["books"]; + int count = books.getLength(); + + cout << setw(30) << left << "TITLE" << " " + << setw(30) << left << "AUTHOR" << " " + << setw(6) << left << "PRICE" << " " + << "QTY" + << endl; + + for(int i = 0; i < count; ++i) + { + const Setting &book = books[i]; + + // Only output the record if all of the expected fields are present. + string title, author; + double price; + int qty; + + if(!(book.lookupValue("title", title) + && book.lookupValue("author", author) + && book.lookupValue("price", price) + && book.lookupValue("qty", qty))) + continue; + + cout << setw(30) << left << title << " " + << setw(30) << left << author << " " + << '$' << setw(6) << right << price << " " + << qty + << endl; + } + cout << endl; + } + catch(const SettingNotFoundException &nfex) + { + // Ignore. + } + + // Output a list of all books in the inventory. + try + { + const Setting &movies = root["inventory"]["movies"]; + int count = movies.getLength(); + + cout << setw(30) << left << "TITLE" << " " + << setw(10) << left << "MEDIA" << " " + << setw(6) << left << "PRICE" << " " + << "QTY" + << endl; + + for(int i = 0; i < count; ++i) + { + const Setting &movie = movies[i]; + + // Only output the record if all of the expected fields are present. + string title, media; + double price; + int qty; + + if(!(movie.lookupValue("title", title) + && movie.lookupValue("media", media) + && movie.lookupValue("price", price) + && movie.lookupValue("qty", qty))) + continue; + + cout << setw(30) << left << title << " " + << setw(10) << left << media << " " + << '$' << setw(6) << right << price << " " + << qty + << endl; + } + cout << endl; + } + catch(const SettingNotFoundException &nfex) + { + // Ignore. + } + + return(EXIT_SUCCESS); +} + +// eof diff --git a/examples/c++/example2.cpp b/examples/c++/example2.cpp new file mode 100644 index 0000000..d0af0e8 --- /dev/null +++ b/examples/c++/example2.cpp @@ -0,0 +1,97 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#include <iostream> +#include <iomanip> +#include <cstdlib> +#include <libconfig.h++> + +using namespace std; +using namespace libconfig; + +// This example reads the configuration file 'example.cfg', adds a new +// movie record to the movies list, and writes the updated configuration to +// 'updated.cfg'. + +int main(int argc, char **argv) +{ + static const char *output_file = "updated.cfg"; + + Config cfg; + + // Read the file. If there is an error, report it and exit. + try + { + cfg.readFile("example.cfg"); + } + catch(const FileIOException &fioex) + { + std::cerr << "I/O error while reading file." << std::endl; + return(EXIT_FAILURE); + } + catch(const ParseException &pex) + { + std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine() + << " - " << pex.getError() << std::endl; + return(EXIT_FAILURE); + } + + // Find the 'movies' setting. Add intermediate settings if they don't yet + // exist. + Setting &root = cfg.getRoot(); + + if(! root.exists("inventory")) + root.add("inventory", Setting::TypeGroup); + + Setting &inventory = root["inventory"]; + + if(! inventory.exists("movies")) + inventory.add("movies", Setting::TypeList); + + Setting &movies = inventory["movies"]; + + // Create the new movie entry. + Setting &movie = movies.add(Setting::TypeGroup); + + movie.add("title", Setting::TypeString) = "Buckaroo Banzai"; + movie.add("media", Setting::TypeString) = "DVD"; + movie.add("price", Setting::TypeFloat) = 12.99; + movie.add("qty", Setting::TypeInt) = 20; + + // Write out the updated configuration. + try + { + cfg.writeFile(output_file); + cerr << "Updated configuration successfully written to: " << output_file + << endl; + + } + catch(const FileIOException &fioex) + { + cerr << "I/O error while writing file: " << output_file << endl; + return(EXIT_FAILURE); + } + + return(EXIT_SUCCESS); +} + +// eof diff --git a/examples/c++/example3.cpp b/examples/c++/example3.cpp new file mode 100644 index 0000000..da5caf5 --- /dev/null +++ b/examples/c++/example3.cpp @@ -0,0 +1,71 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#include <iostream> +#include <iomanip> +#include <cstdlib> +#include <libconfig.h++> + +using namespace std; +using namespace libconfig; + +// This example constructs a new configuration in memory and writes it to +// 'newconfig.cfg'. + +int main(int argc, char **argv) +{ + static const char *output_file = "newconfig.cfg"; + Config cfg; + + Setting &root = cfg.getRoot(); + + // Add some settings to the configuration. + Setting &address = root.add("address", Setting::TypeGroup); + + address.add("street", Setting::TypeString) = "1 Woz Way"; + address.add("city", Setting::TypeString) = "San Jose"; + address.add("state", Setting::TypeString) = "CA"; + address.add("zip", Setting::TypeInt) = 95110; + + Setting &array = root.add("array", Setting::TypeArray); + + for(int i = 0; i < 10; ++i) + array.add(Setting::TypeInt) = 10 * i; + + // Write out the new configuration. + try + { + cfg.writeFile(output_file); + cerr << "New configuration successfully written to: " << output_file + << endl; + + } + catch(const FileIOException &fioex) + { + cerr << "I/O error while writing file: " << output_file << endl; + return(EXIT_FAILURE); + } + + return(EXIT_SUCCESS); +} + +// eof diff --git a/examples/c++/example4.cpp b/examples/c++/example4.cpp new file mode 100644 index 0000000..b23f4c5 --- /dev/null +++ b/examples/c++/example4.cpp @@ -0,0 +1,57 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#include <iostream> +#include <iomanip> +#include <cstdlib> +#include <libconfig.h++> + +using namespace std; +using namespace libconfig; + +// This example demonstrates the handling of parsing errors in +// 'invalid.cfg'. + +int main(int argc, char **argv) +{ + Config cfg; + + try + { + cfg.readFile("invalid.cfg"); + } + catch(const FileIOException &fioex) + { + std::cerr << "File I/O error" << std::endl; + return(EXIT_FAILURE); + } + catch(const ParseException &pex) + { + std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine() + << " - " << pex.getError() << std::endl; + return(EXIT_FAILURE); + } + + return(EXIT_SUCCESS); +} + +// eof diff --git a/examples/c++/invalid.cfg b/examples/c++/invalid.cfg new file mode 100644 index 0000000..764b44d --- /dev/null +++ b/examples/c++/invalid.cfg @@ -0,0 +1,8 @@ +// An example configuration file with an invalid @include. + + +pi = 3.141592654; + +@include "missing.cfg" + +e = 2.718281828; |