From 5354989f45faa1faa4252b3644b26f17d2df50c2 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:12:27 +0200 Subject: [PATCH 01/38] add a newline for clarity Signed-off-by: FrancisANDRE --- Foundation/testsuite/src/CoreTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Foundation/testsuite/src/CoreTest.cpp b/Foundation/testsuite/src/CoreTest.cpp index bf8b03dce..fe1a73dca 100644 --- a/Foundation/testsuite/src/CoreTest.cpp +++ b/Foundation/testsuite/src/CoreTest.cpp @@ -194,7 +194,7 @@ void CoreTest::testEnvironment() catch (Exception&) { } - + std::cout << std::endl; std::cout << "OS Name: " << Environment::osName() << std::endl; std::cout << "OS Display Name: " << Environment::osDisplayName() << std::endl; std::cout << "OS Version: " << Environment::osVersion() << std::endl; From 462deab58bbd0db02b847f7d1af632b65b8d9091 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:13:56 +0200 Subject: [PATCH 02/38] condition assert for POCO_NO_FPENVIRONMENT platform Signed-off-by: FrancisANDRE --- Foundation/testsuite/src/FPETest.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Foundation/testsuite/src/FPETest.cpp b/Foundation/testsuite/src/FPETest.cpp index 3d79b9a67..5f4fba2b8 100644 --- a/Foundation/testsuite/src/FPETest.cpp +++ b/Foundation/testsuite/src/FPETest.cpp @@ -88,21 +88,27 @@ void FPETest::testFlags() volatile double b = 0; volatile double c = div(a, b); +#if !defined(POCO_NO_FPENVIRONMENT) assert (FPE::isFlag(FPE::FP_DIVIDE_BY_ZERO)); +#endif assert (FPE::isInfinite(c)); FPE::clearFlags(); a = 1.23456789e210; b = 9.87654321e210; c = mult(a, b); +#if !defined(POCO_NO_FPENVIRONMENT) assert (FPE::isFlag(FPE::FP_OVERFLOW)); +#endif assertEqualDelta(c, c, 0); FPE::clearFlags(); a = 1.23456789e-99; b = 9.87654321e210; c = div(a, b); +#if !defined(POCO_NO_FPENVIRONMENT) assert (FPE::isFlag(FPE::FP_UNDERFLOW)); +#endif assertEqualDelta(c, c, 0); } @@ -118,7 +124,8 @@ void FPETest::testFlags() void FPETest::testRound() { -#if !defined(__osf__) && !defined(__VMS) +#if !defined(__osf__) && !defined(__VMS) && !defined(POCO_NO_FPENVIRONMENT) + FPE::setRoundingMode(FPE::FP_ROUND_TONEAREST); assert (FPE::getRoundingMode() == FPE::FP_ROUND_TONEAREST); { From d1a8c11f98a8d6ffd68ef919c2cbad702bb17d49 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:15:13 +0200 Subject: [PATCH 03/38] skip SharedMemoryTest for DPOCO_NO_SHAREDMEMORY platform Signed-off-by: FrancisANDRE --- Foundation/testsuite/src/SharedMemoryTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Foundation/testsuite/src/SharedMemoryTest.cpp b/Foundation/testsuite/src/SharedMemoryTest.cpp index 1172239e1..3fc115ef4 100644 --- a/Foundation/testsuite/src/SharedMemoryTest.cpp +++ b/Foundation/testsuite/src/SharedMemoryTest.cpp @@ -89,8 +89,9 @@ CppUnit::Test* SharedMemoryTest::suite() { CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedMemoryTest"); +#if !defined(POCO_NO_SHAREDMEMORY) CppUnit_addTest(pSuite, SharedMemoryTest, testCreate); CppUnit_addTest(pSuite, SharedMemoryTest, testCreateFromFile); - +#endif return pSuite; } From 0926c9b752cb93cdce8657441a0d03b3788a4a75 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:16:45 +0200 Subject: [PATCH 04/38] add command line arguments as [component] [test] for unit testing a single test. Signed-off-by: FrancisANDRE --- build/script/runtests.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/build/script/runtests.sh b/build/script/runtests.sh index 501a2340b..5a1bc1787 100755 --- a/build/script/runtests.sh +++ b/build/script/runtests.sh @@ -4,17 +4,31 @@ # # A script for running the POCO testsuites. # -# usage: runtests +# usage: runtests [component] [test] # # If the environment variable EXCLUDE_TESTS is set, containing # a space-separated list of project names (as found in the # components file), these tests will be skipped. # -TESTRUNNER=./testrunner -TESTRUNNERARGS=-all +if [ "$POCO_BASE" = "" ] ; then + POCO_BASE=`pwd` +fi + +TESTRUNNER=./testrunner + +if [ "$1" = "" ] ; then + components=`cat $POCO_BASE/components` +else + components=$1 +fi + +if [ "$2" = "" ] ; then + TESTRUNNERARGS=-all +else + TESTRUNNERARGS=$2 +fi -components=`cat $POCO_BASE/components` if [ "$OSNAME" = "" ] ; then OSNAME=`uname` From 883800f56c5d0998964c88bd2cefb557082755d5 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:18:37 +0200 Subject: [PATCH 05/38] Use Cygwin instead of CYGWIN for POCO_HOST_OSNAME. Setup OSARCH_64BITS to 1 for Cygwin x86_64 platform. Signed-off-by: FrancisANDRE --- build/rules/global | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/rules/global b/build/rules/global index 0a582a1c5..f972e5ce6 100644 --- a/build/rules/global +++ b/build/rules/global @@ -68,7 +68,10 @@ endif # POCO_HOST_OSNAME = $(shell uname) ifeq ($(findstring CYGWIN,$(POCO_HOST_OSNAME)),CYGWIN) -POCO_HOST_OSNAME = CYGWIN +ifeq ($(findstring x86_64,$(POCO_HOST_OSNAME)),x86_64) +OSARCH_64BITS = 1 +endif +POCO_HOST_OSNAME = Cygwin endif ifeq ($(findstring MINGW,$(POCO_HOST_OSNAME)),MINGW) @@ -161,6 +164,9 @@ LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64 sparc64 ppc64),64,) else ifneq ($(DEBIANISH),) LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64 sparc64 ppc64),/x86_64-linux-gnu,) endif +ifeq ($(findstring Cygwin,$(POCO_HOST_OSNAME)),Cygwin) +LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64),64,) +endif # Default static lib extension STATICLIBLINKEXT = .a From fc46b81e56bdafae83442e3bff2b9b7a70e1a760 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:36:56 +0200 Subject: [PATCH 06/38] rename build/config/CYGWIN to build/config/Cygwin Signed-off-by: FrancisANDRE --- build/config/{CYGWIN => Cygwin} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build/config/{CYGWIN => Cygwin} (100%) diff --git a/build/config/CYGWIN b/build/config/Cygwin similarity index 100% rename from build/config/CYGWIN rename to build/config/Cygwin From e37f63c823ae2e0120b4a4a1f3fcc85d0cdb1f10 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Fri, 21 Aug 2015 14:36:56 +0200 Subject: [PATCH 07/38] rename build/config/CYGWIN to build/config/Cygwin Signed-off-by: FrancisANDRE --- build/config/{CYGWIN => Cygwin} | 0 configure | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename build/config/{CYGWIN => Cygwin} (100%) diff --git a/build/config/CYGWIN b/build/config/Cygwin similarity index 100% rename from build/config/CYGWIN rename to build/config/Cygwin diff --git a/configure b/configure index 9815e9fa1..52568a3fc 100755 --- a/configure +++ b/configure @@ -224,7 +224,7 @@ if [ "$config" = "" ] ; then config=`uname` case "$config" in CYGWIN*) - config=CYGWIN ;; + config=Cygwin ;; MINGW*) config=MinGW ;; esac From 083ade81359c115b40855b6f3f5567f9a3dfee31 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Sat, 22 Aug 2015 09:21:11 +0200 Subject: [PATCH 08/38] fix proper syntax for testing one test Signed-off-by: FrancisANDRE --- build/script/runtests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/script/runtests.sh b/build/script/runtests.sh index 5a1bc1787..38722b518 100755 --- a/build/script/runtests.sh +++ b/build/script/runtests.sh @@ -4,7 +4,7 @@ # # A script for running the POCO testsuites. # -# usage: runtests [component] [test] +# usage: runtests [component [test] ] # # If the environment variable EXCLUDE_TESTS is set, containing # a space-separated list of project names (as found in the From 293e7c91f7f03f3c032275c39a32fa476aab07c8 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Sat, 22 Aug 2015 09:54:29 +0200 Subject: [PATCH 09/38] use /dev/tty instead /dev/console on Cygwin otherwise a file acces check makes the test failing. Signed-off-by: FrancisANDRE --- Foundation/testsuite/src/FileTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Foundation/testsuite/src/FileTest.cpp b/Foundation/testsuite/src/FileTest.cpp index a9dfb1932..9b2117a11 100644 --- a/Foundation/testsuite/src/FileTest.cpp +++ b/Foundation/testsuite/src/FileTest.cpp @@ -228,7 +228,11 @@ void FileTest::testFileAttributes2() void FileTest::testFileAttributes3() { #if defined(POCO_OS_FAMILY_UNIX) +#if POCO_OS==POCO_OS_CYGWIN + File f("/dev/tty"); +#else File f("/dev/console"); +#endif #elif defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE) File f("CON"); #endif From 8cc9bda1e432d235f2e62450a7011c395e72a8ba Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Sat, 22 Aug 2015 12:37:03 +0200 Subject: [PATCH 10/38] insert a empty line for clarity. Signed-off-by: FrancisANDRE --- build/rules/compile | 12 +++++++++++- build/rules/lib | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/build/rules/compile b/build/rules/compile index 1945e3ca2..e888c5784 100644 --- a/build/rules/compile +++ b/build/rules/compile @@ -36,34 +36,42 @@ $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_SHARED) $(OB $(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d @echo "** Compiling" $< "(debug, static)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(STATICOPT_CXX) -c $< -o $@ - + @echo " " + $(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d @echo "** Compiling" $< "(release, static)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(STATICOPT_CXX) -c $< -o $@ + @echo " " $(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d @echo "** Compiling" $< "(debug, static)" $(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(STATICOPT_CC) -c $< -o $@ + @echo " " $(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d @echo "** Compiling" $< "(release, static)" $(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(STATICOPT_CC) -c $< -o $@ + @echo " " $(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d @echo "** Compiling" $< "(debug, shared)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $@ + @echo " " $(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d @echo "** Compiling" $< "(release, shared)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $@ + @echo " " $(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d @echo "** Compiling" $< "(debug, shared)" $(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(SHAREDOPT_CC) -c $< -o $@ + @echo " " $(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d @echo "** Compiling" $< "(release, shared)" $(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(SHAREDOPT_CC) -c $< -o $@ + @echo " " # # Rules for creating dependency information @@ -72,10 +80,12 @@ $(DEPPATH)/%.d: $(SRCDIR)/%.cpp @echo "** Creating dependency info for" $^ $(MKDIR) $(DEPPATH) $(DEP) $(SRCDIR)/$(patsubst %.d,%.cpp,$(notdir $@)) $@ $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_SHARED) $(OBJPATH_RELEASE_SHARED) $(INCLUDE) $(CXXFLAGS) + @echo " " $(DEPPATH)/%.d: $(SRCDIR)/%.c @echo "** Creating dependency info for" $^ $(MKDIR) $(DEPPATH) $(DEP) $(SRCDIR)/$(patsubst %.d,%.c,$(notdir $@)) $@ $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_SHARED) $(OBJPATH_RELEASE_SHARED) $(INCLUDE) $(CFLAGS) + @echo " " depend: $(addprefix $(DEPPATH)/,$(addsuffix .d,$(objects))) diff --git a/build/rules/lib b/build/rules/lib index 8126f4af3..8944fbaf9 100644 --- a/build/rules/lib +++ b/build/rules/lib @@ -52,18 +52,21 @@ $(LIB_DEBUG_STATIC): $(foreach o,$(objects),$(OBJPATH_DEBUG_STATIC)/$(o).o) $(LIB) $@ $^ $(RANLIB) $@ $(postbuild) + @echo " " $(LIB_RELEASE_STATIC): $(foreach o,$(objects),$(OBJPATH_RELEASE_STATIC)/$(o).o) @echo "** Building library (release)" $@ $(LIB) $@ $^ $(RANLIB) $@ $(postbuild) + @echo " " $(LIB_DEBUG_SHARED): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building shared library (debug)" $@ $(SHLIB) $(SHLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(SHLIBLN) $(LIB_DEBUG_SHARED) $(LIB_DEBUG_SHARED_LINK) $(postbuild) + @echo " " $(LIB_RELEASE_SHARED): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building shared library (release)" $@ @@ -71,6 +74,7 @@ $(LIB_RELEASE_SHARED): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) $(SHLIBLN) $(LIB_RELEASE_SHARED) $(LIB_RELEASE_SHARED_LINK) $(STRIPCMD) $(postbuild) + @echo " " # # Include the automatically generated dependency files From 09f5b06aaff90eb4925fa258eb392c5b40ad052a Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Sun, 23 Aug 2015 11:29:45 +0200 Subject: [PATCH 11/38] add an empty line for clarity. Signed-off-by: FrancisANDRE --- build/rules/dylib | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/rules/dylib b/build/rules/dylib index b4fa9b951..ada7e46d5 100644 --- a/build/rules/dylib +++ b/build/rules/dylib @@ -55,21 +55,25 @@ $(DYLIB_DEBUG): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building dynamic library (debug, shared)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) + @echo " " $(DYLIB_RELEASE): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building dynamic library (release, shared)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(postbuild) + @echo " " $(DYLIB_S_DEBUG): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building dynamic library (debug, static)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) + @echo " " $(DYLIB_S_RELEASE): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building dynamic library (release, static)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(postbuild) + @echo " " # # Include the automatically generated dependency files From f0a618b5a6d7cf0e3d5ac63a509d7aafacb9f115 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Sun, 23 Aug 2015 15:44:49 +0200 Subject: [PATCH 12/38] add $(POCO_BASE)/build/config/$(POCO_CONFIG) as a prerequisite Signed-off-by: FrancisANDRE --- build/rules/compile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/rules/compile b/build/rules/compile index e888c5784..1a2d3f27e 100644 --- a/build/rules/compile +++ b/build/rules/compile @@ -33,42 +33,42 @@ $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_SHARED) $(OB # # Rules for compiling # -$(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d +$(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, static)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(STATICOPT_CXX) -c $< -o $@ @echo " " -$(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d +$(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, static)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(STATICOPT_CXX) -c $< -o $@ @echo " " -$(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d +$(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, static)" $(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(STATICOPT_CC) -c $< -o $@ @echo " " -$(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d +$(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, static)" $(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(STATICOPT_CC) -c $< -o $@ @echo " " -$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d +$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, shared)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $@ @echo " " -$(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d +$(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, shared)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $@ @echo " " -$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d +$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, shared)" $(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(SHAREDOPT_CC) -c $< -o $@ @echo " " -$(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d +$(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, shared)" $(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(SHAREDOPT_CC) -c $< -o $@ @echo " " From 6c2398226bd52f5dc04f428b51c10a9661ce7089 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Sun, 23 Aug 2015 15:45:45 +0200 Subject: [PATCH 13/38] insert an empty line for clarity Signed-off-by: FrancisANDRE --- build/rules/exec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/rules/exec b/build/rules/exec index d65d09b6d..db6cbc2ee 100644 --- a/build/rules/exec +++ b/build/rules/exec @@ -43,23 +43,27 @@ $(EXEC_DEBUG_STATIC): $(foreach o,$(objects),$(OBJPATH_DEBUG_STATIC)/$(o).o) @echo "** Building executable (debug)" $@ $(LINK) $(LINKFLAGS) $(DEBUGOPT_LINK) $(STATICOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) + @echo " " $(EXEC_RELEASE_STATIC): $(foreach o,$(objects),$(OBJPATH_RELEASE_STATIC)/$(o).o) @echo "** Building executable (release)" $@ $(LINK) $(LINKFLAGS) $(RELEASEOPT_LINK) $(STATICOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(STRIPCMD) $(postbuild) + @echo " " $(EXEC_DEBUG_SHARED): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building shared executable (debug)" $@ $(LINK) $(LINKFLAGS) $(DEBUGOPT_LINK) $(SHAREDOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) + @echo " " $(EXEC_RELEASE_SHARED): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building shared executable (release)" $@ $(LINK) $(LINKFLAGS) $(RELEASEOPT_LINK) $(SHAREDOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(STRIPCMD) $(postbuild) + @echo " " # # Include the automatically generated dependency files From ac879caa46784e068efe985b47e7e7143fdc100e Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Mon, 24 Aug 2015 11:25:44 +0200 Subject: [PATCH 14/38] Cygwin supports Unix IPCs thru a system process started by /usr/sbin/cygserver. So, the flag -DPOCO_NO_SHAREDMEMORY can be removed. Signed-off-by: FrancisANDRE --- build/config/Cygwin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/config/Cygwin b/build/config/Cygwin index 177723ff5..4538cd69f 100644 --- a/build/config/Cygwin +++ b/build/config/Cygwin @@ -1,7 +1,7 @@ # # $Id$ # -# CYGWIN +# Cygwin # # Make settings for Cygwin on WinXP/gcc 3.4 # @@ -42,7 +42,7 @@ SHAREDLIBLINKEXT = .dll CFLAGS = CFLAGS32 = CFLAGS64 = -CXXFLAGS = -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY -Wa,-mbig-obj +CXXFLAGS = -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -Wa,-mbig-obj CXXFLAGS32 = CXXFLAGS64 = LINKFLAGS = From 01d029f28240ba6b905b093eae1e4d468d61990d Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Mon, 24 Aug 2015 11:27:33 +0200 Subject: [PATCH 15/38] remove the LIBSUFFIX setup since the x86_64 directory serves already as discriminator. Signed-off-by: FrancisANDRE --- build/rules/global | 3 --- 1 file changed, 3 deletions(-) diff --git a/build/rules/global b/build/rules/global index f972e5ce6..0f4e08968 100644 --- a/build/rules/global +++ b/build/rules/global @@ -164,9 +164,6 @@ LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64 sparc64 ppc64),64,) else ifneq ($(DEBIANISH),) LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64 sparc64 ppc64),/x86_64-linux-gnu,) endif -ifeq ($(findstring Cygwin,$(POCO_HOST_OSNAME)),Cygwin) -LIB64SUFFIX = $(if $(filter $(OSARCH),x86_64),64,) -endif # Default static lib extension STATICLIBLINKEXT = .a From 56b6995a5b83c377c2799e89561e2fa8d995846b Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Mon, 24 Aug 2015 11:28:12 +0200 Subject: [PATCH 16/38] add separation line for BUILDING FOR WINDOWS CE. Signed-off-by: FrancisANDRE --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 9d9520fc6..183ecdc30 100644 --- a/README +++ b/README @@ -153,6 +153,7 @@ message compiler may fail when building the Foundation library. BUILDING FOR WINDOWS CE +======================= Building for Windows CE is supported with Microsoft Visual Studio 2008. Unless you have the Digi JumpStart Windows CE 6.0 SDK installed, you'll From c7469d0ea1c599625efa07b78c3b5f23853bcb67 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Mon, 24 Aug 2015 11:36:38 +0200 Subject: [PATCH 17/38] remove the inserted line. Signed-off-by: FrancisANDRE --- build/rules/compile | 10 ---------- build/rules/dylib | 4 ---- build/rules/exec | 4 ---- build/rules/lib | 4 ---- 4 files changed, 22 deletions(-) diff --git a/build/rules/compile b/build/rules/compile index 1a2d3f27e..e8d94bd95 100644 --- a/build/rules/compile +++ b/build/rules/compile @@ -36,42 +36,34 @@ $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_SHARED) $(OB $(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, static)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(STATICOPT_CXX) -c $< -o $@ - @echo " " $(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, static)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(STATICOPT_CXX) -c $< -o $@ - @echo " " $(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, static)" $(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(STATICOPT_CC) -c $< -o $@ - @echo " " $(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, static)" $(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(STATICOPT_CC) -c $< -o $@ - @echo " " $(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, shared)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $@ - @echo " " $(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, shared)" $(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $@ - @echo " " $(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(debug, shared)" $(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(SHAREDOPT_CC) -c $< -o $@ - @echo " " $(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d $(POCO_BASE)/build/config/$(POCO_CONFIG) @echo "** Compiling" $< "(release, shared)" $(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(SHAREDOPT_CC) -c $< -o $@ - @echo " " # # Rules for creating dependency information @@ -80,12 +72,10 @@ $(DEPPATH)/%.d: $(SRCDIR)/%.cpp @echo "** Creating dependency info for" $^ $(MKDIR) $(DEPPATH) $(DEP) $(SRCDIR)/$(patsubst %.d,%.cpp,$(notdir $@)) $@ $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_SHARED) $(OBJPATH_RELEASE_SHARED) $(INCLUDE) $(CXXFLAGS) - @echo " " $(DEPPATH)/%.d: $(SRCDIR)/%.c @echo "** Creating dependency info for" $^ $(MKDIR) $(DEPPATH) $(DEP) $(SRCDIR)/$(patsubst %.d,%.c,$(notdir $@)) $@ $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_SHARED) $(OBJPATH_RELEASE_SHARED) $(INCLUDE) $(CFLAGS) - @echo " " depend: $(addprefix $(DEPPATH)/,$(addsuffix .d,$(objects))) diff --git a/build/rules/dylib b/build/rules/dylib index ada7e46d5..b4fa9b951 100644 --- a/build/rules/dylib +++ b/build/rules/dylib @@ -55,25 +55,21 @@ $(DYLIB_DEBUG): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building dynamic library (debug, shared)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) - @echo " " $(DYLIB_RELEASE): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building dynamic library (release, shared)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(postbuild) - @echo " " $(DYLIB_S_DEBUG): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building dynamic library (debug, static)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) - @echo " " $(DYLIB_S_RELEASE): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building dynamic library (release, static)" $@ $(DYLIB) $(DYLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(postbuild) - @echo " " # # Include the automatically generated dependency files diff --git a/build/rules/exec b/build/rules/exec index db6cbc2ee..d65d09b6d 100644 --- a/build/rules/exec +++ b/build/rules/exec @@ -43,27 +43,23 @@ $(EXEC_DEBUG_STATIC): $(foreach o,$(objects),$(OBJPATH_DEBUG_STATIC)/$(o).o) @echo "** Building executable (debug)" $@ $(LINK) $(LINKFLAGS) $(DEBUGOPT_LINK) $(STATICOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) - @echo " " $(EXEC_RELEASE_STATIC): $(foreach o,$(objects),$(OBJPATH_RELEASE_STATIC)/$(o).o) @echo "** Building executable (release)" $@ $(LINK) $(LINKFLAGS) $(RELEASEOPT_LINK) $(STATICOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(STRIPCMD) $(postbuild) - @echo " " $(EXEC_DEBUG_SHARED): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building shared executable (debug)" $@ $(LINK) $(LINKFLAGS) $(DEBUGOPT_LINK) $(SHAREDOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(postbuild) - @echo " " $(EXEC_RELEASE_SHARED): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building shared executable (release)" $@ $(LINK) $(LINKFLAGS) $(RELEASEOPT_LINK) $(SHAREDOPT_LINK) -o $@ $^ $(LIBRARY) $(TARGET_LIBS_RELEASE) $(SYSLIBS) $(STRIPCMD) $(postbuild) - @echo " " # # Include the automatically generated dependency files diff --git a/build/rules/lib b/build/rules/lib index 8944fbaf9..8126f4af3 100644 --- a/build/rules/lib +++ b/build/rules/lib @@ -52,21 +52,18 @@ $(LIB_DEBUG_STATIC): $(foreach o,$(objects),$(OBJPATH_DEBUG_STATIC)/$(o).o) $(LIB) $@ $^ $(RANLIB) $@ $(postbuild) - @echo " " $(LIB_RELEASE_STATIC): $(foreach o,$(objects),$(OBJPATH_RELEASE_STATIC)/$(o).o) @echo "** Building library (release)" $@ $(LIB) $@ $^ $(RANLIB) $@ $(postbuild) - @echo " " $(LIB_DEBUG_SHARED): $(foreach o,$(objects),$(OBJPATH_DEBUG_SHARED)/$(o).o) @echo "** Building shared library (debug)" $@ $(SHLIB) $(SHLIBFLAGS) $^ $(LIBRARY) $(TARGET_LIBS_DEBUG) $(SYSLIBS) $(SHLIBLN) $(LIB_DEBUG_SHARED) $(LIB_DEBUG_SHARED_LINK) $(postbuild) - @echo " " $(LIB_RELEASE_SHARED): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) @echo "** Building shared library (release)" $@ @@ -74,7 +71,6 @@ $(LIB_RELEASE_SHARED): $(foreach o,$(objects),$(OBJPATH_RELEASE_SHARED)/$(o).o) $(SHLIBLN) $(LIB_RELEASE_SHARED) $(LIB_RELEASE_SHARED_LINK) $(STRIPCMD) $(postbuild) - @echo " " # # Include the automatically generated dependency files From e0c38261b6d5d33ad02a1f69935e7c7493774bd6 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Mon, 24 Aug 2015 11:47:24 +0200 Subject: [PATCH 18/38] add specific Cygwin setup for running Foundation tests. Signed-off-by: FrancisANDRE --- build/script/runtests.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build/script/runtests.sh b/build/script/runtests.sh index 38722b518..728c99bb5 100755 --- a/build/script/runtests.sh +++ b/build/script/runtests.sh @@ -10,6 +10,17 @@ # a space-separated list of project names (as found in the # components file), these tests will be skipped. # +# Cygwin specific setup. +# ---------------------- +# On Cygwin, Unix IPC are provided by a separate process daemon +# named cygserver, which should be started once before running any +# test from Foundation. +# 1/ Open a separate Cygwin terminal with Administrator privilege +# 2/ run the command: cygserver-configure +# 3/ Start the cygserver: nohup /usr/sbin/cygserver & +# 4/ close the separate terminal +# 5/ run the Foundation tests: build/script/runtests.sh Foundation +# if [ "$POCO_BASE" = "" ] ; then POCO_BASE=`pwd` From b0989b0828f7be3695f6771ca442402196fb8c63 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Thu, 27 Aug 2015 08:42:11 +0200 Subject: [PATCH 19/38] replace duplicate define for HP_ACC by the COMPAQ one for DEC CXX Signed-off-by: FrancisANDRE --- Foundation/include/Poco/Platform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Foundation/include/Poco/Platform.h b/Foundation/include/Poco/Platform.h index 29660e25b..7330b3797 100644 --- a/Foundation/include/Poco/Platform.h +++ b/Foundation/include/Poco/Platform.h @@ -242,8 +242,8 @@ #define POCO_COMPILER_CBUILDER #elif defined (__DMC__) #define POCO_COMPILER_DMARS -#elif defined (__HP_aCC) - #define POCO_COMPILER_HP_ACC +#elif defined (__DECCXX) + #define POCO_COMPILER_COMPAC #elif (defined (__xlc__) || defined (__xlC__)) && defined(__IBMCPP__) #define POCO_COMPILER_IBM_XLC // IBM XL C++ #elif defined (__IBMCPP__) && defined(__COMPILER_VER__) From 7f01fbc3db348916f0908fa54dccfb762a32570d Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Thu, 27 Aug 2015 08:48:26 +0200 Subject: [PATCH 20/38] add std::string SharedLibrary::prefix() for building library name that complies with Cygwin standard. Signed-off-by: FrancisANDRE --- Foundation/include/Poco/SharedLibrary.h | 6 ++++++ Foundation/include/Poco/SharedLibrary_HPUX.h | 1 + Foundation/include/Poco/SharedLibrary_UNIX.h | 1 + Foundation/include/Poco/SharedLibrary_VMS.h | 1 + Foundation/include/Poco/SharedLibrary_VX.h | 1 + Foundation/include/Poco/SharedLibrary_WIN32.h | 1 + Foundation/include/Poco/SharedLibrary_WIN32U.h | 1 + Foundation/src/SharedLibrary.cpp | 6 ++++++ Foundation/src/SharedLibrary_HPUX.cpp | 6 ++++++ Foundation/src/SharedLibrary_UNIX.cpp | 18 ++++++++++++++---- Foundation/src/SharedLibrary_VMS.cpp | 6 ++++++ Foundation/src/SharedLibrary_VX.cpp | 6 ++++++ Foundation/src/SharedLibrary_WIN32.cpp | 6 ++++++ Foundation/src/SharedLibrary_WIN32U.cpp | 6 ++++++ 14 files changed, 62 insertions(+), 4 deletions(-) diff --git a/Foundation/include/Poco/SharedLibrary.h b/Foundation/include/Poco/SharedLibrary.h index d34349f64..e8a7b19da 100644 --- a/Foundation/include/Poco/SharedLibrary.h +++ b/Foundation/include/Poco/SharedLibrary.h @@ -118,6 +118,12 @@ public: /// specified in a call to load() or the /// constructor. + static std::string prefix(); + /// Returns the platform-specific filename prefix + /// for shared libraries. + /// Most platforms would return an empty string, but + /// on Cygwin, the "cyg" prefix will be returned. + static std::string suffix(); /// Returns the platform-specific filename suffix /// for shared libraries (including the period). diff --git a/Foundation/include/Poco/SharedLibrary_HPUX.h b/Foundation/include/Poco/SharedLibrary_HPUX.h index f77b02ae6..a25f825e5 100644 --- a/Foundation/include/Poco/SharedLibrary_HPUX.h +++ b/Foundation/include/Poco/SharedLibrary_HPUX.h @@ -38,6 +38,7 @@ protected: bool isLoadedImpl() const; void* findSymbolImpl(const std::string& name); const std::string& getPathImpl() const; + static std::string prefixImpl(); static std::string suffixImpl(); private: diff --git a/Foundation/include/Poco/SharedLibrary_UNIX.h b/Foundation/include/Poco/SharedLibrary_UNIX.h index ee968d1d2..a6eed76d1 100644 --- a/Foundation/include/Poco/SharedLibrary_UNIX.h +++ b/Foundation/include/Poco/SharedLibrary_UNIX.h @@ -43,6 +43,7 @@ protected: bool isLoadedImpl() const; void* findSymbolImpl(const std::string& name); const std::string& getPathImpl() const; + static std::string prefixImpl(); static std::string suffixImpl(); private: diff --git a/Foundation/include/Poco/SharedLibrary_VMS.h b/Foundation/include/Poco/SharedLibrary_VMS.h index 8cb701fcf..096cef6af 100644 --- a/Foundation/include/Poco/SharedLibrary_VMS.h +++ b/Foundation/include/Poco/SharedLibrary_VMS.h @@ -37,6 +37,7 @@ protected: bool isLoadedImpl() const; void* findSymbolImpl(const std::string& name); const std::string& getPathImpl() const; + static std::string prefixImpl(); static std::string suffixImpl(); private: diff --git a/Foundation/include/Poco/SharedLibrary_VX.h b/Foundation/include/Poco/SharedLibrary_VX.h index ef1502310..e76a3fcea 100644 --- a/Foundation/include/Poco/SharedLibrary_VX.h +++ b/Foundation/include/Poco/SharedLibrary_VX.h @@ -38,6 +38,7 @@ protected: bool isLoadedImpl() const; void* findSymbolImpl(const std::string& name); const std::string& getPathImpl() const; + static std::string prefixImpl(); static std::string suffixImpl(); private: diff --git a/Foundation/include/Poco/SharedLibrary_WIN32.h b/Foundation/include/Poco/SharedLibrary_WIN32.h index e949ab323..61550c2ad 100644 --- a/Foundation/include/Poco/SharedLibrary_WIN32.h +++ b/Foundation/include/Poco/SharedLibrary_WIN32.h @@ -37,6 +37,7 @@ protected: bool isLoadedImpl() const; void* findSymbolImpl(const std::string& name); const std::string& getPathImpl() const; + static std::string prefixImpl(); static std::string suffixImpl(); private: diff --git a/Foundation/include/Poco/SharedLibrary_WIN32U.h b/Foundation/include/Poco/SharedLibrary_WIN32U.h index f116ad341..66d447379 100644 --- a/Foundation/include/Poco/SharedLibrary_WIN32U.h +++ b/Foundation/include/Poco/SharedLibrary_WIN32U.h @@ -37,6 +37,7 @@ protected: bool isLoadedImpl() const; void* findSymbolImpl(const std::string& name); const std::string& getPathImpl() const; + static std::string prefixImpl(); static std::string suffixImpl(); private: diff --git a/Foundation/src/SharedLibrary.cpp b/Foundation/src/SharedLibrary.cpp index f847d9fb6..8ba80e9c4 100644 --- a/Foundation/src/SharedLibrary.cpp +++ b/Foundation/src/SharedLibrary.cpp @@ -104,6 +104,12 @@ const std::string& SharedLibrary::getPath() const } +std::string SharedLibrary::prefix() +{ + return prefixImpl(); +} + + std::string SharedLibrary::suffix() { return suffixImpl(); diff --git a/Foundation/src/SharedLibrary_HPUX.cpp b/Foundation/src/SharedLibrary_HPUX.cpp index a9998d460..25bc00460 100644 --- a/Foundation/src/SharedLibrary_HPUX.cpp +++ b/Foundation/src/SharedLibrary_HPUX.cpp @@ -83,6 +83,12 @@ const std::string& SharedLibraryImpl::getPathImpl() const } +std::string SharedLibraryImpl::prefixImpl() +{ + return ""; +} + + std::string SharedLibraryImpl::suffixImpl() { #if defined(_DEBUG) diff --git a/Foundation/src/SharedLibrary_UNIX.cpp b/Foundation/src/SharedLibrary_UNIX.cpp index 0153fabbe..663cb90b5 100644 --- a/Foundation/src/SharedLibrary_UNIX.cpp +++ b/Foundation/src/SharedLibrary_UNIX.cpp @@ -20,7 +20,7 @@ // Note: cygwin is missing RTLD_LOCAL, set it to 0 -#if defined(__CYGWIN__) && !defined(RTLD_LOCAL) +#if POCO_OS == POCO_OS_CYGWIN && !defined(RTLD_LOCAL) #define RTLD_LOCAL 0 #endif @@ -99,21 +99,31 @@ const std::string& SharedLibraryImpl::getPathImpl() const } +std::string SharedLibraryImpl::prefixImpl() +{ +#if POCO_OS == POCO_OS_CYGWIN + return "cyg"; +#else + return ""; +#endif +} + + std::string SharedLibraryImpl::suffixImpl() { -#if defined(__APPLE__) +#if POCO_OS == POCO_OS_MAC_OS_X #if defined(_DEBUG) return "d.dylib"; #else return ".dylib"; #endif -#elif defined(hpux) || defined(_hpux) +#elif POCO_OS == POCO_OS_HPUX #if defined(_DEBUG) return "d.sl"; #else return ".sl"; #endif -#elif defined(__CYGWIN__) +#elif POCO_OS == POCO_OS_CYGWIN #if defined(_DEBUG) return "d.dll"; #else diff --git a/Foundation/src/SharedLibrary_VMS.cpp b/Foundation/src/SharedLibrary_VMS.cpp index 3bd6ee0c0..92dac3d5b 100644 --- a/Foundation/src/SharedLibrary_VMS.cpp +++ b/Foundation/src/SharedLibrary_VMS.cpp @@ -106,6 +106,12 @@ const std::string& SharedLibraryImpl::getPathImpl() const } +std::string SharedLibraryImpl::prefixImpl() +{ + return ""; +} + + std::string SharedLibraryImpl::suffixImpl() { #if defined(_DEBUG) diff --git a/Foundation/src/SharedLibrary_VX.cpp b/Foundation/src/SharedLibrary_VX.cpp index 0901ff44a..573faeb76 100644 --- a/Foundation/src/SharedLibrary_VX.cpp +++ b/Foundation/src/SharedLibrary_VX.cpp @@ -128,6 +128,12 @@ const std::string& SharedLibraryImpl::getPathImpl() const } +std::string SharedLibraryImpl::prefixImpl() +{ + return ""; +} + + std::string SharedLibraryImpl::suffixImpl() { return ".out"; diff --git a/Foundation/src/SharedLibrary_WIN32.cpp b/Foundation/src/SharedLibrary_WIN32.cpp index ba7dabf2c..42751de1e 100644 --- a/Foundation/src/SharedLibrary_WIN32.cpp +++ b/Foundation/src/SharedLibrary_WIN32.cpp @@ -87,6 +87,12 @@ const std::string& SharedLibraryImpl::getPathImpl() const } +std::string SharedLibraryImpl::prefixImpl() +{ + return ""; +} + + std::string SharedLibraryImpl::suffixImpl() { #if defined(_DEBUG) diff --git a/Foundation/src/SharedLibrary_WIN32U.cpp b/Foundation/src/SharedLibrary_WIN32U.cpp index 650ac0513..2b50a0df6 100644 --- a/Foundation/src/SharedLibrary_WIN32U.cpp +++ b/Foundation/src/SharedLibrary_WIN32U.cpp @@ -98,6 +98,12 @@ const std::string& SharedLibraryImpl::getPathImpl() const } +std::string SharedLibraryImpl::prefixImpl() +{ + return ""; +} + + std::string SharedLibraryImpl::suffixImpl() { #if defined(_DEBUG) From 2aa6657717b86079116e83bd24918fdfacfb6fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Bleuz=C3=A9?= Date: Thu, 2 Jul 2015 10:00:11 +0200 Subject: [PATCH 21/38] Crypto: Add any digest to key generation. --- Crypto/include/Poco/Crypto/CipherKey.h | 15 +++++++++++++-- Crypto/include/Poco/Crypto/CipherKeyImpl.h | 11 +++++++---- Crypto/src/CipherKey.cpp | 5 +++-- Crypto/src/CipherKeyImpl.cpp | 18 +++++++++++++----- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Crypto/include/Poco/Crypto/CipherKey.h b/Crypto/include/Poco/Crypto/CipherKey.h index 792de73b2..367afc28e 100644 --- a/Crypto/include/Poco/Crypto/CipherKey.h +++ b/Crypto/include/Poco/Crypto/CipherKey.h @@ -47,6 +47,16 @@ class Crypto_API CipherKey /// std::string salt("asdff8723lasdf(**923412"); /// CipherKey key("aes-256", password, salt); /// + /// You may also control the digest and the number of iterations used to generate the key + /// by specifying the specific values. Here we create a key with the same data as before, + /// except that we use 100 iterations instead of DEFAULT_ITERATION_COUNT, and sha1 instead of + /// the default md5: + /// + /// std::string password = "secret"; + /// std::string salt("asdff8723lasdf(**923412"); + /// std::string digest ("sha1"); + /// CipherKey key("aes-256", password, salt, 100, digest); + /// { public: typedef CipherKeyImpl::Mode Mode; @@ -63,9 +73,10 @@ public: CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt = "", - int iterationCount = DEFAULT_ITERATION_COUNT); + int iterationCount = DEFAULT_ITERATION_COUNT, + const std::string& digest = "md5"); /// Creates a new CipherKeyImpl object using the given - /// cipher name, passphrase, salt value and iteration count. + /// cipher name, passphrase, salt value, iteration count and digest. CipherKey(const std::string& name, const ByteVec& key, diff --git a/Crypto/include/Poco/Crypto/CipherKeyImpl.h b/Crypto/include/Poco/Crypto/CipherKeyImpl.h index 3b9e7bfce..6b2a6a8b2 100644 --- a/Crypto/include/Poco/Crypto/CipherKeyImpl.h +++ b/Crypto/include/Poco/Crypto/CipherKeyImpl.h @@ -53,17 +53,19 @@ public: MODE_OFB /// Output feedback }; - CipherKeyImpl(const std::string& name, - const std::string& passphrase, + CipherKeyImpl(const std::string& name, + const std::string& passphrase, const std::string& salt, - int iterationCount); + int iterationCount, + const std::string &digest); /// Creates a new CipherKeyImpl object, using /// the given cipher name, passphrase, salt value /// and iteration count. CipherKeyImpl(const std::string& name, const ByteVec& key, - const ByteVec& iv); + const ByteVec& iv + ); /// Creates a new CipherKeyImpl object, using the /// given cipher name, key and initialization vector. @@ -118,6 +120,7 @@ private: private: const EVP_CIPHER* _pCipher; + const EVP_MD* _pDigest; std::string _name; ByteVec _key; ByteVec _iv; diff --git a/Crypto/src/CipherKey.cpp b/Crypto/src/CipherKey.cpp index eb535e9d8..82a099776 100644 --- a/Crypto/src/CipherKey.cpp +++ b/Crypto/src/CipherKey.cpp @@ -21,8 +21,9 @@ namespace Poco { namespace Crypto { -CipherKey::CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt, int iterationCount): - _pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount)) +CipherKey::CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt, int iterationCount, + const std::string &digest): + _pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount, digest)) { } diff --git a/Crypto/src/CipherKeyImpl.cpp b/Crypto/src/CipherKeyImpl.cpp index bcd7452c6..7f496aa07 100644 --- a/Crypto/src/CipherKeyImpl.cpp +++ b/Crypto/src/CipherKeyImpl.cpp @@ -27,11 +27,13 @@ namespace Poco { namespace Crypto { -CipherKeyImpl::CipherKeyImpl(const std::string& name, +CipherKeyImpl::CipherKeyImpl(const std::string& name, const std::string& passphrase, const std::string& salt, - int iterationCount): + int iterationCount, + const std::string& digest): _pCipher(0), + _pDigest(0), _name(name), _key(), _iv() @@ -42,6 +44,13 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name, if (!_pCipher) throw Poco::NotFoundException("Cipher " + name + " was not found"); + + _pDigest = EVP_get_digestbyname(digest.c_str()); + + if (!_pDigest) + throw Poco::NotFoundException("Digest " + name + " was not found"); + + _key = ByteVec(keySize()); _iv = ByteVec(ivSize()); generateKey(passphrase, salt, iterationCount); @@ -145,7 +154,6 @@ void CipherKeyImpl::generateKey( // OpenSSL documentation specifies that the salt must be an 8-byte array. unsigned char saltBytes[8]; - if (!salt.empty()) { int len = static_cast(salt.size()); @@ -156,10 +164,10 @@ void CipherKeyImpl::generateKey( saltBytes[i % 8] ^= salt.at(i); } - // Now create the key and IV, using the MD5 digest algorithm. + // Now create the key and IV, using the digest set in the constructor. int keySize = EVP_BytesToKey( _pCipher, - EVP_md5(), + _pDigest, (salt.empty() ? 0 : saltBytes), reinterpret_cast(password.data()), static_cast(password.size()), From a399ff60154b8d64c444f5f9863d08dde8d982f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Bleuz=C3=A9?= Date: Thu, 3 Sep 2015 14:45:10 +0200 Subject: [PATCH 22/38] Crypto: add tests for cipher custom digests --- Crypto/testsuite/src/CryptoTest.cpp | 60 +++++++++++++++++++++++++++++ Crypto/testsuite/src/CryptoTest.h | 2 + 2 files changed, 62 insertions(+) diff --git a/Crypto/testsuite/src/CryptoTest.cpp b/Crypto/testsuite/src/CryptoTest.cpp index 8c4034709..cfc9e67f3 100644 --- a/Crypto/testsuite/src/CryptoTest.cpp +++ b/Crypto/testsuite/src/CryptoTest.cpp @@ -20,6 +20,7 @@ #include "Poco/Crypto/CryptoStream.h" #include "Poco/StreamCopier.h" #include "Poco/Base64Encoder.h" +#include "Poco/HexBinaryEncoder.h" #include @@ -125,6 +126,37 @@ void CryptoTest::testEncryptDecryptWithSalt() } } +void CryptoTest::testEncryptDecryptWithSaltSha1() +{ + Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher( + CipherKey("aes256", "simplepwd", "Too much salt", 2000, "sha1")); + Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher( + CipherKey("aes256", "simplepwd", "Too much salt", 2000, "sha1")); + + for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) + { + std::string in(n, 'x'); + std::string out = pCipher->encryptString(in, Cipher::ENC_NONE); + std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE); + assert (in == result); + } + + for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) + { + std::string in(n, 'x'); + std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64); + std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64); + assert (in == result); + } + + for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) + { + std::string in(n, 'x'); + std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX); + std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX); + assert (in == result); + } +} void CryptoTest::testEncryptDecryptDESECB() { @@ -168,6 +200,32 @@ void CryptoTest::testPassword() assert (base64Key == "hIzxBt58GDd7/6mRp88bewKk42lM4QwaF78ek0FkVoA="); } +void CryptoTest::testPasswordSha1() +{ + // the test uses 1 iteration, as the openssl executable does not allow to set a custom number + // of iterations + CipherKey key("aes256", "password", "saltsalt", 1, "sha1"); + + std::ostringstream keyStream; + Poco::HexBinaryEncoder hexKeyEnc(keyStream); + hexKeyEnc.write(reinterpret_cast(&key.getKey()[0]), key.keySize()); + hexKeyEnc.close(); + std::string hexKey = keyStream.str(); + + std::ostringstream ivStream; + Poco::HexBinaryEncoder hexIvEnc(ivStream); + hexIvEnc.write(reinterpret_cast(&key.getIV()[0]), key.ivSize()); + hexIvEnc.close(); + std::string hexIv = ivStream.str(); + + // got Hex value for key and iv using: + // openssl enc -e -a -md sha1 -aes256 -k password -S 73616c7473616c74 -P + // (where "salt" == 73616c74 in Hex, doubled for an 8 bytes salt, openssl padds the salt with 0 + // whereas Poco's implementation padds with the existing bytes using a modulo operation) + assert (hexIv == "c96049b0edc0b67af61ecc43d3de8898"); + assert (hexKey == "cab86dd6261710891e8cb56ee3625691a75df344f0bff4c12cf3596fc00b39c7"); +} + void CryptoTest::testEncryptInterop() { @@ -265,8 +323,10 @@ CppUnit::Test* CryptoTest::suite() CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt); CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt); + CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSaltSha1); CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptDESECB); CppUnit_addTest(pSuite, CryptoTest, testPassword); + CppUnit_addTest(pSuite, CryptoTest, testPasswordSha1); CppUnit_addTest(pSuite, CryptoTest, testEncryptInterop); CppUnit_addTest(pSuite, CryptoTest, testDecryptInterop); CppUnit_addTest(pSuite, CryptoTest, testStreams); diff --git a/Crypto/testsuite/src/CryptoTest.h b/Crypto/testsuite/src/CryptoTest.h index 18390f670..95b655f6a 100644 --- a/Crypto/testsuite/src/CryptoTest.h +++ b/Crypto/testsuite/src/CryptoTest.h @@ -33,9 +33,11 @@ public: void testEncryptDecrypt(); void testEncryptDecryptWithSalt(); + void testEncryptDecryptWithSaltSha1(); void testEncryptDecryptDESECB(); void testStreams(); void testPassword(); + void testPasswordSha1(); void testEncryptInterop(); void testDecryptInterop(); void testCertificate(); From 733c466657af60b0ec45bb012a09a76bde4bb5c8 Mon Sep 17 00:00:00 2001 From: Aleksandar Fabijanic Date: Sat, 5 Sep 2015 09:32:49 -0500 Subject: [PATCH 23/38] Update CONTRIBUTORS --- CONTRIBUTORS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 53631fb35..9c74a2d7f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -48,11 +48,12 @@ Christopher Baker Scott Davis Jeff Adams Martin Osborne -Björn Schramke +Björn Schramke Jonathan Seeley Tor Lillqvist Alexander Bychuk -Francisco Ramírez -Francis André +Francisco Ramírez +Francis André +Benoît Bleuzé -- $Id$ From 9feb6ea98711575d2cdf7e9678c179298e88ad04 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Sun, 6 Sep 2015 09:56:29 +0200 Subject: [PATCH 24/38] more style fixes --- XML/include/Poco/XML/QName.h | 6 +- XML/include/Poco/XML/XMLStreamParser.h | 157 +++--- XML/src/QName.cpp | 8 +- XML/src/XMLStreamParser.cpp | 139 +++-- XML/src/XMLStreamParserException.cpp | 2 - XML/testsuite/Makefile | 2 +- XML/testsuite/src/XMLStreamParserTest.cpp | 505 ++++++++++++++++++ XML/testsuite/src/XMLStreamParserTest.h | 40 ++ .../src/XMLStreamParserTestSuite.cpp | 489 ----------------- XML/testsuite/src/XMLStreamParserTestSuite.h | 40 -- XML/testsuite/src/XMLTestSuite.cpp | 4 +- 11 files changed, 699 insertions(+), 693 deletions(-) create mode 100644 XML/testsuite/src/XMLStreamParserTest.cpp create mode 100644 XML/testsuite/src/XMLStreamParserTest.h delete mode 100644 XML/testsuite/src/XMLStreamParserTestSuite.cpp delete mode 100644 XML/testsuite/src/XMLStreamParserTestSuite.h diff --git a/XML/include/Poco/XML/QName.h b/XML/include/Poco/XML/QName.h index 21f19d007..e89db8c8e 100644 --- a/XML/include/Poco/XML/QName.h +++ b/XML/include/Poco/XML/QName.h @@ -63,11 +63,9 @@ public: std::string& prefix(); /// Returns the namespace prefix of the name. - std::string string() const; + std::string toString() const; /// Returns a printable representation in the [#] form. - // Note that comparison operators - // public: friend bool operator < (const QName& x, const QName& y) { @@ -130,7 +128,7 @@ inline std::string& QName::prefix() } -XML_API std::ostream& operator<<(std::ostream&, const QName&); +XML_API std::ostream& operator << (std::ostream&, const QName&); } } // namespace Poco::XML diff --git a/XML/include/Poco/XML/XMLStreamParser.h b/XML/include/Poco/XML/XMLStreamParser.h index 3966f9414..c9daf8735 100644 --- a/XML/include/Poco/XML/XMLStreamParser.h +++ b/XML/include/Poco/XML/XMLStreamParser.h @@ -38,7 +38,6 @@ #include #include #include -#include namespace Poco { @@ -64,7 +63,7 @@ class XML_API XMLStreamParser /// are not very common). /// /// Attribute map is valid throughout at the "element level" until - /// end_element and not just during startElement. As a special case, + /// end_element and not just during EV_START_ELEMENT. As a special case, /// the map is still valid after peek() that returned end_element until /// this end_element event is retrieved with next(). /// @@ -75,17 +74,17 @@ class XML_API XMLStreamParser /// { /// switch (e) /// { - /// case XMLStreamParser::startElement: + /// case XMLStreamParser::EV_START_ELEMENT: /// cerr << p.line () << ':' << p.column () << ": start " << p.name () << endl; /// break; - /// case XMLStreamParser::endElement: + /// case XMLStreamParser::EV_END_ELEMENT: /// cerr << p.line () << ':' << p.column () << ": end " << p.name () << endl; /// break; - /// case XMLStreamParser::startAttribute: + /// case XMLStreamParser::EV_START_ATTRIBUTE: /// ... - /// case XMLStreamParser::endAttribute: + /// case XMLStreamParser::EV_END_ATTRIBUTE: /// ... - /// case XMLStreamParser::characters: + /// case XMLStreamParser::EV_CHARACTERS: /// ... /// } /// } @@ -94,14 +93,14 @@ public: enum EventType /// Parsing events. { - StartElement, - EndElement, - StartAttribute, - EndAttribute, - Characters, - StartNamespaceDecl, - EndNamespaceDecl, - Eof + EV_START_ELEMENT, + EV_END_ELEMENT, + EV_START_ATTRIBUTE, + EV_END_ATTRIBUTE, + EV_CHARACTERS, + EV_START_NAMESPACE_DECL, + EV_END_NAMESPACE_DECL, + EV_EOF }; typedef unsigned short FeatureType; @@ -130,16 +129,18 @@ public: { typedef EventType value_type; - Iterator(XMLStreamParser* p = 0, EventType e = Eof) : + Iterator(XMLStreamParser* p = 0, EventType e = EV_EOF): _parser(p), _e(e) { } - value_type operator*() const + + value_type operator * () const { return _e; } - Iterator& operator++() + + Iterator& operator ++ () { _e = _parser->next(); return *this; @@ -148,10 +149,10 @@ public: bool operator == (Iterator y) const /// Comparison only makes sense when comparing to end (eof). { - return _e == Eof && y._e == Eof; + return _e == EV_EOF && y._e == EV_EOF; } - bool operator!=(Iterator y) const + bool operator != (Iterator y) const /// Comparison only makes sense when comparing to end (eof). { return !(*this == y); @@ -169,10 +170,10 @@ public: Iterator end() { - return Iterator(this, Eof); + return Iterator(this, EV_EOF); } - XMLStreamParser(std::istream&, const std::string& input_name, FeatureType = RECEIVE_DEFAULT); + XMLStreamParser(std::istream&, const std::string& inputName, FeatureType = RECEIVE_DEFAULT); /// The parser constructor takes three arguments: the stream to parse, /// input name that is used in diagnostics to identify the document being /// parsed, and the list of events we want the parser to report. @@ -184,7 +185,7 @@ public: /// exception is used to report io errors (badbit and failbit). /// Otherwise, those are reported as the parsing exception. - XMLStreamParser(const void* data, std::size_t size, const std::string& input_name, FeatureType = RECEIVE_DEFAULT); + XMLStreamParser(const void* data, std::size_t size, const std::string& inputName, FeatureType = RECEIVE_DEFAULT); /// Parse memory buffer that contains the whole document. Input name /// is used in diagnostics to identify the document being parsed. @@ -204,7 +205,7 @@ public: EventType peek(); EventType event(); - /// Return the even that was last returned by the call to next() or peek(). + /// Return the event that was last returned by the call to next() or peek(). const std::string& inputName() const; const QName& getQName() const; @@ -213,21 +214,21 @@ public: const std::string& prefix() const; std::string& value(); const std::string& value() const; - template T value() const; + template T value() const; Poco::UInt64 line() const; Poco::UInt64 column() const; const std::string& attribute(const std::string& name) const; - template + template T attribute(const std::string& name) const; - std::string attribute(const std::string& name, const std::string& default_value) const; - template - T attribute(const std::string& name, const T& default_value) const; + std::string attribute(const std::string& name, const std::string& deflt) const; + template + T attribute(const std::string& name, const T& deflt) const; const std::string& attribute(const QName& qname) const; - template + template T attribute(const QName& qname) const; - std::string attribute(const QName& qname, const std::string& default_value) const; - template - T attribute(const QName& qname, const T& default_value) const; + std::string attribute(const QName& qname, const std::string& deflt) const; + template + T attribute(const QName& qname, const T& deflt) const; bool attributePresent(const std::string& name) const; bool attributePresent(const QName& qname) const; const AttributeMapType& attributeMap() const; @@ -240,46 +241,44 @@ public: void nextExpect(EventType, const std::string& ns, const std::string& name, Content); // Helpers for parsing elements with simple content. The first two - // functions assume that startElement has already been parsed. The + // functions assume that EV_START_ELEMENT has already been parsed. The // rest parse the complete element, from start to end. // // Note also that as with attribute(), there is no (namespace,name) - // overload since it would conflicts with (namespace,default_value). - // + // overload since it would conflicts with (namespace,deflt). std::string element(); - template + template T element(); std::string element(const std::string& name); std::string element(const QName& qname); - template + template T element(const std::string& name); - template + template T element(const QName& qname); - std::string element(const std::string& name, const std::string& default_value); - std::string element(const QName& qname, const std::string& default_value); - template - T element(const std::string& name, const T& default_value); - template - T element(const QName& qname, const T& default_value); + std::string element(const std::string& name, const std::string& deflt); + std::string element(const QName& qname, const std::string& deflt); + template + T element(const std::string& name, const T& deflt); + template + T element(const QName& qname, const T& deflt); private: XMLStreamParser(const XMLStreamParser&); - XMLStreamParser& operator=(const XMLStreamParser&); + XMLStreamParser& operator = (const XMLStreamParser&); - static void XMLCALL start_element_(void*, const XML_Char*, const XML_Char**); - static void XMLCALL end_element_(void*, const XML_Char*); - static void XMLCALL characters_(void*, const XML_Char*, int); - static void XMLCALL start_namespace_decl_(void*, const XML_Char*, const XML_Char*); - static void XMLCALL end_namespace_decl_(void*, const XML_Char*); + static void XMLCALL handleStartElement(void*, const XML_Char*, const XML_Char**); + static void XMLCALL handleEndElement(void*, const XML_Char*); + static void XMLCALL handleCharacters(void*, const XML_Char*, int); + static void XMLCALL handleStartNamespaceDecl(void*, const XML_Char*, const XML_Char*); + static void XMLCALL handleEndNamespaceDecl(void*, const XML_Char*); void init(); - EventType next_(bool peek); - EventType next_body(); - void handle_error(); + EventType nextImpl(bool peek); + EventType nextBody(); + void handleError(); - // If size_ is 0, then data is std::istream. Otherwise, it is a buffer. - // + // If _size is 0, then data is std::istream. Otherwise, it is a buffer. union { std::istream* is; @@ -303,13 +302,13 @@ private: Poco::UInt64 _line; Poco::UInt64 _column; - struct attribute_type + struct AttributeType { QName qname; std::string value; }; - typedef std::vector attributes; + typedef std::vector attributes; attributes _attributes; attributes::size_type _currentAttributeIndex; // Index of the current attribute. @@ -321,7 +320,7 @@ private: struct ElementEntry { - ElementEntry(std::size_t d, Content c = Content::Mixed) : + ElementEntry(std::size_t d, Content c = Content::Mixed): depth(d), content(c), attributesUnhandled(0) @@ -418,14 +417,14 @@ inline XMLStreamParser::EventType XMLStreamParser::peek() return _currentEvent; else { - EventType e(next_(true)); - _parserState = state_peek; // Set it after the call to next_(). + EventType e(nextImpl(true)); + _parserState = state_peek; // Set it after the call to nextImpl(). return e; } } -template +template inline T XMLStreamParser::value() const { return ValueTraits < T > ::parse(value(), *this); @@ -438,7 +437,7 @@ inline const std::string& XMLStreamParser::attribute(const std::string& n) const } -template +template inline T XMLStreamParser::attribute(const std::string& n) const { return attribute < T > (QName(n)); @@ -451,14 +450,14 @@ inline std::string XMLStreamParser::attribute(const std::string& n, const std::s } -template +template inline T XMLStreamParser::attribute(const std::string& n, const T& dv) const { return attribute < T > (QName(n), dv); } -template +template inline T XMLStreamParser::attribute(const QName& qn) const { return ValueTraits < T > ::parse(attribute(qn), *this); @@ -498,7 +497,7 @@ inline void XMLStreamParser::nextExpect(EventType e, const std::string& n) inline void XMLStreamParser::nextExpect(EventType e, const QName& qn, Content c) { nextExpect(e, qn); - assert(e == StartElement); + poco_assert(e == EV_START_ELEMENT); content(c); } @@ -506,7 +505,7 @@ inline void XMLStreamParser::nextExpect(EventType e, const QName& qn, Content c) inline void XMLStreamParser::nextExpect(EventType e, const std::string& n, Content c) { nextExpect(e, std::string(), n); - assert(e == StartElement); + poco_assert(e == EV_START_ELEMENT); content(c); } @@ -514,12 +513,12 @@ inline void XMLStreamParser::nextExpect(EventType e, const std::string& n, Conte inline void XMLStreamParser::nextExpect(EventType e, const std::string& ns, const std::string& n, Content c) { nextExpect(e, ns, n); - assert(e == StartElement); + poco_assert(e == EV_START_ELEMENT); content(c); } -template +template inline T XMLStreamParser::element() { return ValueTraits < T > ::parse(element(), *this); @@ -528,26 +527,26 @@ inline T XMLStreamParser::element() inline std::string XMLStreamParser::element(const std::string& n) { - nextExpect(StartElement, n); + nextExpect(EV_START_ELEMENT, n); return element(); } inline std::string XMLStreamParser::element(const QName& qn) { - nextExpect(StartElement, qn); + nextExpect(EV_START_ELEMENT, qn); return element(); } -template +template inline T XMLStreamParser::element(const std::string& n) { return ValueTraits < T > ::parse(element(n), *this); } -template +template inline T XMLStreamParser::element(const QName& qn) { return ValueTraits < T > ::parse(element(qn), *this); @@ -560,7 +559,7 @@ inline std::string XMLStreamParser::element(const std::string& n, const std::str } -template +template inline T XMLStreamParser::element(const std::string& n, const T& dv) { return element < T > (QName(n), dv); @@ -569,7 +568,7 @@ inline T XMLStreamParser::element(const std::string& n, const T& dv) inline void XMLStreamParser::content(Content c) { - assert(_parserState == state_next); + poco_assert(_parserState == state_next); if (!_elementState.empty() && _elementState.back().depth == _depth) _elementState.back().content = c; @@ -580,7 +579,7 @@ inline void XMLStreamParser::content(Content c) inline Content XMLStreamParser::content() const { - assert(_parserState == state_next); + poco_assert(_parserState == state_next); return !_elementState.empty() && _elementState.back().depth == _depth ? _elementState.back().content : Content(Content::Mixed); } @@ -592,7 +591,7 @@ inline const XMLStreamParser::ElementEntry* XMLStreamParser::getElement() const } -template +template T XMLStreamParser::attribute(const QName& qn, const T& dv) const { if (const ElementEntry* e = getElement()) @@ -614,10 +613,10 @@ T XMLStreamParser::attribute(const QName& qn, const T& dv) const } -template +template T XMLStreamParser::element(const QName& qn, const T& dv) { - if (peek() == StartElement && getQName() == qn) + if (peek() == EV_START_ELEMENT && getQName() == qn) { next(); return element(); diff --git a/XML/src/QName.cpp b/XML/src/QName.cpp index 28acfdac3..01b7e13fa 100644 --- a/XML/src/QName.cpp +++ b/XML/src/QName.cpp @@ -7,8 +7,6 @@ // Package: XML // Module: QName // -// Definition of the QName class. -// // Copyright (c) 2015, Applied Informatics Software Engineering GmbH. // and Contributors. // @@ -53,7 +51,7 @@ QName::QName(const std::string& ns, const std::string& name, const std::string& } -std::string QName::string() const +std::string QName::toString() const { std::string r; if (!_ns.empty()) @@ -67,9 +65,9 @@ std::string QName::string() const } -std::ostream& operator<<(std::ostream& os, const QName& qn) +std::ostream& operator << (std::ostream& os, const QName& qn) { - return os << qn.string(); + return os << qn.toString(); } diff --git a/XML/src/XMLStreamParser.cpp b/XML/src/XMLStreamParser.cpp index 8dfacffa0..3f819c3a7 100644 --- a/XML/src/XMLStreamParser.cpp +++ b/XML/src/XMLStreamParser.cpp @@ -7,8 +7,6 @@ // Package: XML // Module: XMLStreamParser // -// Definition of the XMLStreamParser class. -// // Copyright (c) 2015, Applied Informatics Software Engineering GmbH. // and Contributors. // @@ -21,7 +19,6 @@ #include "Poco/XML/XMLStreamParser.h" #include -#include #include #include #include @@ -105,7 +102,7 @@ XMLStreamParser::XMLStreamParser(const void* data, std::size_t size, const std:: _inputName(iname), _feature(f) { - assert(data != 0 && size != 0); + poco_assert(data != 0 && size != 0); _data.buf = data; init(); @@ -122,8 +119,8 @@ void XMLStreamParser::init() { _depth = 0; _parserState = state_next; - _currentEvent = Eof; - _queue = Eof; + _currentEvent = EV_EOF; + _queue = EV_EOF; _qualifiedName = &_qname; _pvalue = &_value; @@ -156,26 +153,26 @@ void XMLStreamParser::init() if ((_feature & RECEIVE_ELEMENTS) != 0) { - XML_SetStartElementHandler(_parser, &start_element_); - XML_SetEndElementHandler(_parser, &end_element_); + XML_SetStartElementHandler(_parser, &handleStartElement); + XML_SetEndElementHandler(_parser, &handleEndElement); } if ((_feature & RECEIVE_CHARACTERS) != 0) - XML_SetCharacterDataHandler(_parser, &characters_); + XML_SetCharacterDataHandler(_parser, &handleCharacters); if ((_feature & RECEIVE_NAMESPACE_DECLS) != 0) - XML_SetNamespaceDeclHandler(_parser, &start_namespace_decl_, &end_namespace_decl_); + XML_SetNamespaceDeclHandler(_parser, &handleStartNamespaceDecl, &handleEndNamespaceDecl); } -void XMLStreamParser::handle_error() +void XMLStreamParser::handleError() { XML_Error e(XML_GetErrorCode(_parser)); if (e == XML_ERROR_ABORTED) { - // For now we only abort the XMLStreamParser in the characters_() and - // start_element_() handlers. + // For now we only abort the XMLStreamParser in the handleCharacters() and + // handleStartElement() handlers. // switch (content()) { @@ -186,7 +183,7 @@ void XMLStreamParser::handle_error() case Content::Complex: throw XMLStreamParserException(*this, "characters in complex content"); default: - assert(false); + poco_assert(false); } } else @@ -197,7 +194,7 @@ void XMLStreamParser::handle_error() XMLStreamParser::EventType XMLStreamParser::next() { if (_parserState == state_next) - return next_(false); + return nextImpl(false); else { // If we previously peeked at start/end_element, then adjust @@ -205,7 +202,7 @@ XMLStreamParser::EventType XMLStreamParser::next() // switch (_currentEvent) { - case EndElement: + case EV_END_ELEMENT: { if (!_elementState.empty() && _elementState.back().depth == _depth) popElement(); @@ -213,7 +210,7 @@ XMLStreamParser::EventType XMLStreamParser::next() _depth--; break; } - case StartElement: + case EV_START_ELEMENT: { _depth++; break; @@ -245,7 +242,7 @@ const std::string& XMLStreamParser::attribute(const QName& qn) const } } - throw XMLStreamParserException(*this, "attribute '" + qn.string() + "' expected"); + throw XMLStreamParserException(*this, "attribute '" + qn.toString() + "' expected"); } @@ -301,7 +298,7 @@ void XMLStreamParser::nextExpect(EventType e) void XMLStreamParser::nextExpect(EventType e, const std::string& ns, const std::string& n) { if (next() != e || namespaceURI() != ns || localName() != n) - throw XMLStreamParserException(*this, std::string(parserEventStrings[e]) + " '" + QName(ns, n).string() + "' expected"); + throw XMLStreamParserException(*this, std::string(parserEventStrings[e]) + " '" + QName(ns, n).toString() + "' expected"); } @@ -314,7 +311,7 @@ std::string XMLStreamParser::element() // will be no characters event. // EventType e(next()); - if (e == Characters) + if (e == EV_CHARACTERS) { r.swap(value()); e = next(); @@ -323,7 +320,7 @@ std::string XMLStreamParser::element() // We cannot really get anything other than end_element since // the simple content validation won't allow it. // - assert(e == EndElement); + poco_assert(e == EV_END_ELEMENT); return r; } @@ -331,7 +328,7 @@ std::string XMLStreamParser::element() std::string XMLStreamParser::element(const QName& qn, const std::string& dv) { - if (peek() == StartElement && getQName() == qn) + if (peek() == EV_START_ELEMENT && getQName() == qn) { next(); return element(); @@ -343,7 +340,7 @@ std::string XMLStreamParser::element(const QName& qn, const std::string& dv) const XMLStreamParser::ElementEntry* XMLStreamParser::getElementImpl() const { - // The start_element_() Expat handler may have already provisioned + // The handleStartElement() Expat handler may have already provisioned // an entry in the element stack. In this case, we need to get the // one before it, if any. // @@ -375,21 +372,21 @@ void XMLStreamParser::popElement() for (AttributeMapType::const_iterator i(e.attributeMap.begin()); i != e.attributeMap.end(); ++i) { if (!i->second.handled) - throw XMLStreamParserException(*this, "unexpected attribute '" + i->first.string() + "'"); + throw XMLStreamParserException(*this, "unexpected attribute '" + i->first.toString() + "'"); } - assert(false); + poco_assert(false); } _elementState.pop_back(); } -XMLStreamParser::EventType XMLStreamParser::next_(bool peek) +XMLStreamParser::EventType XMLStreamParser::nextImpl(bool peek) { - EventType e(next_body()); + EventType e(nextBody()); // Content-specific processing. Note that we handle characters in the - // characters_() Expat handler for two reasons. Firstly, it is faster + // handleCharacters() Expat handler for two reasons. Firstly, it is faster // to ignore the whitespaces at the source. Secondly, this allows us // to distinguish between element and attribute characters. We can // move this processing to the handler because the characters event @@ -397,7 +394,7 @@ XMLStreamParser::EventType XMLStreamParser::next_(bool peek) // switch (e) { - case EndElement: + case EV_END_ELEMENT: { // If this is a peek, then avoid popping the stack just yet. // This way, the attribute map will still be valid until we @@ -412,7 +409,7 @@ XMLStreamParser::EventType XMLStreamParser::next_(bool peek) } break; } - case StartElement: + case EV_START_ELEMENT: { if (const ElementEntry* e = getElement()) { @@ -442,7 +439,7 @@ XMLStreamParser::EventType XMLStreamParser::next_(bool peek) } -XMLStreamParser::EventType XMLStreamParser::next_body() +XMLStreamParser::EventType XMLStreamParser::nextBody() { // See if we have any start namespace declarations we need to return. // @@ -452,7 +449,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // switch (_currentEvent) { - case StartNamespaceDecl: + case EV_START_NAMESPACE_DECL: { if (++_startNamespaceIndex == _startNamespace.size()) { @@ -463,16 +460,16 @@ XMLStreamParser::EventType XMLStreamParser::next_body() } // Fall through. } - case StartElement: + case EV_START_ELEMENT: { - _currentEvent = StartNamespaceDecl; + _currentEvent = EV_START_NAMESPACE_DECL; _qualifiedName = &_startNamespace[_startNamespaceIndex]; return _currentEvent; } default: { - assert(false); - return _currentEvent = Eof; + poco_assert(false); + return _currentEvent = EV_EOF; } } } @@ -485,18 +482,18 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // switch (_currentEvent) { - case StartAttribute: + case EV_START_ATTRIBUTE: { - _currentEvent = Characters; + _currentEvent = EV_CHARACTERS; _pvalue = &_attributes[_currentAttributeIndex].value; return _currentEvent; } - case Characters: + case EV_CHARACTERS: { - _currentEvent = EndAttribute; // Name is already set. + _currentEvent = EV_END_ATTRIBUTE; // Name is already set. return _currentEvent; } - case EndAttribute: + case EV_END_ATTRIBUTE: { if (++_currentAttributeIndex == _attributes.size()) { @@ -508,17 +505,17 @@ XMLStreamParser::EventType XMLStreamParser::next_body() } // Fall through. } - case StartElement: - case StartNamespaceDecl: + case EV_START_ELEMENT: + case EV_START_NAMESPACE_DECL: { - _currentEvent = StartAttribute; + _currentEvent = EV_START_ATTRIBUTE; _qualifiedName = &_attributes[_currentAttributeIndex].qname; return _currentEvent; } default: { - assert(false); - return _currentEvent = Eof; + poco_assert(false); + return _currentEvent = EV_EOF; } } } @@ -531,7 +528,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // switch (_currentEvent) { - case EndNamespaceDecl: + case EV_END_NAMESPACE_DECL: { if (++_endNamespaceIndex == _endNamespace.size()) { @@ -547,7 +544,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // default: { - _currentEvent = EndNamespaceDecl; + _currentEvent = EV_END_NAMESPACE_DECL; _qualifiedName = &_endNamespace[_endNamespaceIndex]; return _currentEvent; } @@ -556,10 +553,10 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // Check the queue. // - if (_queue != Eof) + if (_queue != EV_EOF) { _currentEvent = _queue; - _queue = Eof; + _queue = EV_EOF; _line = XML_GetCurrentLineNumber(_parser); _column = XML_GetCurrentColumnNumber(_parser); @@ -583,12 +580,12 @@ XMLStreamParser::EventType XMLStreamParser::next_body() } case XML_PARSING: { - assert(false); - return _currentEvent = Eof; + poco_assert(false); + return _currentEvent = EV_EOF; } case XML_FINISHED: { - return _currentEvent = Eof; + return _currentEvent = EV_EOF; } case XML_SUSPENDED: { @@ -607,12 +604,12 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // unless this was the last chunk, in which case this is eof. // if (ps.finalBuffer) - return _currentEvent = Eof; + return _currentEvent = EV_EOF; break; } case XML_STATUS_ERROR: - handle_error(); + handleError(); } break; } @@ -622,7 +619,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body() // or reach eof. // if (!_accumulateContent) - _currentEvent = Eof; + _currentEvent = EV_EOF; XML_Status s; do @@ -632,7 +629,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body() s = XML_Parse(_parser, static_cast(_data.buf), static_cast(_size), true); if (s == XML_STATUS_ERROR) - handle_error(); + handleError(); break; } @@ -664,7 +661,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body() s = XML_ParseBuffer(_parser, static_cast(is.gcount()), eof); if (s == XML_STATUS_ERROR) - handle_error(); + handleError(); if (eof) break; @@ -710,7 +707,7 @@ static void splitName(const XML_Char* s, QName& qn) } -void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, const XML_Char** atts) +void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name, const XML_Char** atts) { XMLStreamParser& p(*static_cast(v)); @@ -725,7 +722,7 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons // Cannot be a followup event. // - assert(ps.parsing == XML_PARSING); + poco_assert(ps.parsing == XML_PARSING); // When accumulating characters in simple content, we expect to // see more characters or end element. Seeing start element is @@ -742,7 +739,7 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons return; } - p._currentEvent = StartElement; + p._currentEvent = EV_START_ELEMENT; splitName(name, p._qname); p._line = XML_GetCurrentLineNumber(p._parser); @@ -779,7 +776,7 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons } else { - p._attributes.push_back(attribute_type()); + p._attributes.push_back(AttributeType()); splitName(*atts, p._attributes.back().qname); p._attributes.back().value = *(atts + 1); } @@ -794,7 +791,7 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons } -void XMLCALL XMLStreamParser::end_element_(void* v, const XML_Char* name) +void XMLCALL XMLStreamParser::handleEndElement(void* v, const XML_Char* name) { XMLStreamParser& p(*static_cast(v)); @@ -811,7 +808,7 @@ void XMLCALL XMLStreamParser::end_element_(void* v, const XML_Char* name) // case the element name is already set. // if (ps.parsing != XML_PARSING) - p._queue = EndElement; + p._queue = EV_END_ELEMENT; else { splitName(name, p._qname); @@ -819,10 +816,10 @@ void XMLCALL XMLStreamParser::end_element_(void* v, const XML_Char* name) // If we are accumulating characters, then queue this event. // if (p._accumulateContent) - p._queue = EndElement; + p._queue = EV_END_ELEMENT; else { - p._currentEvent = EndElement; + p._currentEvent = EV_END_ELEMENT; p._line = XML_GetCurrentLineNumber(p._parser); p._column = XML_GetCurrentColumnNumber(p._parser); @@ -833,7 +830,7 @@ void XMLCALL XMLStreamParser::end_element_(void* v, const XML_Char* name) } -void XMLCALL XMLStreamParser::characters_(void* v, const XML_Char* s, int n) +void XMLCALL XMLStreamParser::handleCharacters(void* v, const XML_Char* s, int n) { XMLStreamParser& p(*static_cast(v)); @@ -881,12 +878,12 @@ void XMLCALL XMLStreamParser::characters_(void* v, const XML_Char* s, int n) // if (p._accumulateContent || ps.parsing != XML_PARSING) { - assert(p._currentEvent == Characters); + poco_assert(p._currentEvent == EV_CHARACTERS); p._value.append(s, n); } else { - p._currentEvent = Characters; + p._currentEvent = EV_CHARACTERS; p._value.assign(s, n); p._line = XML_GetCurrentLineNumber(p._parser); @@ -904,7 +901,7 @@ void XMLCALL XMLStreamParser::characters_(void* v, const XML_Char* s, int n) } -void XMLCALL XMLStreamParser::start_namespace_decl_(void* v, const XML_Char* prefix, const XML_Char* ns) +void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char* prefix, const XML_Char* ns) { XMLStreamParser& p(*static_cast(v)); @@ -923,7 +920,7 @@ void XMLCALL XMLStreamParser::start_namespace_decl_(void* v, const XML_Char* pre } -void XMLCALL XMLStreamParser::end_namespace_decl_(void* v, const XML_Char* prefix) +void XMLCALL XMLStreamParser::handleEndNamespaceDecl(void* v, const XML_Char* prefix) { XMLStreamParser& p(*static_cast(v)); diff --git a/XML/src/XMLStreamParserException.cpp b/XML/src/XMLStreamParserException.cpp index 03166519d..81430baa7 100644 --- a/XML/src/XMLStreamParserException.cpp +++ b/XML/src/XMLStreamParserException.cpp @@ -7,8 +7,6 @@ // Package: XML // Module: XMLStreamParserException // -// Definition of the XMLStreamParserException class. -// // Copyright (c) 2015, Applied Informatics Software Engineering GmbH. // and Contributors. // diff --git a/XML/testsuite/Makefile b/XML/testsuite/Makefile index d7a7672bc..5fd0b7406 100644 --- a/XML/testsuite/Makefile +++ b/XML/testsuite/Makefile @@ -13,7 +13,7 @@ objects = AttributesImplTest ChildNodesTest DOMTestSuite DocumentTest \ NamespaceSupportTest NodeIteratorTest NodeTest ParserWriterTest \ SAXParserTest SAXTestSuite TextTest TreeWalkerTest \ XMLTestSuite XMLWriterTest NodeAppenderTest \ - XMLStreamParserTestSuite + XMLStreamParserTest target = testrunner target_version = 1 diff --git a/XML/testsuite/src/XMLStreamParserTest.cpp b/XML/testsuite/src/XMLStreamParserTest.cpp new file mode 100644 index 000000000..09c96ae5b --- /dev/null +++ b/XML/testsuite/src/XMLStreamParserTest.cpp @@ -0,0 +1,505 @@ +// +// XMLStreamParserTest.cpp +// +// $Id$ +// +// Copyright (c) 2015, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + +#include "XMLStreamParserTest.h" +#include "CppUnit/TestCaller.h" +#include "CppUnit/TestSuite.h" +#include "Poco/XML/XMLStreamParser.h" +#include "Poco/Exception.h" +#include +#include +#include +#include + + +using namespace Poco::XML; + + +XMLStreamParserTest::XMLStreamParserTest(const std::string& name): + CppUnit::TestCase(name) +{ +} + + +XMLStreamParserTest::~XMLStreamParserTest() +{ +} + + +void XMLStreamParserTest::testParser() +{ + // Test error handling. + // + try + { + std::istringstream is("X"); + XMLStreamParser p(is, "test"); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == "X"); + p.next(); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + try + { + std::istringstream is(""); + is.exceptions(std::ios_base::badbit | std::ios_base::failbit); + XMLStreamParser p(is, "test"); + + is.setstate(std::ios_base::badbit); + p.next(); + assert(false); + } + catch (const std::ios_base::failure&) + { + } + + // Test the nextExpect() functionality. + // + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + } + + try + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + try + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root1"); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + // Test nextExpect() with content setting. + // + { + std::istringstream is(" "); + XMLStreamParser p(is, "empty"); + + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root", Content::Empty); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + p.nextExpect(XMLStreamParser::EV_EOF); + } + + // Test namespace declarations. + // + { + // Followup end element event that should be precedeeded by end + // namespace declaration. + // + std::istringstream is(""); + XMLStreamParser p(is, "test", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_NAMESPACE_DECLS); + + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + p.nextExpect(XMLStreamParser::EV_START_NAMESPACE_DECL); + p.nextExpect(XMLStreamParser::EV_END_NAMESPACE_DECL); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + } + + // Test value extraction. + // + { + std::istringstream is("123"); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + p.nextExpect(XMLStreamParser::EV_CHARACTERS); + assert(p.value() == 123); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + } + + // Test attribute maps. + // + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + + assert(p.attribute("a") == "a"); + assert(p.attribute("b", "B") == "b"); + assert(p.attribute("c", "C") == "C"); + assert(p.attribute("d") == 123); + assert(p.attribute("t") == true); + assert(p.attribute("f", false) == false); + + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + } + + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + assert(p.attribute("a") == "a"); + assert(p.peek() == XMLStreamParser::EV_START_ELEMENT && p.localName() == "nested"); + assert(p.attribute("a") == "a"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "nested"); + assert(p.attribute("a") == "A"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "inner"); + assert(p.attribute("a", "") == ""); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + assert(p.attribute("a") == "A"); + assert(p.peek() == XMLStreamParser::EV_END_ELEMENT); + assert(p.attribute("a") == "A"); // Still valid. + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + assert(p.attribute("a") == "a"); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + assert(p.attribute("a", "") == ""); + } + + try + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + assert(p.attribute("a") == "a"); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + try + { + std::istringstream is(""); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + p.attribute("a"); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + // Test peeking and getting the current event. + // + { + std::istringstream is("x"); + XMLStreamParser p(is, "peek", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_ATTRIBUTES_EVENT); + + assert(p.event() == XMLStreamParser::EV_EOF); + + assert(p.peek() == XMLStreamParser::EV_START_ELEMENT); + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + assert(p.event() == XMLStreamParser::EV_START_ELEMENT); + + assert(p.peek() == XMLStreamParser::EV_START_ATTRIBUTE); + assert(p.event() == XMLStreamParser::EV_START_ATTRIBUTE); + assert(p.next() == XMLStreamParser::EV_START_ATTRIBUTE); + + assert(p.peek() == XMLStreamParser::EV_CHARACTERS && p.value() == "x"); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == "x"); + assert(p.event() == XMLStreamParser::EV_CHARACTERS && p.value() == "x"); + + assert(p.peek() == XMLStreamParser::EV_END_ATTRIBUTE); + assert(p.event() == XMLStreamParser::EV_END_ATTRIBUTE); + assert(p.next() == XMLStreamParser::EV_END_ATTRIBUTE); + + assert(p.peek() == XMLStreamParser::EV_CHARACTERS && p.value() == "x"); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == "x"); + assert(p.event() == XMLStreamParser::EV_CHARACTERS && p.value() == "x"); + + assert(p.peek() == XMLStreamParser::EV_START_ELEMENT); + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + assert(p.event() == XMLStreamParser::EV_START_ELEMENT); + + assert(p.peek() == XMLStreamParser::EV_END_ELEMENT); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); + assert(p.event() == XMLStreamParser::EV_END_ELEMENT); + + assert(p.peek() == XMLStreamParser::EV_END_ELEMENT); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); + assert(p.event() == XMLStreamParser::EV_END_ELEMENT); + + assert(p.peek() == XMLStreamParser::EV_EOF); + assert(p.next() == XMLStreamParser::EV_EOF); + assert(p.event() == XMLStreamParser::EV_EOF); + } + + // Test content processing. + // + + // empty + // + { + std::istringstream is(" \n\t "); + XMLStreamParser p(is, "empty", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_ATTRIBUTES_EVENT); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.content(Content::Empty); + assert(p.next() == XMLStreamParser::EV_START_ATTRIBUTE); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == " x "); + assert(p.next() == XMLStreamParser::EV_END_ATTRIBUTE); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); + assert(p.next() == XMLStreamParser::EV_EOF); + } + + try + { + std::istringstream is(" \n & X \t "); + XMLStreamParser p(is, "empty"); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.content(Content::Empty); + p.next(); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + // simple + // + { + std::istringstream is(" X "); + XMLStreamParser p(is, "simple"); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.content(Content::Simple); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == " X "); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); + assert(p.next() == XMLStreamParser::EV_EOF); + } + + try + { + std::istringstream is(" ? "); + XMLStreamParser p(is, "simple"); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.content(Content::Simple); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == " ? "); + p.next(); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + { + // Test content accumulation in simple content. + // + std::istringstream is("123"); + XMLStreamParser p(is, "simple", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_NAMESPACE_DECLS); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.nextExpect(XMLStreamParser::EV_START_NAMESPACE_DECL); + p.content(Content::Simple); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == "123"); + p.nextExpect(XMLStreamParser::EV_END_NAMESPACE_DECL); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); + assert(p.next() == XMLStreamParser::EV_EOF); + } + + try + { + // Test error handling in accumulation in simple content. + // + std::istringstream is("123"); + XMLStreamParser p(is, "simple", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_NAMESPACE_DECLS); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.nextExpect(XMLStreamParser::EV_START_NAMESPACE_DECL); + p.content(Content::Simple); + p.next(); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + // complex + // + { + std::istringstream is("\n" + " \n" + " \n" + " X \n" + " \n" + "\n"); + XMLStreamParser p(is, "complex", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_ATTRIBUTES_EVENT); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); // root + p.content(Content::Complex); + + assert(p.next() == XMLStreamParser::EV_START_ATTRIBUTE); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == " x "); + assert(p.next() == XMLStreamParser::EV_END_ATTRIBUTE); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); // nested + p.content(Content::Complex); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); // inner + p.content(Content::Empty); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); // inner + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); // inner + p.content(Content::Simple); + assert(p.next() == XMLStreamParser::EV_CHARACTERS && p.value() == " X "); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); // inner + + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); // nested + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); // root + assert(p.next() == XMLStreamParser::EV_EOF); + } + + try + { + std::istringstream is(" \n X X "); + XMLStreamParser p(is, "complex"); + + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + p.content(Content::Complex); + assert(p.next() == XMLStreamParser::EV_START_ELEMENT); + assert(p.next() == XMLStreamParser::EV_END_ELEMENT); + p.next(); + assert(false); + } + catch (const Poco::Exception&) + { + // cerr << e.what () << endl; + } + + // Test element with simple content helpers. + // + { + std::istringstream is("" + " X" + " " + " 123" + " Y" + " Z" + " 234" + " 345" + " A" + " B" + " A" + " B" + " 1" + " 2" + " 1" + " 2" + ""); + XMLStreamParser p(is, "element"); + + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root", Content::Complex); + + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "nested"); + assert(p.element() == "X"); + + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "nested"); + assert(p.element() == ""); + + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "nested"); + assert(p.element() == 123); + + assert(p.element("nested") == "Y"); + assert(p.element(QName("test", "nested")) == "Z"); + + assert(p.element("nested") == 234); + assert(p.element(QName("test", "nested")) == 345); + + assert(p.element("nested", "a") == "A"); + assert(p.element(QName("test", "nested"), "b") == "B"); + + assert(p.element("nested", "a") == "a" && p.element("nested1") == "A"); + assert(p.element(QName("test", "nested"), "b") == "b" && p.element(QName("test", "nested1")) == "B"); + + assert(p.element("nested", 10) == 1); + assert(p.element(QName("test", "nested"), 20) == 2); + + assert(p.element("nested", 10) == 10 && p.element("nested1") == 1); + assert(p.element(QName("test", "nested"), 20) == 20 && p.element(QName("test", "nested1")) == 2); + + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + } + + // Test the iterator interface. + // + { + std::istringstream is("X"); + XMLStreamParser p(is, "iterator"); + + std::vector v; + + for (XMLStreamParser::Iterator i(p.begin()); i != p.end(); ++i) + v.push_back(*i); + + //for (XMLStreamParser::EventType e: p) + // v.push_back (e); + + assert(v.size() == 5); + assert(v[0] == XMLStreamParser::EV_START_ELEMENT); + assert(v[1] == XMLStreamParser::EV_START_ELEMENT); + assert(v[2] == XMLStreamParser::EV_CHARACTERS); + assert(v[3] == XMLStreamParser::EV_END_ELEMENT); + assert(v[4] == XMLStreamParser::EV_END_ELEMENT); + } + + // Test space extraction into the std::string value. + // + { + std::istringstream is(" b "); + XMLStreamParser p(is, "test"); + p.nextExpect(XMLStreamParser::EV_START_ELEMENT, "root"); + assert(p.attribute("a") == " a "); + p.nextExpect(XMLStreamParser::EV_CHARACTERS); + assert(p.value() == " b "); + p.nextExpect(XMLStreamParser::EV_END_ELEMENT); + } +} + + +void XMLStreamParserTest::setUp() +{ +} + + +void XMLStreamParserTest::tearDown() +{ +} + + +CppUnit::Test* XMLStreamParserTest::suite() +{ + CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("XMLStreamParserTest"); + + CppUnit_addTest(pSuite, XMLStreamParserTest, testParser); + + return pSuite; +} diff --git a/XML/testsuite/src/XMLStreamParserTest.h b/XML/testsuite/src/XMLStreamParserTest.h new file mode 100644 index 000000000..2579a74c3 --- /dev/null +++ b/XML/testsuite/src/XMLStreamParserTest.h @@ -0,0 +1,40 @@ +// +// XMLStreamParserTest.h +// +// $Id$ +// +// Definition of the XMLStreamParserTest class. +// +// Copyright (c) 2015, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XMLStreamParserTest_INCLUDED +#define XMLStreamParserTest_INCLUDED + + +#include "Poco/XML/XML.h" +#include "CppUnit/TestCase.h" + + +class XMLStreamParserTest: public CppUnit::TestCase +{ +public: + XMLStreamParserTest(const std::string& name); + ~XMLStreamParserTest(); + + void testParser(); + + void setUp(); + void tearDown(); + + static CppUnit::Test* suite(); + +private: +}; + + +#endif // XMLStreamParserTest_INCLUDED diff --git a/XML/testsuite/src/XMLStreamParserTestSuite.cpp b/XML/testsuite/src/XMLStreamParserTestSuite.cpp deleted file mode 100644 index 5b6ab123f..000000000 --- a/XML/testsuite/src/XMLStreamParserTestSuite.cpp +++ /dev/null @@ -1,489 +0,0 @@ -// -// XMLStreamParserTestSuite.cpp -// -// $Id: //poco/1.4/XML/testsuite/src/XMLStreamParserTestSuite.cpp#4 $ -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - -#include "XMLStreamParserTestSuite.h" -#include "CppUnit/TestCaller.h" -#include "CppUnit/TestSuite.h" -#include "Poco/XML/XMLStreamParser.h" -#include "Poco/Exception.h" -#include -#include -#include -#include - -using namespace Poco::XML; -using namespace std; - -XMLStreamParserTestSuite::XMLStreamParserTestSuite(const std::string& name) - : CppUnit::TestCase(name) -{ -} - -XMLStreamParserTestSuite::~XMLStreamParserTestSuite() -{ -} - -void XMLStreamParserTestSuite::testParser() -{ - // Test error handling. - // - try - { - istringstream is("X"); - XMLStreamParser p(is, "test"); - - poco_assert(p.next() == XMLStreamParser::StartElement); - poco_assert(p.next() == XMLStreamParser::StartElement); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == "X"); - p.next(); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - try - { - istringstream is(""); - is.exceptions(ios_base::badbit | ios_base::failbit); - XMLStreamParser p(is, "test"); - - is.setstate(ios_base::badbit); - p.next(); - poco_assert(false); - } catch (const ios_base::failure&) - { - } - - // Test the nextExpect() functionality. - // - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - p.nextExpect(XMLStreamParser::EndElement); - } - - try - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::EndElement); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - try - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root1"); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - // Test nextExpect() with content setting. - // - { - istringstream is(" "); - XMLStreamParser p(is, "empty"); - - p.nextExpect(XMLStreamParser::StartElement, "root", Content::Empty); - p.nextExpect(XMLStreamParser::EndElement); - p.nextExpect(XMLStreamParser::Eof); - } - - // Test namespace declarations. - // - { - // Followup end element event that should be precedeeded by end - // namespace declaration. - // - istringstream is(""); - XMLStreamParser p(is, "test", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_NAMESPACE_DECLS); - - p.nextExpect(XMLStreamParser::StartElement, "root"); - p.nextExpect(XMLStreamParser::StartNamespaceDecl); - p.nextExpect(XMLStreamParser::EndNamespaceDecl); - p.nextExpect(XMLStreamParser::EndElement); - } - - // Test value extraction. - // - { - istringstream is("123"); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - p.nextExpect(XMLStreamParser::Characters); - poco_assert(p.value() == 123); - p.nextExpect(XMLStreamParser::EndElement); - } - - // Test attribute maps. - // - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - - poco_assert(p.attribute("a") == "a"); - poco_assert(p.attribute("b", "B") == "b"); - poco_assert(p.attribute("c", "C") == "C"); - poco_assert(p.attribute("d") == 123); - poco_assert(p.attribute("t") == true); - poco_assert(p.attribute("f", false) == false); - - p.nextExpect(XMLStreamParser::EndElement); - } - - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - poco_assert(p.attribute("a") == "a"); - poco_assert(p.peek() == XMLStreamParser::StartElement && p.localName() == "nested"); - poco_assert(p.attribute("a") == "a"); - p.nextExpect(XMLStreamParser::StartElement, "nested"); - poco_assert(p.attribute("a") == "A"); - p.nextExpect(XMLStreamParser::StartElement, "inner"); - poco_assert(p.attribute("a", "") == ""); - p.nextExpect(XMLStreamParser::EndElement); - poco_assert(p.attribute("a") == "A"); - poco_assert(p.peek() == XMLStreamParser::EndElement); - poco_assert(p.attribute("a") == "A"); // Still valid. - p.nextExpect(XMLStreamParser::EndElement); - poco_assert(p.attribute("a") == "a"); - p.nextExpect(XMLStreamParser::EndElement); - poco_assert(p.attribute("a", "") == ""); - } - - try - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - poco_assert(p.attribute("a") == "a"); - p.nextExpect(XMLStreamParser::EndElement); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - try - { - istringstream is(""); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - p.attribute("a"); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - // Test peeking and getting the current event. - // - { - istringstream is("x"); - XMLStreamParser p(is, "peek", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_ATTRIBUTES_EVENT); - - poco_assert(p.event() == XMLStreamParser::Eof); - - poco_assert(p.peek() == XMLStreamParser::StartElement); - poco_assert(p.next() == XMLStreamParser::StartElement); - poco_assert(p.event() == XMLStreamParser::StartElement); - - poco_assert(p.peek() == XMLStreamParser::StartAttribute); - poco_assert(p.event() == XMLStreamParser::StartAttribute); - poco_assert(p.next() == XMLStreamParser::StartAttribute); - - poco_assert(p.peek() == XMLStreamParser::Characters && p.value() == "x"); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == "x"); - poco_assert(p.event() == XMLStreamParser::Characters && p.value() == "x"); - - poco_assert(p.peek() == XMLStreamParser::EndAttribute); - poco_assert(p.event() == XMLStreamParser::EndAttribute); - poco_assert(p.next() == XMLStreamParser::EndAttribute); - - poco_assert(p.peek() == XMLStreamParser::Characters && p.value() == "x"); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == "x"); - poco_assert(p.event() == XMLStreamParser::Characters && p.value() == "x"); - - poco_assert(p.peek() == XMLStreamParser::StartElement); - poco_assert(p.next() == XMLStreamParser::StartElement); - poco_assert(p.event() == XMLStreamParser::StartElement); - - poco_assert(p.peek() == XMLStreamParser::EndElement); - poco_assert(p.next() == XMLStreamParser::EndElement); - poco_assert(p.event() == XMLStreamParser::EndElement); - - poco_assert(p.peek() == XMLStreamParser::EndElement); - poco_assert(p.next() == XMLStreamParser::EndElement); - poco_assert(p.event() == XMLStreamParser::EndElement); - - poco_assert(p.peek() == XMLStreamParser::Eof); - poco_assert(p.next() == XMLStreamParser::Eof); - poco_assert(p.event() == XMLStreamParser::Eof); - } - - // Test content processing. - // - - // empty - // - { - istringstream is(" \n\t "); - XMLStreamParser p(is, "empty", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_ATTRIBUTES_EVENT); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.content(Content::Empty); - poco_assert(p.next() == XMLStreamParser::StartAttribute); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == " x "); - poco_assert(p.next() == XMLStreamParser::EndAttribute); - poco_assert(p.next() == XMLStreamParser::EndElement); - poco_assert(p.next() == XMLStreamParser::Eof); - } - - try - { - istringstream is(" \n & X \t "); - XMLStreamParser p(is, "empty"); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.content(Content::Empty); - p.next(); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - // simple - // - { - istringstream is(" X "); - XMLStreamParser p(is, "simple"); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.content(Content::Simple); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == " X "); - poco_assert(p.next() == XMLStreamParser::EndElement); - poco_assert(p.next() == XMLStreamParser::Eof); - } - - try - { - istringstream is(" ? "); - XMLStreamParser p(is, "simple"); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.content(Content::Simple); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == " ? "); - p.next(); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - { - // Test content accumulation in simple content. - // - istringstream is("123"); - XMLStreamParser p(is, "simple", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_NAMESPACE_DECLS); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.nextExpect(XMLStreamParser::StartNamespaceDecl); - p.content(Content::Simple); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == "123"); - p.nextExpect(XMLStreamParser::EndNamespaceDecl); - poco_assert(p.next() == XMLStreamParser::EndElement); - poco_assert(p.next() == XMLStreamParser::Eof); - } - - try - { - // Test error handling in accumulation in simple content. - // - istringstream is("123"); - XMLStreamParser p(is, "simple", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_NAMESPACE_DECLS); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.nextExpect(XMLStreamParser::StartNamespaceDecl); - p.content(Content::Simple); - p.next(); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - // complex - // - { - istringstream is("\n" - " \n" - " \n" - " X \n" - " \n" - "\n"); - XMLStreamParser p(is, "complex", XMLStreamParser::RECEIVE_DEFAULT | XMLStreamParser::RECEIVE_ATTRIBUTES_EVENT); - - poco_assert(p.next() == XMLStreamParser::StartElement); // root - p.content(Content::Complex); - - poco_assert(p.next() == XMLStreamParser::StartAttribute); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == " x "); - poco_assert(p.next() == XMLStreamParser::EndAttribute); - - poco_assert(p.next() == XMLStreamParser::StartElement); // nested - p.content(Content::Complex); - - poco_assert(p.next() == XMLStreamParser::StartElement); // inner - p.content(Content::Empty); - poco_assert(p.next() == XMLStreamParser::EndElement); // inner - - poco_assert(p.next() == XMLStreamParser::StartElement); // inner - p.content(Content::Simple); - poco_assert(p.next() == XMLStreamParser::Characters && p.value() == " X "); - poco_assert(p.next() == XMLStreamParser::EndElement); // inner - - poco_assert(p.next() == XMLStreamParser::EndElement); // nested - poco_assert(p.next() == XMLStreamParser::EndElement); // root - poco_assert(p.next() == XMLStreamParser::Eof); - } - - try - { - istringstream is(" \n X X "); - XMLStreamParser p(is, "complex"); - - poco_assert(p.next() == XMLStreamParser::StartElement); - p.content(Content::Complex); - poco_assert(p.next() == XMLStreamParser::StartElement); - poco_assert(p.next() == XMLStreamParser::EndElement); - p.next(); - poco_assert(false); - } catch (const Poco::Exception&) - { - // cerr << e.what () << endl; - } - - // Test element with simple content helpers. - // - { - istringstream is("" - " X" - " " - " 123" - " Y" - " Z" - " 234" - " 345" - " A" - " B" - " A" - " B" - " 1" - " 2" - " 1" - " 2" - ""); - XMLStreamParser p(is, "element"); - - p.nextExpect(XMLStreamParser::StartElement, "root", Content::Complex); - - p.nextExpect(XMLStreamParser::StartElement, "nested"); - poco_assert(p.element() == "X"); - - p.nextExpect(XMLStreamParser::StartElement, "nested"); - poco_assert(p.element() == ""); - - p.nextExpect(XMLStreamParser::StartElement, "nested"); - poco_assert(p.element() == 123); - - poco_assert(p.element("nested") == "Y"); - poco_assert(p.element(QName("test", "nested")) == "Z"); - - poco_assert(p.element("nested") == 234); - poco_assert(p.element(QName("test", "nested")) == 345); - - poco_assert(p.element("nested", "a") == "A"); - poco_assert(p.element(QName("test", "nested"), "b") == "B"); - - poco_assert(p.element("nested", "a") == "a" && p.element("nested1") == "A"); - poco_assert(p.element(QName("test", "nested"), "b") == "b" && p.element(QName("test", "nested1")) == "B"); - - poco_assert(p.element("nested", 10) == 1); - poco_assert(p.element(QName("test", "nested"), 20) == 2); - - poco_assert(p.element("nested", 10) == 10 && p.element("nested1") == 1); - poco_assert(p.element(QName("test", "nested"), 20) == 20 && p.element(QName("test", "nested1")) == 2); - - p.nextExpect(XMLStreamParser::EndElement); - } - - // Test the iterator interface. - // - { - istringstream is("X"); - XMLStreamParser p(is, "iterator"); - - vector v; - - for (XMLStreamParser::Iterator i(p.begin()); i != p.end(); ++i) - v.push_back(*i); - - //for (XMLStreamParser::EventType e: p) - // v.push_back (e); - - poco_assert(v.size() == 5); - poco_assert(v[0] == XMLStreamParser::StartElement); - poco_assert(v[1] == XMLStreamParser::StartElement); - poco_assert(v[2] == XMLStreamParser::Characters); - poco_assert(v[3] == XMLStreamParser::EndElement); - poco_assert(v[4] == XMLStreamParser::EndElement); - } - - // Test space extraction into the std::string value. - // - { - istringstream is(" b "); - XMLStreamParser p(is, "test"); - p.nextExpect(XMLStreamParser::StartElement, "root"); - poco_assert(p.attribute("a") == " a "); - p.nextExpect(XMLStreamParser::Characters); - poco_assert(p.value() == " b "); - p.nextExpect(XMLStreamParser::EndElement); - } -} - -void XMLStreamParserTestSuite::setUp() -{ -} - -void XMLStreamParserTestSuite::tearDown() -{ -} - -CppUnit::Test* XMLStreamParserTestSuite::suite() -{ - CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("XMLStreamParserTestSuite"); - - CppUnit_addTest(pSuite, XMLStreamParserTestSuite, testParser); - - return pSuite; -} diff --git a/XML/testsuite/src/XMLStreamParserTestSuite.h b/XML/testsuite/src/XMLStreamParserTestSuite.h deleted file mode 100644 index 5626448ae..000000000 --- a/XML/testsuite/src/XMLStreamParserTestSuite.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// XMLStreamParserTestSuite.h -// -// $Id: //poco/1.4/XML/testsuite/src/XMLStreamParserTestSuite.h#2 $ -// -// Definition of the XMLStreamParserTestSuite class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XMLStreamParserTestSuite_INCLUDED -#define XMLStreamParserTestSuite_INCLUDED - - -#include "Poco/XML/XML.h" -#include "CppUnit/TestCase.h" - - -class XMLStreamParserTestSuite: public CppUnit::TestCase -{ -public: - XMLStreamParserTestSuite(const std::string& name); - ~XMLStreamParserTestSuite(); - - void testParser(); - - void setUp(); - void tearDown(); - - static CppUnit::Test* suite(); - -private: -}; - - -#endif // XMLStreamParserTestSuite_INCLUDED diff --git a/XML/testsuite/src/XMLTestSuite.cpp b/XML/testsuite/src/XMLTestSuite.cpp index 2ecc54c04..691bb83e5 100644 --- a/XML/testsuite/src/XMLTestSuite.cpp +++ b/XML/testsuite/src/XMLTestSuite.cpp @@ -16,7 +16,7 @@ #include "XMLWriterTest.h" #include "SAXTestSuite.h" #include "DOMTestSuite.h" -#include "XMLStreamParserTestSuite.h" +#include "XMLStreamParserTest.h" CppUnit::Test* XMLTestSuite::suite() { @@ -27,7 +27,7 @@ CppUnit::Test* XMLTestSuite::suite() pSuite->addTest(XMLWriterTest::suite()); pSuite->addTest(SAXTestSuite::suite()); pSuite->addTest(DOMTestSuite::suite()); - pSuite->addTest(XMLStreamParserTestSuite::suite()); + pSuite->addTest(XMLStreamParserTest::suite()); return pSuite; } From dba1d44b15b01906d2ae0afc5a4f0cc4447d41c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Sun, 6 Sep 2015 10:20:10 +0200 Subject: [PATCH 25/38] updated project files --- XML/XML_CE_vs90.vcproj | 18 +++++++ XML/XML_WEC2013_vs110.vcxproj | 9 ++++ XML/XML_WEC2013_vs110.vcxproj.filters | 51 ++++++++++++++----- XML/XML_WEC2013_vs120.vcxproj | 9 ++++ XML/XML_WEC2013_vs120.vcxproj.filters | 51 ++++++++++++++----- XML/XML_vs100.vcxproj | 9 ++++ XML/XML_vs100.vcxproj.filters | 51 ++++++++++++++----- XML/XML_vs110.vcxproj | 9 ++++ XML/XML_vs110.vcxproj.filters | 51 ++++++++++++++----- XML/XML_vs120.vcxproj | 9 ++++ XML/XML_vs120.vcxproj.filters | 51 ++++++++++++++----- XML/XML_vs140.vcxproj | 9 ++++ XML/XML_vs140.vcxproj.filters | 51 ++++++++++++++----- XML/XML_vs90.vcproj | 18 +++++++ XML/XML_x64_vs100.vcxproj | 9 ++++ XML/XML_x64_vs100.vcxproj.filters | 51 ++++++++++++++----- XML/XML_x64_vs110.vcxproj | 9 ++++ XML/XML_x64_vs110.vcxproj.filters | 51 ++++++++++++++----- XML/XML_x64_vs120.vcxproj | 9 ++++ XML/XML_x64_vs120.vcxproj.filters | 51 ++++++++++++++----- XML/XML_x64_vs140.vcxproj | 9 ++++ XML/XML_x64_vs140.vcxproj.filters | 51 ++++++++++++++----- XML/XML_x64_vs90.vcproj | 18 +++++++ XML/testsuite/TestSuite_CE_vs90.vcproj | 4 ++ XML/testsuite/TestSuite_WEC2013_vs110.vcxproj | 2 + .../TestSuite_WEC2013_vs110.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_WEC2013_vs120.vcxproj | 2 + .../TestSuite_WEC2013_vs120.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_vs100.vcxproj | 2 + XML/testsuite/TestSuite_vs100.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_vs110.vcxproj | 2 + XML/testsuite/TestSuite_vs110.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_vs120.vcxproj | 2 + XML/testsuite/TestSuite_vs120.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_vs140.vcxproj | 2 + XML/testsuite/TestSuite_vs140.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_vs90.vcproj | 4 ++ XML/testsuite/TestSuite_x64_vs100.vcxproj | 2 + .../TestSuite_x64_vs100.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_x64_vs110.vcxproj | 2 + .../TestSuite_x64_vs110.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_x64_vs120.vcxproj | 2 + .../TestSuite_x64_vs120.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_x64_vs140.vcxproj | 2 + .../TestSuite_x64_vs140.vcxproj.filters | 34 ++++++++----- XML/testsuite/TestSuite_x64_vs90.vcproj | 4 ++ 46 files changed, 766 insertions(+), 260 deletions(-) diff --git a/XML/XML_CE_vs90.vcproj b/XML/XML_CE_vs90.vcproj index d4e2e558f..a5536d8b0 100644 --- a/XML/XML_CE_vs90.vcproj +++ b/XML/XML_CE_vs90.vcproj @@ -438,6 +438,8 @@ Name="XML"> + + + + + + + + + + + + + + @@ -346,7 +351,11 @@ + + + + true true diff --git a/XML/XML_WEC2013_vs110.vcxproj.filters b/XML/XML_WEC2013_vs110.vcxproj.filters index ee6166528..14e11b8bb 100644 --- a/XML/XML_WEC2013_vs110.vcxproj.filters +++ b/XML/XML_WEC2013_vs110.vcxproj.filters @@ -2,43 +2,46 @@ - {0a27ef56-d026-41bb-b4a6-815c736c20de} + {510c128c-0ade-44b5-a9f3-6db227aef09d} - {ee5c0026-27ea-497e-b85a-44ef9193d6d4} + {eb8e48e5-e7d7-4fc2-bee2-301cab23d8ee} - {313a431c-94c1-423a-845f-ccc3f8051420} + {a621b86a-9f8d-41a3-a2b1-834702c9b214} - {5a587ae3-0947-4436-b3f5-a43e5ada5473} + {f18ca99c-69dc-47e1-84a6-8179fb89e252} - {182eaaff-f16c-44a8-bfcd-689486365f7a} + {42f77d62-a0a1-4993-b5ef-fe3c80b7de8e} - {b883bb0b-ecf7-4d5c-a9a6-f79d10d97972} + {14685372-8923-479b-9b7b-0608409613c2} - {95e9ef8e-3cf0-4f95-b111-e079410adbb1} + {b20d129b-1a74-43db-82c4-f0386333d35b} - {f5579eb9-c0d3-45de-8182-471394cf1e2e} + {13a1ba93-0ecc-48a8-a272-6c2305b0b0de} - {cdd3c97f-bc1c-44e3-a063-1fccb2ccd54a} + {fc75763f-6295-43ad-84b1-238b2a7bc88f} - {3e206c78-0fec-4487-96d1-b9d7d201a9fe} + {fddcd22d-4141-4243-8216-c8f7dc015483} - {5df33881-4d8e-4cf6-970f-739fa9552915} + {27f63b8d-80c8-4221-acf8-2f9a66820ad2} - {7e73cd8a-56f2-4830-9fb9-56870af1ca42} + {a9f27e9b-c698-4ae8-aefd-0af0888b21b1} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_WEC2013_vs120.vcxproj b/XML/XML_WEC2013_vs120.vcxproj index 4ed3772b1..3259c985e 100644 --- a/XML/XML_WEC2013_vs120.vcxproj +++ b/XML/XML_WEC2013_vs120.vcxproj @@ -318,15 +318,20 @@ + + + + + @@ -398,10 +403,12 @@ + + @@ -409,6 +416,8 @@ + + true true diff --git a/XML/XML_WEC2013_vs120.vcxproj.filters b/XML/XML_WEC2013_vs120.vcxproj.filters index df57c6b4a..a89aaea16 100644 --- a/XML/XML_WEC2013_vs120.vcxproj.filters +++ b/XML/XML_WEC2013_vs120.vcxproj.filters @@ -2,43 +2,46 @@ - {607e5536-55e7-4e1c-8f7a-ead0b6fbb8a5} + {ae9d5858-a285-4cfd-8714-c2bb23b90257} - {6a4ab1a6-fde6-424c-9280-cf3f84f3b922} + {2bb463d2-36d4-4681-8626-05967eddeabb} - {52d539ce-9c2c-427d-9eeb-a1b0464ee70b} + {92673221-b6d4-44d0-8b5d-f5fb1a029a8e} - {29c0ac4a-5923-4581-a688-ad63661a6f69} + {cbfcc7ca-f0ab-4c63-b9b6-448d6562f30c} - {29fab171-3cd5-439c-87ca-cd7d5378c610} + {3e622a06-6c0c-498b-bba2-55fb5d707f18} - {261566a4-8657-4175-a627-61d33b927a9f} + {f7c29f4d-3835-4455-8b31-bfaee8880392} - {11e9e69a-837e-43bf-b0c4-ebf06b41da0c} + {dccce482-4adf-47de-91ff-fe678f4d33bd} - {f9b59c23-1a04-40dd-ad55-dedaa84c950d} + {0c5fd4ee-c77b-4e77-b524-65057356a480} - {9af80e24-06aa-464f-aca3-4d6676f4ea80} + {94764808-1760-4d49-806e-176306d945fa} - {b0347d1c-78f0-479e-9026-40302bd099a0} + {99b93127-5895-4119-8e21-1cf0c251e133} - {abceea86-9fd4-4b54-8ffe-00ff7a7c7ea2} + {5d6e3cd0-aefc-43ef-a743-41a7b8072db6} - {f3796949-1eb2-487d-a280-34101b469ded} + {12cf45cc-4baf-419f-86c9-a4b187548303} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_vs100.vcxproj b/XML/XML_vs100.vcxproj index 7d0483473..cd51128a6 100644 --- a/XML/XML_vs100.vcxproj +++ b/XML/XML_vs100.vcxproj @@ -275,13 +275,18 @@ + + + + + @@ -364,7 +369,11 @@ + + + + true true diff --git a/XML/XML_vs100.vcxproj.filters b/XML/XML_vs100.vcxproj.filters index 64587aef1..6b14e175f 100644 --- a/XML/XML_vs100.vcxproj.filters +++ b/XML/XML_vs100.vcxproj.filters @@ -2,43 +2,46 @@ - {945aef23-2a80-45dc-8849-17f49c429628} + {65edf253-2918-415f-b844-3dc8476e9220} - {2387b12c-3d91-4a05-ae0a-5fa5f2f053b8} + {9ebb8cab-c404-4260-8645-a4ac53cc60af} - {cc309da4-8a97-4cf0-8a43-335332e5c36a} + {0b9a4efc-33d2-4942-bd02-ed6f65267a43} - {59745370-646f-4b63-8a9e-3da50498645a} + {f332bb84-587e-40b0-afe2-db0c29432a43} - {26ca3b75-75c6-4839-a0ec-cc907bbf7854} + {e4557921-321d-483c-a8a2-334d5db19d18} - {cefbbfb3-bad1-4a6f-b582-2b86cce8b66b} + {20ed4584-5386-4f5d-8165-e3ec8a7d2b85} - {4c1944da-731c-4f58-9075-e02ab859103f} + {1b8ee62a-1051-46a8-b707-a5bec27508d6} - {34469edc-3620-4681-9ec8-9ec0c8be3af0} + {a898e832-e332-4044-bcc6-7cef571d39a2} - {66e7d765-fff0-451b-92f1-d0bae40f24d3} + {ee2e1498-4015-48ce-9463-ed5bb37c82d2} - {6c219dda-366c-48f6-beb6-fba9249e4870} + {5b5ead3e-11b3-4bb1-92be-88393ddfe15d} - {e81d5d15-c25d-4b8c-80e5-3c08b0586acc} + {cc161af7-9f27-41b3-a5a4-51c06232a6d7} - {5a304a8f-2138-4643-a9e1-2e7148e40bf3} + {ab77295e-6e6a-403e-a160-cd4bacbfc722} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_vs110.vcxproj b/XML/XML_vs110.vcxproj index 9aba52f60..ebcbf686e 100644 --- a/XML/XML_vs110.vcxproj +++ b/XML/XML_vs110.vcxproj @@ -276,13 +276,18 @@ + + + + + @@ -365,7 +370,11 @@ + + + + true true diff --git a/XML/XML_vs110.vcxproj.filters b/XML/XML_vs110.vcxproj.filters index b2537cbac..3a824b77e 100644 --- a/XML/XML_vs110.vcxproj.filters +++ b/XML/XML_vs110.vcxproj.filters @@ -2,43 +2,46 @@ - {a2887584-c87a-473e-9213-6ea412a66190} + {2614bd4a-a27e-4c67-a033-1675289f29c6} - {599ab01a-ce8b-4771-9d58-7b47d241edc7} + {ee056f43-19dc-4389-bb0e-cd55d6c98b14} - {958342fd-277a-4f96-a083-dc4ea4ff9476} + {307488ab-b8f2-4dc9-afb9-184fc7ac57c8} - {5945dd24-9617-40d3-a969-607dd6ccc09a} + {745badfa-021d-457f-8559-00aea54d23f2} - {a145dac2-fe47-4eaf-b01a-876e529b7cc8} + {0f198452-c208-4aeb-9997-ecef2b296b8c} - {0d6314c0-65f2-40f0-b02c-9561e4e173af} + {76ea17bb-be2d-47fe-97ac-bcddea9fae37} - {abd48d02-956b-4925-87ba-ba830d38799e} + {d9357220-87c9-4569-8401-eac5c663688f} - {792651c3-1394-44f8-9679-c351e8c1c20f} + {65baa972-8a32-4bd1-a9a5-c12550542b5c} - {ce6751ed-0db8-4246-95c6-8427a987c2a1} + {e5d81645-e2a7-413f-b675-339f4b4b117a} - {64ae7a77-3d4b-44b9-a791-88d45d2b4a30} + {1015755a-27ea-4e5a-bec2-ea2c15a940ec} - {54029fec-369c-407d-805b-fd982184a1b5} + {b756e985-c22b-45cc-96a4-c7807f7da20c} - {dd157b6d-8794-43f2-a526-fa294e983138} + {024d08ea-dd60-489b-84cb-669aa8a7cae9} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_vs120.vcxproj b/XML/XML_vs120.vcxproj index a0f6521f1..f4d7c3d76 100644 --- a/XML/XML_vs120.vcxproj +++ b/XML/XML_vs120.vcxproj @@ -337,15 +337,20 @@ + + + + + @@ -417,10 +422,12 @@ + + @@ -428,6 +435,8 @@ + + true true diff --git a/XML/XML_vs120.vcxproj.filters b/XML/XML_vs120.vcxproj.filters index 28c25e77a..42a76d8b0 100644 --- a/XML/XML_vs120.vcxproj.filters +++ b/XML/XML_vs120.vcxproj.filters @@ -2,43 +2,46 @@ - {f8c939c5-d561-45ef-af14-574018eb24df} + {b61b4dc4-6c51-4d81-8d4b-99c7cef7afe5} - {d7fdaf18-37a9-41c0-895c-204a7fec0fb2} + {5b3e63a0-0182-414d-9733-b55e6c720494} - {3ce9b3eb-d690-4d52-bd1c-536d25b09aa4} + {f89b42ee-c77a-4046-9d0f-9083e1618b6f} - {9220f641-2d43-44c8-a757-882a94ade8cc} + {301d2339-3fba-49d7-8877-69cc3bdd7ac2} - {265754a5-e5c5-46ac-9549-27fbfbd2c7e0} + {4ce8a48b-462f-4b89-8aa8-3eb09161bef7} - {d1a6a322-33b1-4049-ba3e-25649837ea15} + {935c0e34-ee3c-48ec-b40a-6071020bd2b4} - {08e4032d-7dfe-4f9e-8791-79a62f4a89e3} + {ca1fa1b9-9526-4e7a-adba-5503848a5f56} - {87060c43-254e-44ec-9651-ff16e6505d5b} + {703bde44-00d7-45fd-aef4-a790934909b1} - {aa3e33e9-0e87-470f-a2f6-31fcc089874f} + {f93ef8be-bab9-46da-82e6-fe60256e9989} - {7a1cc54d-11ed-4a5c-b394-c17f00e85f4c} + {cb4bdd1a-1598-4ca2-ae05-f56368dbf4b4} - {6ea00709-b54b-41f6-a3f0-9a560d90da3d} + {01034770-0bdc-46a4-ab48-525db37849d2} - {9c81622a-12cb-4471-a624-310cb2fa9351} + {814d64ca-c357-4e33-a81f-b9f203a7a728} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_vs140.vcxproj b/XML/XML_vs140.vcxproj index 14da4c107..4f38e8272 100644 --- a/XML/XML_vs140.vcxproj +++ b/XML/XML_vs140.vcxproj @@ -337,15 +337,20 @@ + + + + + @@ -417,10 +422,12 @@ + + @@ -428,6 +435,8 @@ + + true true diff --git a/XML/XML_vs140.vcxproj.filters b/XML/XML_vs140.vcxproj.filters index 5b4f97705..c20ba5799 100644 --- a/XML/XML_vs140.vcxproj.filters +++ b/XML/XML_vs140.vcxproj.filters @@ -2,43 +2,46 @@ - {2ef8c8e9-851b-4df3-8aab-64725b0ba3a2} + {a5de6ebc-cce9-4746-b3a5-e85625954430} - {a2ddcd8c-da4e-4d6f-8263-a6e60f38c6ca} + {6581ec1a-3ca5-42cb-8570-56a5b4caa5e1} - {160479fd-e5b1-4abd-84f4-085cb460a64a} + {5b3dcd04-3da8-44f6-bc5c-eabd83f89a31} - {9e21f3ad-5f0c-44b3-8d74-13e45441b3cc} + {da1b2d71-07b5-4941-829b-5ba4e1f60290} - {7d508b25-17a3-4a92-b28e-d5bb2f2bfb3e} + {9676bd0e-fdb4-41b1-8617-389c757c765b} - {7429db87-b9f6-48f7-bb67-19ecad21031e} + {91b86e4b-db6a-490b-a345-bf66851b739b} - {dbb18fe7-3f1c-4968-b064-c7b653a05407} + {2709168d-bbd1-43e7-8a54-2964f69ce5be} - {e24fe209-67d6-4c67-9191-9a61f5b00b3a} + {5abd420d-b947-457a-a1df-067c553baf6f} - {d322c835-050c-43b7-ac46-a878fe1748db} + {4de0fdfd-f2f1-4932-bd74-a4cf3dda99d0} - {228f93b4-0920-4a2c-a064-45fdd9c4af67} + {fd935cc1-fa5e-4e21-a5f0-a9048ae3e8c6} - {c513ee9e-d3e4-4763-8646-835279d44d24} + {52492a95-5a47-4310-8bed-f3430d893bdd} - {19fad315-d45a-47ac-9889-e7ea49f44598} + {9bf7efd3-533b-4f95-9802-36b74615b464} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_vs90.vcproj b/XML/XML_vs90.vcproj index ffdb91b7f..de9d41470 100644 --- a/XML/XML_vs90.vcproj +++ b/XML/XML_vs90.vcproj @@ -392,6 +392,8 @@ Name="XML"> + + + + + + + + + + + + + + @@ -362,7 +367,11 @@ + + + + true true diff --git a/XML/XML_x64_vs100.vcxproj.filters b/XML/XML_x64_vs100.vcxproj.filters index a2ed527d9..47f830485 100644 --- a/XML/XML_x64_vs100.vcxproj.filters +++ b/XML/XML_x64_vs100.vcxproj.filters @@ -2,43 +2,46 @@ - {a4f62ec2-6187-462b-b5b5-efaa10d0e0f4} + {a9a1dca5-d1a2-4559-9874-4e79c7416c53} - {c4f6829b-aaaa-4ffb-8cef-d663e1cb83cf} + {80da8a7b-da57-441f-9373-6704174b4cf7} - {6c9db7e3-5b7b-4ae0-afd0-15fe40263e34} + {50af371a-9a79-4856-a74a-c24a18bd27fb} - {a2893b1e-dda6-404b-b4f3-ca4a4f3bde6d} + {b741e391-f97a-412a-82ec-831db3076755} - {51794fbc-6c5f-4b1b-b4e4-047a3b9de526} + {69517bed-4e9a-4183-8663-5c898ca4ff4a} - {6725b3d4-b051-4317-aaee-8ff4d61bef22} + {4161f045-63d3-47ea-98b8-9233ac9ddc4b} - {270b0f18-6867-413b-95e4-ba5f8bfe849b} + {2a9a41eb-1acb-447f-8303-ecee7c85f218} - {b0291fff-e080-4447-9991-b270c5ce00ef} + {8ee24584-ac70-48f7-8543-3244abbfede7} - {48c6f5d5-2adf-4c14-8748-fe6a4a9a9428} + {8ebf4fd1-e05f-46ac-aa3c-31a3049e98f3} - {0e0c68ec-e7d5-4528-b931-51425ef49688} + {7e7f5e71-ded6-4d32-a483-d28a06a45d46} - {c0e34258-e71b-47a3-a3c6-94b72282f7d9} + {e3fb4c9a-ce84-469b-a5ab-326b2ee5da6b} - {41b27c83-c251-4fbe-b9cb-791730e14dab} + {bb2b6642-57c6-4103-b2fe-0f083f0d0ab2} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_x64_vs110.vcxproj b/XML/XML_x64_vs110.vcxproj index 9da21fc2d..0982f6671 100644 --- a/XML/XML_x64_vs110.vcxproj +++ b/XML/XML_x64_vs110.vcxproj @@ -275,13 +275,18 @@ + + + + + @@ -364,7 +369,11 @@ + + + + true true diff --git a/XML/XML_x64_vs110.vcxproj.filters b/XML/XML_x64_vs110.vcxproj.filters index 161fb036d..b67c8a9ec 100644 --- a/XML/XML_x64_vs110.vcxproj.filters +++ b/XML/XML_x64_vs110.vcxproj.filters @@ -2,43 +2,46 @@ - {0b14b184-8d7d-4f7d-b918-8476e5f3647d} + {a04fb07b-1189-423b-a072-98f32e1bdd83} - {d21f4bf9-cfbd-4937-b00f-c7a34c421ca5} + {24c2029b-9e98-4cd6-81ee-054e8fc41f76} - {090b7370-14c8-4643-9ca9-a2ebed4a58e4} + {c12a9af7-dc7b-4e15-b98c-ac11171891b0} - {e7a0a2f6-c1e5-486c-a740-3b0b167380c6} + {606f4b9d-41f3-4c94-aa12-c63b0cfe5843} - {17c8b296-68f9-4551-b093-4d4369806e9a} + {85fb778c-dde8-4196-8848-3a086f883f53} - {ca808b76-0cfb-423a-ac2b-eb7834e1caad} + {5f815669-612b-4323-b373-374acedac950} - {c6683b8a-9a4d-48f9-8800-a8ee42bc74e5} + {d004e13b-5b70-4e31-a595-2246ac3b8b81} - {6508cc30-b59c-4328-ba6c-a0889ed72faf} + {2bfe27a4-664b-449d-bef8-6f2f94fe31df} - {84e6cf67-ab5a-4d70-880e-771857ec1256} + {56025ad2-7e96-4399-8333-b8314670ff23} - {7f54c3aa-c33c-4b64-8966-ca0bae468de5} + {d88f94e7-32c2-4b70-95a2-a41d84b6ef03} - {85fe699d-ee7c-4ba7-be01-87e6d5ff15f2} + {f2f7a9d9-b9ba-4818-9e82-5953f1cf35dc} - {fad7bac7-fac2-41db-a71c-dc1e357ca070} + {9448fb5f-afa6-43ce-93fa-76090c8cea04} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_x64_vs120.vcxproj b/XML/XML_x64_vs120.vcxproj index 6901de8b0..22a737f71 100644 --- a/XML/XML_x64_vs120.vcxproj +++ b/XML/XML_x64_vs120.vcxproj @@ -336,15 +336,20 @@ + + + + + @@ -416,10 +421,12 @@ + + @@ -427,6 +434,8 @@ + + true true diff --git a/XML/XML_x64_vs120.vcxproj.filters b/XML/XML_x64_vs120.vcxproj.filters index 0df206ef4..13e506b2c 100644 --- a/XML/XML_x64_vs120.vcxproj.filters +++ b/XML/XML_x64_vs120.vcxproj.filters @@ -2,43 +2,46 @@ - {19ba2980-0f44-4bd5-8289-8b32ac24b059} + {ee8b01d7-9bf5-40f2-bd7b-99622a98390a} - {33102eef-eba2-4b89-9c73-498777984b85} + {23c5c17d-0c71-4b00-9cf0-a632e2bf6719} - {6a3aa816-1fc2-4278-bb97-fcc6128baf68} + {9192ee3a-4acd-4405-a1f8-4cd3f34775c0} - {dcd92315-7121-47ea-bb75-f0307756e168} + {58aff733-d608-4393-af4e-e31cde3cae69} - {f6cc5dd4-80e2-4d9a-bbe6-f0e0d5870ac0} + {57ce4863-5d93-404f-9c5c-bec22d005975} - {34440a29-b84f-4292-83a1-9782a25e5433} + {53b95691-345e-4488-bc6e-05bf6cb1ad9b} - {7f1fb15f-84ca-4441-8399-96d4fac3ba4b} + {b86cd6c2-9b2a-45a2-a3a3-30d6a6da71be} - {55498c8d-fbb4-4f64-9cca-3030b66fe65c} + {70a35331-ee55-4abe-9d38-8630e3fa0125} - {32bae4d9-8852-48e6-b777-7e2217871772} + {3afeb546-5432-40f1-967a-b0152ff36224} - {17bf0a7b-d886-4a56-9ae8-72a6a58bf16e} + {f9036c78-eea8-4420-9959-1b56027be6d5} - {6d0fc498-2cc8-4571-b9de-002f5352cf25} + {12d0f128-7704-4192-b925-1d7614115340} - {128367df-4699-4de6-b8f5-b00861effb31} + {acba0677-86b6-4f7d-833b-7467a3e0d3c2} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_x64_vs140.vcxproj b/XML/XML_x64_vs140.vcxproj index 80f398ed9..4f3adcb09 100644 --- a/XML/XML_x64_vs140.vcxproj +++ b/XML/XML_x64_vs140.vcxproj @@ -336,15 +336,20 @@ + + + + + @@ -416,10 +421,12 @@ + + @@ -427,6 +434,8 @@ + + true true diff --git a/XML/XML_x64_vs140.vcxproj.filters b/XML/XML_x64_vs140.vcxproj.filters index 02816ec99..7beedf9d6 100644 --- a/XML/XML_x64_vs140.vcxproj.filters +++ b/XML/XML_x64_vs140.vcxproj.filters @@ -2,43 +2,46 @@ - {d5bfdd0a-e08a-4d10-a2b0-df134f9a2bbd} + {0340d279-0fb2-4dff-82e3-9e7ab1b82a10} - {0448e9b9-9f7b-4981-8aeb-c4cf5cbd36d5} + {b991e209-98d2-4336-a9ac-309525db32cf} - {d828eef0-4a7c-4380-ac75-33fc3393a84a} + {61ae2918-df85-4ee5-a205-4342bc2c78ef} - {33b839dc-3ad1-4486-ac47-39bec0fec025} + {d2ccc3a8-d84d-4384-9211-0ca17b60376b} - {26da183a-31ab-48f0-8453-34d9cfec235f} + {998cc9bb-73f6-48df-a71e-2abacea24ff2} - {e3fc1e67-200d-42be-a573-2e862d30899f} + {96a40ea9-5072-4b66-8029-6985f40a9a5c} - {cadc79f9-1742-464e-8d08-00e6298d6c10} + {14ea6404-dd3a-4544-bc57-93f6373c6656} - {c764dc45-cceb-41f5-8d1b-a6fb4b1031af} + {326adfd3-09af-4630-8a33-e9cc0a806682} - {f12e7abd-38e9-4749-bae7-83b490edb149} + {d341d7c9-033c-49c4-9e47-205fd1fb4393} - {47f3e86a-f62a-4b7b-ada8-30e2cadf71e0} + {224b9ae3-766b-47f7-9dc3-eb00e04a7705} - {e3a46273-c07b-4909-a55b-d26abfbea174} + {85b43ec0-ac23-4eb6-be6f-5ef60144777b} - {5c1350fa-7d1b-4ab2-9fc0-cd64458c276f} + {db32d5c6-e354-4a3c-8e36-8637f5cfb226} + + XML\Header Files + XML\Header Files @@ -51,6 +54,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -60,6 +69,12 @@ XML\Header Files + + XML\Header Files + + + XML\Header Files + XML\Header Files @@ -302,9 +317,21 @@ XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files + + XML\Source Files + + + XML\Source Files + XML\Source Files diff --git a/XML/XML_x64_vs90.vcproj b/XML/XML_x64_vs90.vcproj index d2f57c7d3..8bd1666de 100644 --- a/XML/XML_x64_vs90.vcproj +++ b/XML/XML_x64_vs90.vcproj @@ -397,6 +397,8 @@ Name="XML"> + + + + + + + + + + @@ -479,6 +481,8 @@ RelativePath=".\src\NamePoolTest.cpp"/> + diff --git a/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj b/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj index bc025fd53..ef05d19a2 100644 --- a/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj +++ b/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj @@ -309,6 +309,7 @@ + @@ -331,6 +332,7 @@ + diff --git a/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj.filters b/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj.filters index b99aa7d01..f07c7cddc 100644 --- a/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj.filters +++ b/XML/testsuite/TestSuite_WEC2013_vs110.vcxproj.filters @@ -2,46 +2,46 @@ - {acc1ac97-1bd3-4dd9-8baf-41ca0a6a6165} + {14993246-81b3-45d0-a5a8-f8f28bc72144} - {bb3b8f2f-dd85-4524-a3c5-d3613f39ae58} + {abbb650f-8e01-445c-83e0-834d1755c584} - {31e6ca38-1c64-45fd-aa9f-54d6a19a3afa} + {cbc886fd-0051-422c-8ded-7eedb3794fd0} - {110aaaa8-04df-4693-b2da-8d1cefdf242f} + {f440273c-e5f1-4ed7-a860-b3bedb550e58} - {adb2ef10-6b6f-4efd-8dad-7be6da62b36a} + {af1a0506-0353-452b-adab-20d45fd7349d} - {ea15600f-e49d-4e39-98ba-f813e1cc4d7c} + {9222a6e4-8a42-405a-8d7f-84b8a641fb02} - {bc8ab2d0-b1bf-44c2-ac99-f7da132de4d6} + {cc634f41-c6f3-4f89-b48b-fd526323bf5f} - {ba02b3a3-245c-41b4-a2a3-d9f6d723bbc9} + {f3857835-f80d-47c3-bdf0-a1f89430a824} - {75550be9-0331-4301-a83f-43da52cf4e42} + {1e78620a-b7f1-4f73-b95e-7d0071b55b64} - {24087926-a6b4-4279-b3f9-6e13a4c6a4e4} + {6b95b3c9-63e5-4290-8f82-4aa64660c60d} - {88f93edb-b1b6-4875-a49f-ba64fe0c2d53} + {1d53b669-c42d-4ca6-b1f0-874ba3a90f5e} - {c3860c52-6413-48fd-ab45-832b5bee3526} + {7bccd6ef-1413-486c-a980-7603a9c8a4fa} - {8921de7c-b700-46d5-9905-c1ac67603e95} + {66bdcd09-831d-44c0-98c0-9c4554df25ed} - {29a95c2d-2f17-457b-9ebe-bd71a5aad861} + {c31974b9-546e-40ad-89e5-2c8d57aa67a7} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj b/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj index a8498d880..a184909c2 100644 --- a/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj +++ b/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj @@ -325,6 +325,7 @@ + @@ -348,6 +349,7 @@ + diff --git a/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj.filters b/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj.filters index af646d041..6fa110d4d 100644 --- a/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj.filters +++ b/XML/testsuite/TestSuite_WEC2013_vs120.vcxproj.filters @@ -2,46 +2,46 @@ - {04d2c675-cf9d-4558-96a1-9b7c4ecb49fd} + {8cb9d895-422a-4776-8444-d95c58aefe68} - {04eb4642-a65a-4939-9e74-1c2e8510f40b} + {476df276-d107-4ea0-bafe-b8c6c9e63ab5} - {3dec0fab-9d61-4d6c-870c-f5e2296fd7a6} + {1f8125ea-915e-4c72-8319-624565cbaffd} - {9da13994-65c3-4905-bc72-46832a91642d} + {d16cb058-b766-427f-8c72-6d714f350f46} - {2a404352-8658-421f-8eed-876945b0522d} + {9c31f7ce-0b9e-4b82-8cc3-8691e1f7a098} - {57453ad3-c415-4d30-b9e1-2bc89d9f3ede} + {8922883d-d7c8-491a-9b71-3395f36ed939} - {e4deb48b-0c71-4a43-ba0b-f3912cad5c6a} + {1197a3d5-6b5d-41f3-8c0f-83e29f6b546e} - {f03eb07e-6ced-434b-9b64-f52eada04f38} + {20714908-a338-49c3-9ab1-8c2004fbc7a8} - {ac786ae0-2cc5-4116-a237-92c982d37e59} + {2c91e53d-22aa-4978-aaef-3f5d538a2915} - {9fa139ac-c199-4ed1-b047-09e7c9a359e1} + {ef241032-c641-4f6c-8552-b911e81578aa} - {91a2f443-1654-45d4-b960-01011d119d3f} + {2842873a-0e73-4242-a8ee-8f62c48a93dd} - {c02a5bf0-551e-419e-af66-9827fba8aacd} + {a62f1517-842c-489b-b428-7da9fa944529} - {6db315f2-1b79-4485-87e8-749c76b9ab98} + {6cccecc3-755c-47c1-bb33-0116d59722c9} - {c9ebd435-259c-42b1-a815-4b3ced87357f} + {8364dc36-0dd5-4ba1-ba28-ee5acdf62c0d} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_vs100.vcxproj b/XML/testsuite/TestSuite_vs100.vcxproj index 2b5b0adff..85cb6f563 100644 --- a/XML/testsuite/TestSuite_vs100.vcxproj +++ b/XML/testsuite/TestSuite_vs100.vcxproj @@ -314,6 +314,7 @@ + @@ -336,6 +337,7 @@ + diff --git a/XML/testsuite/TestSuite_vs100.vcxproj.filters b/XML/testsuite/TestSuite_vs100.vcxproj.filters index ef9b2df0b..1256c4d41 100644 --- a/XML/testsuite/TestSuite_vs100.vcxproj.filters +++ b/XML/testsuite/TestSuite_vs100.vcxproj.filters @@ -2,46 +2,46 @@ - {bc9aba96-c49c-4195-bfa9-5f20d70241a7} + {ec2eb88c-1700-449f-8f6e-eb216be03640} - {1aa1a2ca-04ae-4891-a268-93fc96c5a842} + {dec39912-44cb-43f3-a3d1-01d8e040086b} - {5f78a5d2-8bb6-40e7-985c-d32e9c91b1cb} + {d60502e2-58d7-4fd5-a6b6-56b40415a5c8} - {b10a80b0-6c2f-4099-8cc8-d759c7c64b48} + {9399ed0e-48b8-40fe-8431-22da540639a0} - {a33cf96a-6710-4338-a946-e9b169cd6e3a} + {11050c4d-e490-4a8c-b0e8-d02f376ac81c} - {54f773cb-7eb4-4b8a-b014-e82cf7d3509a} + {ec0988f7-17b0-437b-982f-07860a9827e9} - {436edf3e-593c-4299-9b50-500b04145e02} + {ce196639-c22c-44a8-90fa-0623e0b4c4e4} - {4570aa97-bb98-4ec5-a8d6-c312bf6cb461} + {faafea84-1544-45f9-80e6-0d9b9966dac4} - {ffb6caac-88f2-40d6-9d41-3398f23dce5b} + {f56c5547-4f8e-45d7-9562-b25199d6bd7d} - {775569c2-32e9-474b-b004-4081648b23a4} + {5c6b2cde-333f-4148-bfb1-87353ad5a809} - {00ca06f5-cc73-4919-b873-79f0b395cbe9} + {56286c53-dc19-48a1-bab9-88525b93baaf} - {7e377499-e76e-47bb-99b1-29d892c7f06c} + {6aef83e8-5a0c-4823-afc3-36b73dffe291} - {7d02d388-c64f-4f60-96e5-ea55c4ad7660} + {26215b04-7cba-42bb-9320-e7ecf9744f4c} - {e93fab3f-b349-4ea4-b035-5b8b0f26ba1d} + {1bbe57dd-5f62-4fa7-9e2b-0b9c3d4de956} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_vs110.vcxproj b/XML/testsuite/TestSuite_vs110.vcxproj index 08285dac1..46258cef1 100644 --- a/XML/testsuite/TestSuite_vs110.vcxproj +++ b/XML/testsuite/TestSuite_vs110.vcxproj @@ -314,6 +314,7 @@ + @@ -336,6 +337,7 @@ + diff --git a/XML/testsuite/TestSuite_vs110.vcxproj.filters b/XML/testsuite/TestSuite_vs110.vcxproj.filters index e042c9a26..94e325c4a 100644 --- a/XML/testsuite/TestSuite_vs110.vcxproj.filters +++ b/XML/testsuite/TestSuite_vs110.vcxproj.filters @@ -2,46 +2,46 @@ - {5e4eedb7-22c4-477e-ab5f-055135d3fdc9} + {43bbfc68-bfe4-4bf7-a083-2a9c6c32e91c} - {818ba16b-4e3a-45d7-a489-02ee149a2b90} + {15578e68-0dcb-4833-b9b9-503aa0abd4ab} - {d95ccc9e-1f48-46b5-b0ed-a1d008a6950a} + {02c4bee6-0ac5-493d-8bd1-4a91a1508c19} - {feee0dff-ad9a-42f4-b24c-9a5f8d8801cf} + {61d2c8b5-7fd4-4dbb-8b82-9d6214915fa2} - {6e10212f-0965-4a63-97f5-7eb6b5b18bef} + {77391364-028f-418a-8b62-2dc9ce96b77c} - {2183ede8-1c3a-4776-928e-4a4524645967} + {b4ac5212-5014-4a29-bc8e-33fb15ffb257} - {02c7712f-ebf2-46a7-a4db-20145db9c70f} + {1f50a48c-5e60-4898-a47f-371ad29a8121} - {c04c00ad-4f6d-49e4-b513-75284388f05b} + {7003eabe-a384-4adb-bf95-e0119c7e0084} - {72aab8c7-84c8-4e75-93cf-95345b30bc39} + {9bb3489d-159a-478d-b409-de8b2c7b3f65} - {05db9aec-6ef7-45a5-8592-84aa3233a477} + {bbe2f546-3202-4d3c-8673-f13d152ff36f} - {1f1fb568-4d3b-4d83-b9b4-d91f65263ff5} + {bceb424e-5b2e-4be8-91a7-5f720575500f} - {f17e8773-cb61-462d-8c14-d697ec747ede} + {21472ddb-4d06-417b-8065-d839efc80032} - {81017ffb-8b78-4f86-afbe-150134274e30} + {cfa29dc3-b002-4fe1-8899-5a81bff90b68} - {4390c02c-c425-4320-b711-da02419ac901} + {a3f87eee-3f2e-49de-a202-f4db8f7d7851} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_vs120.vcxproj b/XML/testsuite/TestSuite_vs120.vcxproj index e06bca1e1..7f8d12d55 100644 --- a/XML/testsuite/TestSuite_vs120.vcxproj +++ b/XML/testsuite/TestSuite_vs120.vcxproj @@ -322,6 +322,7 @@ + @@ -345,6 +346,7 @@ + diff --git a/XML/testsuite/TestSuite_vs120.vcxproj.filters b/XML/testsuite/TestSuite_vs120.vcxproj.filters index 418709a03..6126d51e4 100644 --- a/XML/testsuite/TestSuite_vs120.vcxproj.filters +++ b/XML/testsuite/TestSuite_vs120.vcxproj.filters @@ -2,46 +2,46 @@ - {461629a7-fd2c-4486-88b2-fba4f4ec3ec4} + {7177f691-34cf-4ca3-a2be-29fd8fa3a7f6} - {7560f633-6412-4600-9093-e8d0c2eb3474} + {2241c1e6-310f-4467-8842-3f595ee16ca4} - {7b25d885-0e12-475e-aacd-1535e9ffb1d7} + {8fb3fb9a-ebe1-4b45-b419-9608613defc9} - {4f3cd730-b92c-46c8-9bb0-a84681c72051} + {91446034-2101-479a-914c-5f262949fd41} - {d8b9f0b0-0edb-4602-885b-7fda97ef6ef1} + {fc8a1aa9-7b4f-4157-a1e6-272a862494ee} - {210418b1-d85b-41dd-aba0-b81750062d97} + {79166f97-ce90-43d7-88b4-8d98fc35b112} - {316e052e-9927-41b6-b461-2ff5f3789440} + {bbf4df39-e7e8-4cb9-ad40-b4f34002e415} - {181f4684-6210-47f5-b08d-fd4bac0c6919} + {7d68faba-2358-488d-87f2-17a6e0d161bf} - {4c25f60d-b843-451c-a707-e75c829fd889} + {b679fbe2-d088-476f-b122-1a16120f7a0b} - {a08735d3-ce6a-4a2e-b88c-b3b716bfe8cf} + {9fc2478a-304a-4295-95e1-cfaf36cfb184} - {99a54c29-d3a7-46de-84b0-490cd96ae8b2} + {a163677b-b142-4864-a22a-b2bc9c670266} - {0597e42c-d798-44a3-b211-abccb5ba31e5} + {ab05b85f-13ec-4d0c-8de9-02c41fb9d9d1} - {858bd4a7-decb-45ae-9dd1-f28db0c2c17a} + {656be10c-5a7f-486b-a307-cfb24e2cdfff} - {1f57629b-97c7-44c1-878b-e5e73450bde1} + {5c7f23c3-9b86-402b-8462-f3feb7276ad1} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_vs140.vcxproj b/XML/testsuite/TestSuite_vs140.vcxproj index c87eb8e4e..8ffe9da4f 100644 --- a/XML/testsuite/TestSuite_vs140.vcxproj +++ b/XML/testsuite/TestSuite_vs140.vcxproj @@ -322,6 +322,7 @@ + @@ -345,6 +346,7 @@ + diff --git a/XML/testsuite/TestSuite_vs140.vcxproj.filters b/XML/testsuite/TestSuite_vs140.vcxproj.filters index 4a53f9870..eeb45b125 100644 --- a/XML/testsuite/TestSuite_vs140.vcxproj.filters +++ b/XML/testsuite/TestSuite_vs140.vcxproj.filters @@ -2,46 +2,46 @@ - {9d5b10a7-8491-4151-81e0-c7fc6307698f} + {685faa05-1932-4358-8cf3-b1847bbd00aa} - {c88c324c-c084-4240-b95a-2148329845de} + {b19b094b-2c03-4e4b-a152-7df341e5c89c} - {8fd44539-b481-4b99-86cb-a20289c1199d} + {3f33afd7-5191-418f-8283-d1c06c635cc3} - {042e1b90-a7ac-4aeb-a0f3-8f3a60f4949c} + {b1e72ce4-249a-443b-aafe-e388ba126e93} - {88432b98-63d7-434e-810a-79e7cd0ada88} + {22603a36-6321-4e80-a8af-a4b5f65e50dc} - {cecfa4a5-6960-45cd-867e-7ee69c33e348} + {e6d55069-2f76-4ead-aae8-1d64dd1459de} - {3e9cf637-fb4d-4274-a22d-ec394023238c} + {855e5497-7f10-4117-b1e8-85999b8c9293} - {85677df1-3bbf-44fe-b71c-d1690c4ec49f} + {fba25d90-d813-4dc5-b7b0-c4959620fcc1} - {2c7ab1a4-d06f-4c7e-88ad-86d39a4bae79} + {becd105f-bbfd-461b-b152-0b2d6f8d9a4e} - {c91ea6d7-5870-424d-9544-d8486543fa53} + {86296a25-5f47-470f-8b8d-8640267440e1} - {1e15beeb-742a-4b73-b56b-66731bec8dee} + {006c8503-e692-4f54-a10c-bd0686a8c298} - {f8cf0215-cbdb-4ef8-863e-be4317407945} + {676536ec-c706-4c48-949a-05a6c815698f} - {610fcad3-258e-4845-a57b-5988daf66321} + {ef648185-de9d-4c6c-b644-4c78b06f4cff} - {9d07350d-a59d-4a0a-86ed-a52bba1c1a15} + {10390f1a-68a0-4c46-ac14-67026798063a} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_vs90.vcproj b/XML/testsuite/TestSuite_vs90.vcproj index f05bccae5..22bb453b5 100644 --- a/XML/testsuite/TestSuite_vs90.vcproj +++ b/XML/testsuite/TestSuite_vs90.vcproj @@ -451,6 +451,8 @@ RelativePath=".\src\NamePoolTest.h"/> + @@ -460,6 +462,8 @@ RelativePath=".\src\NamePoolTest.cpp"/> + diff --git a/XML/testsuite/TestSuite_x64_vs100.vcxproj b/XML/testsuite/TestSuite_x64_vs100.vcxproj index 70ebd2590..44426eaca 100644 --- a/XML/testsuite/TestSuite_x64_vs100.vcxproj +++ b/XML/testsuite/TestSuite_x64_vs100.vcxproj @@ -314,6 +314,7 @@ + @@ -336,6 +337,7 @@ + diff --git a/XML/testsuite/TestSuite_x64_vs100.vcxproj.filters b/XML/testsuite/TestSuite_x64_vs100.vcxproj.filters index a55b8c8b1..88b20ba07 100644 --- a/XML/testsuite/TestSuite_x64_vs100.vcxproj.filters +++ b/XML/testsuite/TestSuite_x64_vs100.vcxproj.filters @@ -2,46 +2,46 @@ - {1720e4e3-d855-4f86-b0b9-6430a0050baf} + {756ae8fd-2c9d-416f-9007-0486cfea332a} - {06bf93ef-eb84-4540-931c-fc2524a083f6} + {a615c3d2-5be7-4dff-940d-341c49136dba} - {09c5408d-d2c5-4b48-b06d-d12ec7509481} + {2fd29187-a891-4529-bd55-93dd518679ea} - {e0f8a06e-860a-4818-94b6-cd262c4076df} + {ef6b7ecf-99e6-4754-90a2-be0806a37c6b} - {8104922c-1339-4500-976d-ccaf9ffc687c} + {537844a0-59e4-4ec3-b02c-f135f0cacaa7} - {6b161e5a-2c48-4dab-9128-44f4cde0ff5e} + {3975afe3-3c30-4d1b-a6c3-62162131f9f5} - {a15166ce-f8f2-4f25-9cda-5508ed404611} + {d66152a6-35fd-4f01-a6b9-e4bc9b799e98} - {59cbd71a-e5ef-4f81-88af-f5a21f53f7c1} + {c9bb4b63-d2c3-4eec-9def-52dd7477ddd3} - {bb1776b0-a631-46dd-a5f0-2f44cb7d6d8d} + {3b5e2a25-42dc-4ad5-84f3-c769d42d30db} - {0a8161d4-3246-4fd0-882c-60b8389deca3} + {08387115-4f1b-434e-a772-443675066920} - {a0da31a4-a267-4119-9448-66c73ef096c8} + {3f501b88-8ec9-445c-bf08-523270de7c44} - {7205a71f-777c-4dd2-88bd-1f517e440b44} + {8354ee4e-35dd-4fc8-aa4a-3d9b44bcb2c7} - {f40e55fa-a0ba-4c68-bdff-f3961a2be6a9} + {b8c91003-d3b3-482c-816d-725084b1fba9} - {f611499e-7caf-4b3a-a695-c8d1b5bf88cb} + {52dccc56-6f02-4e55-a9fc-9102d3b71d78} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_x64_vs110.vcxproj b/XML/testsuite/TestSuite_x64_vs110.vcxproj index 2093c82a5..818c4d15b 100644 --- a/XML/testsuite/TestSuite_x64_vs110.vcxproj +++ b/XML/testsuite/TestSuite_x64_vs110.vcxproj @@ -314,6 +314,7 @@ + @@ -336,6 +337,7 @@ + diff --git a/XML/testsuite/TestSuite_x64_vs110.vcxproj.filters b/XML/testsuite/TestSuite_x64_vs110.vcxproj.filters index 2d73e79ee..e6f656d21 100644 --- a/XML/testsuite/TestSuite_x64_vs110.vcxproj.filters +++ b/XML/testsuite/TestSuite_x64_vs110.vcxproj.filters @@ -2,46 +2,46 @@ - {5d86026c-e3b2-4028-b038-ebcdbee8b274} + {91b19ff2-2259-41e8-9382-91f43af59f09} - {610aa5fc-58f6-4b48-831d-eee2ae68b0f3} + {55005bef-a40f-4a47-832c-00618940744b} - {9b6f63a9-d9fc-46ff-9f74-d0913a7d1a26} + {1439a8d0-2999-448b-a0b2-234dcf90f167} - {deb7738e-332f-43bc-aac3-9a8b1923e138} + {20cd544c-d3ed-4bb5-81b9-c85a8c51b04a} - {922c2fa7-f6fa-494c-a839-247a4e59223e} + {96abbad6-02be-460a-9c92-3d49d9262cf1} - {e0a907fb-0eac-490f-a9ca-530dee3365af} + {0b933f63-c45e-4a88-9d0a-1178e8771d8d} - {07ca85d7-830a-46be-9455-78288b74dd19} + {17098242-1c03-4c21-9c3a-75b915da4c45} - {51d4a56c-5db7-4372-847e-e7d76f0e174c} + {ed4d11a7-705c-4ced-94c8-ca473c6221fa} - {9cc551f5-9b31-47e3-8a50-4cb0a1bbe361} + {55169d8f-993d-4a5d-bb45-836ebc5e0b5d} - {9aa34657-479b-4889-945d-56827b1bd601} + {b61eaec2-816d-4e22-95e6-23105ce131eb} - {5f051ba4-d3a3-4e6e-98bd-c376c34a4f7e} + {7869ee36-81ec-4a99-8704-dd7830b4a1e7} - {3df2909a-7644-485b-8817-ba20392c085d} + {c32d5306-29d6-4977-a48b-7fe1d4c61ac0} - {4c1b3a49-d0eb-458f-b03d-a52f258e48ca} + {07d2387f-3780-4e27-9acf-cf121610e4e5} - {d050403e-b877-4d53-9f8a-d0a39d6fd9d7} + {4da0fabf-438d-4ed9-9e7c-57f06b53eb3e} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_x64_vs120.vcxproj b/XML/testsuite/TestSuite_x64_vs120.vcxproj index 10929755f..6710d869a 100644 --- a/XML/testsuite/TestSuite_x64_vs120.vcxproj +++ b/XML/testsuite/TestSuite_x64_vs120.vcxproj @@ -322,6 +322,7 @@ + @@ -345,6 +346,7 @@ + diff --git a/XML/testsuite/TestSuite_x64_vs120.vcxproj.filters b/XML/testsuite/TestSuite_x64_vs120.vcxproj.filters index 938f0687f..d160e8183 100644 --- a/XML/testsuite/TestSuite_x64_vs120.vcxproj.filters +++ b/XML/testsuite/TestSuite_x64_vs120.vcxproj.filters @@ -2,46 +2,46 @@ - {bb9d2019-f348-4295-87dc-86875bc7ec06} + {b8169cfc-cea2-404f-a861-5c5642933475} - {b0c6e7e5-d074-4959-bd0c-af1ad61e0e27} + {63946961-24f8-4ef6-b0b5-443e2f920ea2} - {af032506-79c6-4a71-9cab-7e4b9fab91a3} + {b187d08f-ccbb-4d0a-836b-57213d670ba6} - {a58876af-0c26-472f-9b22-dea617590f39} + {838a0d8d-7d17-4f61-a426-633af0e14ddc} - {5009cc2a-0d20-428a-beb0-e02d749bcb44} + {1672f929-5d30-4ed2-8b04-e04d10a66c9d} - {744ca67e-6d28-40c9-8ea0-619f98f40de1} + {22b9604c-3851-42bc-bc2d-44b3ba3befb0} - {83584577-c541-4ef6-9de2-13be7091dc80} + {dcdd221a-a16f-4ad9-b78d-1a975b4a3772} - {48d02d34-747b-4ad5-9ea1-1ce6f64c8bda} + {b3b1a945-8c16-4851-b111-09425e409a99} - {fb9223b6-cec9-4631-9925-f6967681c23a} + {feb33e81-f76f-4c64-8cdb-c1f927175179} - {9cfa074e-3491-4174-81c1-2851f4116d89} + {c72f089c-fe87-44b1-8fc2-e6a945f6c2cf} - {48790fea-9316-43b0-a3e5-e71b4e5f504e} + {1e6ee134-f65e-420a-a143-c3d4df95c998} - {422246f0-c97e-4bb2-9443-f4c527e3ae29} + {84d1c6e7-5e49-439e-825e-67aa256c9f20} - {bfbc344e-b88f-4d19-8356-b62654aabca9} + {cb0e4ff4-72d3-4aaa-9dde-cf18e4d1409c} - {a7a11833-acfc-4cb2-ae80-7827ffeb56d5} + {4eb10896-0f4d-4a6d-b727-67da0fb8a62e} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_x64_vs140.vcxproj b/XML/testsuite/TestSuite_x64_vs140.vcxproj index 4c6d83d01..5f833f6cf 100644 --- a/XML/testsuite/TestSuite_x64_vs140.vcxproj +++ b/XML/testsuite/TestSuite_x64_vs140.vcxproj @@ -322,6 +322,7 @@ + @@ -345,6 +346,7 @@ + diff --git a/XML/testsuite/TestSuite_x64_vs140.vcxproj.filters b/XML/testsuite/TestSuite_x64_vs140.vcxproj.filters index d2149fb31..289afb416 100644 --- a/XML/testsuite/TestSuite_x64_vs140.vcxproj.filters +++ b/XML/testsuite/TestSuite_x64_vs140.vcxproj.filters @@ -2,46 +2,46 @@ - {2cd7c61d-cfce-4c58-bc4b-24cc9c41a4e6} + {e59b8b5c-eed7-4926-9258-590c5abde857} - {35c26d4e-a150-4820-8204-ddc65810e7f2} + {0a5c3832-2211-4d27-a159-aedcdf2acc75} - {14359eb7-b59e-4859-9be2-5c3cfa8f6c32} + {dbe9c0d2-cabb-4cb4-8e89-58f892354625} - {2191de5e-4144-41ad-b508-e2694470fbb1} + {c02ff0d6-f08d-4d8f-b4ea-4a18c4b31d1d} - {6e87a0d3-8679-4086-bdbd-33bf19c7a3b7} + {72f47ec0-42ee-4740-a7eb-55d1731972f8} - {3574c80e-e4b1-490c-b33d-2f802006a874} + {003c1725-82e9-4ec4-97f2-4aaac760ea34} - {400834f9-404d-4c1f-b003-d9ad5620e923} + {e4c0fdea-fedd-45fa-a4ec-c86029578475} - {2cfa34ba-1503-40c7-96a4-36133f7482a1} + {f4e72b05-f017-4cc1-80b0-6b8414ca5938} - {bba1edf2-61cb-4d41-9a31-e560181f2e5a} + {353cead1-84ea-4925-a4cd-73095cbcd079} - {76e9fd91-9a50-44ed-bbaf-a520af6acc4f} + {8bc04bdd-b80d-4eb2-9a14-0a4d889d132a} - {65df11ec-80d6-40b9-a403-c97aec24342a} + {494e7516-583e-4d7f-9a2b-113f5cd51914} - {5e4ed61d-73b5-4b46-9a01-cd027708aacc} + {d654db14-789d-4962-a218-800281fe5b25} - {374f10bf-6371-4767-a2bf-56234563ae6d} + {41477b5c-0276-4acc-adbb-54fdf2c0b8bf} - {b7fd1d37-0845-403d-b27a-01e5ecfaf4a3} + {78707bfd-fe2a-4ea6-9a88-4e7c7185ad1b} @@ -51,6 +51,9 @@ XML\Header Files + + XML\Header Files + XML\Header Files @@ -113,6 +116,9 @@ XML\Source Files + + XML\Source Files + XML\Source Files diff --git a/XML/testsuite/TestSuite_x64_vs90.vcproj b/XML/testsuite/TestSuite_x64_vs90.vcproj index 29d76dcc1..b02aea373 100644 --- a/XML/testsuite/TestSuite_x64_vs90.vcproj +++ b/XML/testsuite/TestSuite_x64_vs90.vcproj @@ -451,6 +451,8 @@ RelativePath=".\src\NamePoolTest.h"/> + @@ -460,6 +462,8 @@ RelativePath=".\src\NamePoolTest.cpp"/> + From 843f2514876954f4958f06b8099794cca6f5d0ba Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Mon, 7 Sep 2015 17:53:25 +0200 Subject: [PATCH 26/38] support for AF_UNIX socket address --- Net/include/Poco/Net/IPAddress.h | 4 +- Net/include/Poco/Net/IPAddressImpl.h | 4 +- Net/include/Poco/Net/SocketAddress.h | 77 +++++++++++--- Net/include/Poco/Net/SocketAddressImpl.h | 122 +++++++++++++++++++--- Net/include/Poco/Net/SocketDefs.h | 15 ++- Net/src/MulticastSocket.cpp | 4 +- Net/src/SocketAddress.cpp | 123 +++++++++++++++-------- Net/src/SocketAddressImpl.cpp | 64 ++++++++++++ Net/src/SocketImpl.cpp | 2 +- 9 files changed, 333 insertions(+), 82 deletions(-) diff --git a/Net/include/Poco/Net/IPAddress.h b/Net/include/Poco/Net/IPAddress.h index 8dc290c65..2ae11628a 100644 --- a/Net/include/Poco/Net/IPAddress.h +++ b/Net/include/Poco/Net/IPAddress.h @@ -61,9 +61,9 @@ public: enum Family /// Possible address families for IP addresses. { - IPv4 = Poco::Net::Impl::IPAddressImpl::IPv4 + IPv4 = Poco::Net::Impl::IPAddressImpl::IPv4, #ifdef POCO_HAVE_IPv6 - ,IPv6 = Poco::Net::Impl::IPAddressImpl::IPv6 + IPv6 = Poco::Net::Impl::IPAddressImpl::IPv6 #endif }; diff --git a/Net/include/Poco/Net/IPAddressImpl.h b/Net/include/Poco/Net/IPAddressImpl.h index eb90b8e56..64587d2cf 100644 --- a/Net/include/Poco/Net/IPAddressImpl.h +++ b/Net/include/Poco/Net/IPAddressImpl.h @@ -42,9 +42,9 @@ public: enum Family /// Possible address families for IP addresses. { - IPv4 + IPv4, #ifdef POCO_HAVE_IPv6 - ,IPv6 + IPv6 #endif }; diff --git a/Net/include/Poco/Net/SocketAddress.h b/Net/include/Poco/Net/SocketAddress.h index ee1029ed4..e47f091bc 100644 --- a/Net/include/Poco/Net/SocketAddress.h +++ b/Net/include/Poco/Net/SocketAddress.h @@ -43,6 +43,18 @@ class Net_API SocketAddress /// host address and a port number. { public: + enum Family + /// Possible address families for socket addresses. + { + IPv4 = Poco::Net::Impl::SocketAddressImpl::IPv4, +#ifdef POCO_HAVE_IPv6 + IPv6 = Poco::Net::Impl::SocketAddressImpl::IPv6, +#endif +#ifdef POCO_OS_FAMILY_UNIX + UNIX_LOCAL = Poco::Net::Impl::SocketAddressImpl::UNIX_LOCAL +#endif + }; + SocketAddress(); /// Creates a wildcard (all zero) IPv4 SocketAddress. @@ -80,6 +92,13 @@ public: /// [::ffff:192.168.1.120]:2040 /// www.appinf.com:8080 + SocketAddress(Family family, const std::string& addr); + /// Creates a SocketAddress of the given family from a + /// string representation of the address, which is + /// either an IP address and port number, separated by + /// a colon for IPv4 or IPv6 addresses, or a path for + /// UNIX_LOCAL sockets. + SocketAddress(const SocketAddress& addr); /// Creates a SocketAddress by copying another one. @@ -110,7 +129,7 @@ public: std::string toString() const; /// Returns a string representation of the address. - IPAddress::Family family() const; + Family family() const; /// Returns the address family of the host's address. bool operator < (const SocketAddress& socketAddress) const; @@ -131,6 +150,8 @@ public: protected: void init(const IPAddress& hostAddress, Poco::UInt16 portNumber); void init(const std::string& hostAddress, Poco::UInt16 portNumber); + void init(Family family, const std::string& address); + void init(const std::string& hostAndPort); Poco::UInt16 resolveService(const std::string& service); private: @@ -144,14 +165,18 @@ private: Ptr pImpl() const; void newIPv4(); - void newIPv4(const sockaddr_in*); - void newIPv4(const IPAddress& hostAddress, Poco::UInt16 portNumber); - + +#if defined(POCO_HAVE_IPv6) void newIPv6(const sockaddr_in6*); - void newIPv6(const IPAddress& hostAddress, Poco::UInt16 portNumber); +#endif + +#if defined(POCO_OS_FAMILY_UNIX) + void newLocal(const sockaddr_un* sockAddr); + void newLocal(const std::string& path); +#endif void destruct(); @@ -168,7 +193,11 @@ private: AlignerType aligner; } #else // !POCO_ENABLE_CPP11 - AlignedCharArrayUnion + #if defined(POCO_HAVE_IPv6) + AlignedCharArrayUnion + #else + AlignedCharArrayUnion + #endif #endif // POCO_ENABLE_CPP11 _memory; #else // !POCO_HAVE_ALIGNMENT @@ -231,7 +260,7 @@ inline void SocketAddress::newIPv4(const IPAddress& hostAddress, Poco::UInt16 po } - +#if defined(POCO_HAVE_IPv6) inline void SocketAddress::newIPv6(const sockaddr_in6* sockAddr) { #ifdef POCO_HAVE_ALIGNMENT @@ -240,7 +269,7 @@ inline void SocketAddress::newIPv6(const sockaddr_in6* sockAddr) _pImpl = new Poco::Net::Impl::IPv6SocketAddressImpl(sockAddr); #endif } - + inline void SocketAddress::newIPv6(const IPAddress& hostAddress, Poco::UInt16 portNumber) { @@ -250,14 +279,31 @@ inline void SocketAddress::newIPv6(const IPAddress& hostAddress, Poco::UInt16 po _pImpl = new Poco::Net::Impl::IPv6SocketAddressImpl(hostAddress.addr(), htons(portNumber), hostAddress.scope()); #endif } +#endif // POCO_HAVE_IPv6 -inline IPAddress::Family SocketAddress::family() const +#if defined(POCO_OS_FAMILY_UNIX) +inline void SocketAddress::newLocal(const sockaddr_un* sockAddr) { - return host().family(); +#ifdef POCO_HAVE_ALIGNMENT + new (storage()) Poco::Net::Impl::LocalSocketAddressImpl(sockAddr); +#else + _pImpl = new Poco::Net::Impl::LocalSocketAddressImpl(sockAddr); +#endif } +inline void SocketAddress::newLocal(const std::string& path) +{ +#ifdef POCO_HAVE_ALIGNMENT + new (storage()) Poco::Net::Impl::LocalSocketAddressImpl(path.c_str()); +#else + _pImpl = new Poco::Net::Impl::LocalSocketAddressImpl(path.c_str()); +#endif +} +#endif // POCO_OS_FAMILY_UNIX + + #ifdef POCO_HAVE_ALIGNMENT inline char* SocketAddress::storage() { @@ -266,15 +312,20 @@ inline char* SocketAddress::storage() #endif -inline bool SocketAddress::operator == (const SocketAddress& socketAddress) const +inline bool SocketAddress::operator == (const SocketAddress& socketAddress) const { - return host() == socketAddress.host() && port() == socketAddress.port(); +#if defined(POCO_OS_FAMILY_UNIX) + if (family() == UNIX_LOCAL) + return host() == socketAddress.host() && port() == socketAddress.port(); + else +#endif + return toString() == socketAddress.toString(); } inline bool SocketAddress::operator != (const SocketAddress& socketAddress) const { - return host() != socketAddress.host() || port() != socketAddress.port(); + return !operator == (socketAddress); } diff --git a/Net/include/Poco/Net/SocketAddressImpl.h b/Net/include/Poco/Net/SocketAddressImpl.h index 40835d2eb..01a52eb22 100644 --- a/Net/include/Poco/Net/SocketAddressImpl.h +++ b/Net/include/Poco/Net/SocketAddressImpl.h @@ -38,6 +38,18 @@ class Net_API SocketAddressImpl #endif { public: + enum Family + /// Possible address families for socket addresses. + { + IPv4, +#ifdef POCO_HAVE_IPv6 + IPv6, +#endif +#ifdef POCO_OS_FAMILY_UNIX + UNIX_LOCAL +#endif + }; + virtual ~SocketAddressImpl(); virtual IPAddress host() const = 0; @@ -45,6 +57,8 @@ public: virtual poco_socklen_t length() const = 0; virtual const struct sockaddr* addr() const = 0; virtual int af() const = 0; + virtual Family family() const = 0; + virtual std::string toString() const = 0; protected: SocketAddressImpl(); @@ -59,20 +73,15 @@ class Net_API IPv4SocketAddressImpl: public SocketAddressImpl { public: IPv4SocketAddressImpl(); - IPv4SocketAddressImpl(const struct sockaddr_in* addr); - IPv4SocketAddressImpl(const void* addr, UInt16 port); - IPAddress host() const; - UInt16 port() const; - poco_socklen_t length() const; - const struct sockaddr* addr() const; - int af() const; + Family family() const; + std::string toString() const; private: struct sockaddr_in _addr; @@ -113,6 +122,12 @@ inline int IPv4SocketAddressImpl::af() const } +inline SocketAddressImpl::Family IPv4SocketAddressImpl::family() const +{ + return SocketAddressImpl::IPv4; +} + + #if defined(POCO_HAVE_IPv6) @@ -120,20 +135,15 @@ class Net_API IPv6SocketAddressImpl: public SocketAddressImpl { public: IPv6SocketAddressImpl(const struct sockaddr_in6* addr); - IPv6SocketAddressImpl(const void* addr, UInt16 port); - IPv6SocketAddressImpl(const void* addr, UInt16 port, UInt32 scope); - IPAddress host() const; - UInt16 port() const; - poco_socklen_t length() const; - const struct sockaddr* addr() const; - - int af() const; + int af() const; + Family family() const; + std::string toString() const; private: struct sockaddr_in6 _addr; @@ -174,7 +184,87 @@ inline int IPv6SocketAddressImpl::af() const } -#endif //POCO_HAVE_IPv6 +inline SocketAddressImpl::Family IPv6SocketAddressImpl::family() const +{ + return SocketAddressImpl::IPv6; +} + + +#endif // POCO_HAVE_IPv6 + + +#if defined(POCO_OS_FAMILY_UNIX) + + +class Net_API LocalSocketAddressImpl: public SocketAddressImpl +{ +public: + LocalSocketAddressImpl(const struct sockaddr_un* addr); + LocalSocketAddressImpl(const char* path); + ~LocalSocketAddressImpl(); + IPAddress host() const; + UInt16 port() const; + poco_socklen_t length() const; + const struct sockaddr* addr() const; + int af() const; + Family family() const; + const char* path() const; + std::string toString() const; + +private: + struct sockaddr_un* _pAddr; + // Note: We allocate struct sockaddr_un on the heap, otherwise we would + // waste a lot of memory due to small object optimization in SocketAddress. +}; + + +// +// inlines +// + +inline IPAddress LocalSocketAddressImpl::host() const +{ + throw Poco::InvalidAccessException("local socket address does not have host IP address"); +} + + +inline UInt16 LocalSocketAddressImpl::port() const +{ + throw Poco::InvalidAccessException("local socket address does not have port number"); +} + + +inline poco_socklen_t LocalSocketAddressImpl::length() const +{ + return sizeof(struct sockaddr_un); +} + + +inline const struct sockaddr* LocalSocketAddressImpl::addr() const +{ + return reinterpret_cast(_pAddr); +} + + +inline int LocalSocketAddressImpl::af() const +{ + return _pAddr->sun_family; +} + + +inline SocketAddressImpl::Family LocalSocketAddressImpl::family() const +{ + return SocketAddressImpl::UNIX_LOCAL; +} + + +inline const char* LocalSocketAddressImpl::path() const +{ + return _pAddr->sun_path; +} + + +#endif // POCO_OS_FAMILY_UNIX } } } // namespace Poco::Net::Impl diff --git a/Net/include/Poco/Net/SocketDefs.h b/Net/include/Poco/Net/SocketDefs.h index e7583a0b7..ccc91fa16 100644 --- a/Net/include/Poco/Net/SocketDefs.h +++ b/Net/include/Poco/Net/SocketDefs.h @@ -134,6 +134,7 @@ #include #include #include + #include #include #if POCO_OS != POCO_OS_HPUX #include @@ -271,15 +272,19 @@ #if defined(POCO_HAVE_SALEN) - #define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len) - #define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in) + #define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len) + #define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in) #if defined(POCO_HAVE_IPv6) #define poco_set_sin6_len(pSA) (pSA)->sin6_len = sizeof(struct sockaddr_in6) #endif + #if defined(POCO_OS_FAMILY_UNIX) + #define poco_set_sun_len(pSA, len) (pSA)->sun_len = (len) + #endif #else - #define poco_set_sa_len(pSA, len) (void) 0 - #define poco_set_sin_len(pSA) (void) 0 - #define poco_set_sin6_len(pSA) (void) 0 + #define poco_set_sa_len(pSA, len) (void) 0 + #define poco_set_sin_len(pSA) (void) 0 + #define poco_set_sin6_len(pSA) (void) 0 + #define poco_set_sun_len(pSA, len) (void) 0 #endif diff --git a/Net/src/MulticastSocket.cpp b/Net/src/MulticastSocket.cpp index 6bd388ccd..e14f8ffb4 100644 --- a/Net/src/MulticastSocket.cpp +++ b/Net/src/MulticastSocket.cpp @@ -82,12 +82,12 @@ MulticastSocket& MulticastSocket::operator = (const Socket& socket) void MulticastSocket::setInterface(const NetworkInterface& interfc) { - if (address().family() == IPAddress::IPv4) + if (address().family() == SocketAddress::IPv4) { impl()->setOption(IPPROTO_IP, IP_MULTICAST_IF, interfc.firstAddress(IPAddress::IPv4)); } #if defined(POCO_HAVE_IPv6) - else if (address().family() == IPAddress::IPv6) + else if (address().family() == SocketAddress::IPv6) { impl()->setOption(IPPROTO_IPV6, IPV6_MULTICAST_IF, interfc.index()); } diff --git a/Net/src/SocketAddress.cpp b/Net/src/SocketAddress.cpp index cf2721d74..2b9bf26d8 100644 --- a/Net/src/SocketAddress.cpp +++ b/Net/src/SocketAddress.cpp @@ -20,7 +20,6 @@ #include "Poco/Net/DNS.h" #include "Poco/RefCountedObject.h" #include "Poco/NumberParser.h" -#include "Poco/NumberFormatter.h" #include "Poco/BinaryReader.h" #include "Poco/BinaryWriter.h" #include @@ -29,12 +28,16 @@ using Poco::RefCountedObject; using Poco::NumberParser; -using Poco::NumberFormatter; using Poco::UInt16; using Poco::InvalidArgumentException; using Poco::Net::Impl::SocketAddressImpl; using Poco::Net::Impl::IPv4SocketAddressImpl; +#ifdef POCO_HAVE_IPv6 using Poco::Net::Impl::IPv6SocketAddressImpl; +#endif +#ifdef POCO_OS_FAMILY_UNIX +using Poco::Net::Impl::LocalSocketAddressImpl; +#endif namespace Poco { @@ -85,41 +88,30 @@ SocketAddress::SocketAddress(const std::string& hostAddress, const std::string& } +SocketAddress::SocketAddress(Family family, const std::string& addr) +{ + init(family, addr); +} + + SocketAddress::SocketAddress(const std::string& hostAndPort) { - poco_assert (!hostAndPort.empty()); - - std::string host; - std::string port; - std::string::const_iterator it = hostAndPort.begin(); - std::string::const_iterator end = hostAndPort.end(); - if (*it == '[') - { - ++it; - while (it != end && *it != ']') host += *it++; - if (it == end) throw InvalidArgumentException("Malformed IPv6 address"); - ++it; - } - else - { - while (it != end && *it != ':') host += *it++; - } - if (it != end && *it == ':') - { - ++it; - while (it != end) port += *it++; - } - else throw InvalidArgumentException("Missing port number"); - init(host, resolveService(port)); + init(hostAndPort); } SocketAddress::SocketAddress(const SocketAddress& socketAddress) { - if (socketAddress.family() == IPAddress::IPv4) + if (socketAddress.family() == IPv4) newIPv4(reinterpret_cast(socketAddress.addr())); - else +#if defined(POCO_HAVE_IPv6) + else if (socketAddress.family() == IPv6) newIPv6(reinterpret_cast(socketAddress.addr())); +#endif +#if defined(POCO_OS_FAMILY_UNIX) + else if (socketAddress.family() == UNIX_LOCAL) + newLocal(reinterpret_cast(socketAddress.addr())); +#endif } @@ -130,6 +122,10 @@ SocketAddress::SocketAddress(const struct sockaddr* sockAddr, poco_socklen_t len #if defined(POCO_HAVE_IPv6) else if (length == sizeof(struct sockaddr_in6)) newIPv6(reinterpret_cast(sockAddr)); +#endif +#if defined(POCO_OS_FAMILY_UNIX) + else if (length > 0 && length <= sizeof(struct sockaddr_un) && sockAddr->sa_family == AF_UNIX) + newLocal(reinterpret_cast(sockAddr)); #endif else throw Poco::InvalidArgumentException("Invalid address length passed to SocketAddress()"); } @@ -145,6 +141,9 @@ bool SocketAddress::operator < (const SocketAddress& socketAddress) const { if (family() < socketAddress.family()) return true; if (family() > socketAddress.family()) return false; +#if defined(POCO_OS_FAMILY_UNIX) + if (family() == UNIX_LOCAL) return toString() < socketAddress.toString(); +#endif if (host() < socketAddress.host()) return true; if (host() > socketAddress.host()) return false; return (port() < socketAddress.port()); @@ -156,10 +155,16 @@ SocketAddress& SocketAddress::operator = (const SocketAddress& socketAddress) if (&socketAddress != this) { destruct(); - if (socketAddress.family() == IPAddress::IPv4) + if (socketAddress.family() == IPv4) newIPv4(reinterpret_cast(socketAddress.addr())); - else +#if defined(POCO_HAVE_IPv6) + else if (socketAddress.family() == IPv6) newIPv6(reinterpret_cast(socketAddress.addr())); +#endif +#if defined(POCO_OS_FAMILY_UNIX) + else if (socketAddress.family() == UNIX_LOCAL) + newLocal(reinterpret_cast(socketAddress.addr())); +#endif } return *this; } @@ -195,19 +200,15 @@ int SocketAddress::af() const } +SocketAddress::Family SocketAddress::family() const +{ + return static_cast(pImpl()->family()); +} + + std::string SocketAddress::toString() const { - std::string result; -#if defined(POCO_HAVE_IPv6) - if (host().family() == IPAddress::IPv6) - result.append("["); - result.append(host().toString()); - if (host().family() == IPAddress::IPv6) - result.append("]"); -#endif - result.append(":"); - NumberFormatter::append(result, port()); - return result; + return pImpl()->toString(); } @@ -247,6 +248,46 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber } +void SocketAddress::init(Family family, const std::string& address) +{ + if (family == UNIX_LOCAL) + { + newLocal(address); + } + else + { + init(address); + } +} + + +void SocketAddress::init(const std::string& hostAndPort) +{ + std::string host; + std::string port; + std::string::const_iterator it = hostAndPort.begin(); + std::string::const_iterator end = hostAndPort.end(); + if (*it == '[') + { + ++it; + while (it != end && *it != ']') host += *it++; + if (it == end) throw InvalidArgumentException("Malformed IPv6 address"); + ++it; + } + else + { + while (it != end && *it != ':') host += *it++; + } + if (it != end && *it == ':') + { + ++it; + while (it != end) port += *it++; + } + else throw InvalidArgumentException("Missing port number"); + init(host, resolveService(port)); +} + + Poco::UInt16 SocketAddress::resolveService(const std::string& service) { unsigned port; diff --git a/Net/src/SocketAddressImpl.cpp b/Net/src/SocketAddressImpl.cpp index f2de61b46..9cb60bb06 100644 --- a/Net/src/SocketAddressImpl.cpp +++ b/Net/src/SocketAddressImpl.cpp @@ -16,6 +16,7 @@ #include "Poco/Net/SocketAddressImpl.h" #include "Poco/Net/SocketDefs.h" +#include "Poco/NumberFormatter.h" #include @@ -23,6 +24,7 @@ namespace Poco { namespace Net { namespace Impl { + // // SocketAddressImpl // @@ -66,6 +68,16 @@ IPv4SocketAddressImpl::IPv4SocketAddressImpl(const void* addr, UInt16 port) } +std::string IPv4SocketAddressImpl::toString() const +{ + std::string result; + result.append(host().toString()); + result.append(":"); + NumberFormatter::append(result, port()); + return result; +} + + #if defined(POCO_HAVE_IPv6) @@ -101,7 +113,59 @@ IPv6SocketAddressImpl::IPv6SocketAddressImpl(const void* addr, UInt16 port, UInt } +std::string IPv6SocketAddressImpl::toString() const +{ + std::string result; + result.append("["); + result.append(host().toString()); + result.append("]"); + result.append(":"); + NumberFormatter::append(result, port()); + return result; +} + + #endif // POCO_HAVE_IPv6 +#if defined(POCO_OS_FAMILY_UNIX) + + +// +// LocalSocketAddressImpl +// + + +LocalSocketAddressImpl::LocalSocketAddressImpl(const struct sockaddr_un* addr) +{ + _pAddr = new sockaddr_un; + std::memcpy(_pAddr, addr, sizeof(struct sockaddr_un)); +} + + +LocalSocketAddressImpl::LocalSocketAddressImpl(const char* path) +{ + _pAddr = new sockaddr_un; + poco_set_sun_len(_pAddr, std::strlen(path) + sizeof(struct sockaddr_un) - sizeof(_pAddr->sun_path) + 1); + _pAddr->sun_family = AF_UNIX; + std::strcpy(_pAddr->sun_path, path); +} + + +LocalSocketAddressImpl::~LocalSocketAddressImpl() +{ + delete _pAddr; +} + + +std::string LocalSocketAddressImpl::toString() const +{ + std::string result(path()); + return result; +} + + +#endif // POCO_OS_FAMILY_UNIX + + } } } // namespace Poco::Net::Impl diff --git a/Net/src/SocketImpl.cpp b/Net/src/SocketImpl.cpp index 14d872bf3..5c33434f4 100644 --- a/Net/src/SocketImpl.cpp +++ b/Net/src/SocketImpl.cpp @@ -212,7 +212,7 @@ void SocketImpl::bind(const SocketAddress& address, bool reuseAddress) void SocketImpl::bind6(const SocketAddress& address, bool reuseAddress, bool ipV6Only) { #if defined(POCO_HAVE_IPv6) - if (address.family() != IPAddress::IPv6) + if (address.family() != SocketAddress::IPv6) throw Poco::InvalidArgumentException("SocketAddress must be an IPv6 address"); if (_sockfd == POCO_INVALID_SOCKET) From d64ec94653b8d22ffab8a1399c173795fe0d6a6e Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 14:15:38 +0200 Subject: [PATCH 27/38] UNIX domain sockets support: replace IPAddress::Family with new enum AddressFamily::Family enum --- Net/include/Poco/Net/DatagramSocket.h | 2 +- Net/include/Poco/Net/DatagramSocketImpl.h | 2 +- Net/include/Poco/Net/ICMPClient.h | 6 ++-- Net/include/Poco/Net/ICMPPacket.h | 2 +- Net/include/Poco/Net/ICMPSocket.h | 2 +- Net/include/Poco/Net/ICMPSocketImpl.h | 2 +- Net/include/Poco/Net/IPAddress.h | 16 +++++----- Net/include/Poco/Net/IPAddressImpl.h | 9 +----- Net/include/Poco/Net/MulticastSocket.h | 2 +- Net/include/Poco/Net/NTPClient.h | 4 +-- Net/include/Poco/Net/RawSocket.h | 2 +- Net/include/Poco/Net/RawSocketImpl.h | 2 +- Net/include/Poco/Net/SocketAddress.h | 24 +++++++-------- Net/include/Poco/Net/SocketAddressImpl.h | 19 ++++-------- Net/include/Poco/Net/SocketDefs.h | 28 ++++++++++++++++++ Net/include/Poco/Net/StreamSocket.h | 2 +- Net/include/Poco/Net/StreamSocketImpl.h | 2 +- Net/src/DatagramSocket.cpp | 2 +- Net/src/DatagramSocketImpl.cpp | 10 +++++-- Net/src/ICMPClient.cpp | 2 +- Net/src/IPAddress.cpp | 6 ++++ Net/src/IPAddressImpl.cpp | 6 ++-- Net/src/MulticastSocket.cpp | 9 ++++-- Net/src/RawSocket.cpp | 2 +- Net/src/RawSocketImpl.cpp | 6 ++-- Net/src/SocketAddress.cpp | 19 +++++++++--- Net/src/SocketAddressImpl.cpp | 5 ++-- Net/src/StreamSocket.cpp | 2 +- Net/src/StreamSocketImpl.cpp | 10 +++++-- Net/testsuite/src/SocketAddressTest.cpp | 36 +++++++++++++++++++++++ Net/testsuite/src/SocketAddressTest.h | 1 + 31 files changed, 161 insertions(+), 81 deletions(-) diff --git a/Net/include/Poco/Net/DatagramSocket.h b/Net/include/Poco/Net/DatagramSocket.h index 74c4c5e3d..cd93aa317 100644 --- a/Net/include/Poco/Net/DatagramSocket.h +++ b/Net/include/Poco/Net/DatagramSocket.h @@ -36,7 +36,7 @@ public: DatagramSocket(); /// Creates an unconnected IPv4 datagram socket. - explicit DatagramSocket(IPAddress::Family family); + explicit DatagramSocket(SocketAddress::Family family); /// Creates an unconnected datagram socket. /// /// The socket will be created for the diff --git a/Net/include/Poco/Net/DatagramSocketImpl.h b/Net/include/Poco/Net/DatagramSocketImpl.h index ce36cfeea..c6a30bdab 100644 --- a/Net/include/Poco/Net/DatagramSocketImpl.h +++ b/Net/include/Poco/Net/DatagramSocketImpl.h @@ -39,7 +39,7 @@ public: /// be an IPv6 socket. Otherwise, it will be /// an IPv4 socket. - explicit DatagramSocketImpl(IPAddress::Family family); + explicit DatagramSocketImpl(SocketAddress::Family family); /// Creates an unconnected datagram socket. /// /// The socket will be created for the diff --git a/Net/include/Poco/Net/ICMPClient.h b/Net/include/Poco/Net/ICMPClient.h index b3a27b686..275bf52d6 100644 --- a/Net/include/Poco/Net/ICMPClient.h +++ b/Net/include/Poco/Net/ICMPClient.h @@ -46,7 +46,7 @@ public: mutable Poco::BasicEvent pingError; mutable Poco::BasicEvent pingEnd; - explicit ICMPClient(IPAddress::Family family); + explicit ICMPClient(SocketAddress::Family family); /// Creates an ICMP client. ~ICMPClient(); @@ -64,7 +64,7 @@ public: /// /// Returns the number of valid replies. - static int ping(SocketAddress& address, IPAddress::Family family, int repeat = 1); + static int ping(SocketAddress& address, SocketAddress::Family family, int repeat = 1); /// Pings the specified address [repeat] times. /// Notifications are not posted for events. /// @@ -77,7 +77,7 @@ public: /// Returns the number of valid replies. private: - mutable IPAddress::Family _family; + mutable SocketAddress::Family _family; }; diff --git a/Net/include/Poco/Net/ICMPPacket.h b/Net/include/Poco/Net/ICMPPacket.h index 95f6d65a8..e8b3b5186 100644 --- a/Net/include/Poco/Net/ICMPPacket.h +++ b/Net/include/Poco/Net/ICMPPacket.h @@ -33,7 +33,7 @@ class Net_API ICMPPacket /// This class is the ICMP packet abstraction. { public: - ICMPPacket(IPAddress::Family family, int dataSize = 48); + ICMPPacket(SocketAddress::Family family, int dataSize = 48); /// Creates an ICMPPacket of specified family. ~ICMPPacket(); diff --git a/Net/include/Poco/Net/ICMPSocket.h b/Net/include/Poco/Net/ICMPSocket.h index b6253864c..3b98dd6e8 100644 --- a/Net/include/Poco/Net/ICMPSocket.h +++ b/Net/include/Poco/Net/ICMPSocket.h @@ -33,7 +33,7 @@ class Net_API ICMPSocket: public Socket /// ICMP client socket. { public: - ICMPSocket(IPAddress::Family family, int dataSize = 48, int ttl = 128, int timeout = 500000); + ICMPSocket(SocketAddress::Family family, int dataSize = 48, int ttl = 128, int timeout = 500000); /// Creates an unconnected ICMP socket. /// /// The socket will be created for the diff --git a/Net/include/Poco/Net/ICMPSocketImpl.h b/Net/include/Poco/Net/ICMPSocketImpl.h index c033e5af1..771c5a227 100644 --- a/Net/include/Poco/Net/ICMPSocketImpl.h +++ b/Net/include/Poco/Net/ICMPSocketImpl.h @@ -34,7 +34,7 @@ class Net_API ICMPSocketImpl: public RawSocketImpl /// This class implements an ICMP socket. { public: - ICMPSocketImpl(IPAddress::Family family, int dataSize, int ttl, int timeout); + ICMPSocketImpl(SocketAddress::Family family, int dataSize, int ttl, int timeout); /// Creates an unconnected ICMP socket. /// /// The socket will be created for the given address family. diff --git a/Net/include/Poco/Net/IPAddress.h b/Net/include/Poco/Net/IPAddress.h index 2ae11628a..fa6fe73f1 100644 --- a/Net/include/Poco/Net/IPAddress.h +++ b/Net/include/Poco/Net/IPAddress.h @@ -57,15 +57,15 @@ class Net_API IPAddress { public: typedef std::vector List; - - enum Family - /// Possible address families for IP addresses. - { - IPv4 = Poco::Net::Impl::IPAddressImpl::IPv4, -#ifdef POCO_HAVE_IPv6 - IPv6 = Poco::Net::Impl::IPAddressImpl::IPv6 + + // The following declarations keep the Family type + // backwards compatible with the previously used + // enum declaration. + typedef AddressFamily::Family Family; + static const Family IPv4 = AddressFamily::IPv4; +#if defined(POCO_HAVE_IPv6) + static const Family IPv6 = AddressFamily::IPv6; #endif - }; IPAddress(); /// Creates a wildcard (zero) IPv4 IPAddress. diff --git a/Net/include/Poco/Net/IPAddressImpl.h b/Net/include/Poco/Net/IPAddressImpl.h index 64587d2cf..d68049cee 100644 --- a/Net/include/Poco/Net/IPAddressImpl.h +++ b/Net/include/Poco/Net/IPAddressImpl.h @@ -39,14 +39,7 @@ class IPAddressImpl #endif { public: - enum Family - /// Possible address families for IP addresses. - { - IPv4, -#ifdef POCO_HAVE_IPv6 - IPv6 -#endif - }; + typedef AddressFamily::Family Family; virtual ~IPAddressImpl(); diff --git a/Net/include/Poco/Net/MulticastSocket.h b/Net/include/Poco/Net/MulticastSocket.h index b26801c64..88921c7a8 100644 --- a/Net/include/Poco/Net/MulticastSocket.h +++ b/Net/include/Poco/Net/MulticastSocket.h @@ -43,7 +43,7 @@ public: MulticastSocket(); /// Creates the MulticastSocket. - explicit MulticastSocket(IPAddress::Family family); + explicit MulticastSocket(SocketAddress::Family family); /// Creates an unconnected datagram socket. /// /// The socket will be created for the diff --git a/Net/include/Poco/Net/NTPClient.h b/Net/include/Poco/Net/NTPClient.h index b2967ff21..11c17c712 100644 --- a/Net/include/Poco/Net/NTPClient.h +++ b/Net/include/Poco/Net/NTPClient.h @@ -36,7 +36,7 @@ class Net_API NTPClient public: mutable Poco::BasicEvent response; - explicit NTPClient(IPAddress::Family family, int timeout = 3000000); + explicit NTPClient(SocketAddress::Family family, int timeout = 3000000); /// Creates an NTP client. ~NTPClient(); @@ -55,7 +55,7 @@ public: /// Returns the number of valid replies. private: - mutable IPAddress::Family _family; + mutable SocketAddress::Family _family; int _timeout; }; diff --git a/Net/include/Poco/Net/RawSocket.h b/Net/include/Poco/Net/RawSocket.h index f5e92765a..43efd7a95 100644 --- a/Net/include/Poco/Net/RawSocket.h +++ b/Net/include/Poco/Net/RawSocket.h @@ -36,7 +36,7 @@ public: RawSocket(); /// Creates an unconnected IPv4 raw socket. - RawSocket(IPAddress::Family family, int proto = IPPROTO_RAW); + RawSocket(SocketAddress::Family family, int proto = IPPROTO_RAW); /// Creates an unconnected raw socket. /// /// The socket will be created for the diff --git a/Net/include/Poco/Net/RawSocketImpl.h b/Net/include/Poco/Net/RawSocketImpl.h index 8bf056913..ab299e0d1 100644 --- a/Net/include/Poco/Net/RawSocketImpl.h +++ b/Net/include/Poco/Net/RawSocketImpl.h @@ -35,7 +35,7 @@ public: RawSocketImpl(); /// Creates an unconnected IPv4 raw socket with IPPROTO_RAW. - RawSocketImpl(IPAddress::Family family, int proto = IPPROTO_RAW); + RawSocketImpl(SocketAddress::Family family, int proto = IPPROTO_RAW); /// Creates an unconnected raw socket. /// /// The socket will be created for the diff --git a/Net/include/Poco/Net/SocketAddress.h b/Net/include/Poco/Net/SocketAddress.h index e47f091bc..f0dcea2e6 100644 --- a/Net/include/Poco/Net/SocketAddress.h +++ b/Net/include/Poco/Net/SocketAddress.h @@ -43,17 +43,17 @@ class Net_API SocketAddress /// host address and a port number. { public: - enum Family - /// Possible address families for socket addresses. - { - IPv4 = Poco::Net::Impl::SocketAddressImpl::IPv4, -#ifdef POCO_HAVE_IPv6 - IPv6 = Poco::Net::Impl::SocketAddressImpl::IPv6, + // The following declarations keep the Family type + // backwards compatible with the previously used + // enum declaration. + typedef AddressFamily::Family Family; + static const Family IPv4 = AddressFamily::IPv4; +#if defined(POCO_HAVE_IPv6) + static const Family IPv6 = AddressFamily::IPv6; #endif -#ifdef POCO_OS_FAMILY_UNIX - UNIX_LOCAL = Poco::Net::Impl::SocketAddressImpl::UNIX_LOCAL +#if defined(POCO_OS_FAMILY_UNIX) + static const Family UNIX_LOCAL = AddressFamily::UNIX_LOCAL; #endif - }; SocketAddress(); /// Creates a wildcard (all zero) IPv4 SocketAddress. @@ -316,16 +316,16 @@ inline bool SocketAddress::operator == (const SocketAddress& socketAddress) cons { #if defined(POCO_OS_FAMILY_UNIX) if (family() == UNIX_LOCAL) - return host() == socketAddress.host() && port() == socketAddress.port(); + return toString() == socketAddress.toString(); else #endif - return toString() == socketAddress.toString(); + return host() == socketAddress.host() && port() == socketAddress.port(); } inline bool SocketAddress::operator != (const SocketAddress& socketAddress) const { - return !operator == (socketAddress); + return !(operator == (socketAddress)); } diff --git a/Net/include/Poco/Net/SocketAddressImpl.h b/Net/include/Poco/Net/SocketAddressImpl.h index 01a52eb22..11253003b 100644 --- a/Net/include/Poco/Net/SocketAddressImpl.h +++ b/Net/include/Poco/Net/SocketAddressImpl.h @@ -27,6 +27,7 @@ #include "Poco/RefCountedObject.h" #endif + namespace Poco { namespace Net { namespace Impl { @@ -38,17 +39,7 @@ class Net_API SocketAddressImpl #endif { public: - enum Family - /// Possible address families for socket addresses. - { - IPv4, -#ifdef POCO_HAVE_IPv6 - IPv6, -#endif -#ifdef POCO_OS_FAMILY_UNIX - UNIX_LOCAL -#endif - }; + typedef AddressFamily::Family Family; virtual ~SocketAddressImpl(); @@ -124,7 +115,7 @@ inline int IPv4SocketAddressImpl::af() const inline SocketAddressImpl::Family IPv4SocketAddressImpl::family() const { - return SocketAddressImpl::IPv4; + return AddressFamily::IPv4; } @@ -186,7 +177,7 @@ inline int IPv6SocketAddressImpl::af() const inline SocketAddressImpl::Family IPv6SocketAddressImpl::family() const { - return SocketAddressImpl::IPv6; + return AddressFamily::IPv6; } @@ -254,7 +245,7 @@ inline int LocalSocketAddressImpl::af() const inline SocketAddressImpl::Family LocalSocketAddressImpl::family() const { - return SocketAddressImpl::UNIX_LOCAL; + return AddressFamily::UNIX_LOCAL; } diff --git a/Net/include/Poco/Net/SocketDefs.h b/Net/include/Poco/Net/SocketDefs.h index ccc91fa16..635fb2f9b 100644 --- a/Net/include/Poco/Net/SocketDefs.h +++ b/Net/include/Poco/Net/SocketDefs.h @@ -353,4 +353,32 @@ #endif +namespace Poco { +namespace Net { + + +struct AddressFamily + /// AddressFamily::Family replaces the previously used IPAddress::Family + /// enumeration and is now used for IPAddress::Family and SocketAddress::Family. +{ + enum Family + /// Possible address families for socket addresses. + { + IPv4, + /// IPv4 address family. + #if defined(POCO_HAVE_IPv6) + IPv6, + /// IPv6 address family. + #endif + #if defined(POCO_OS_FAMILY_UNIX) + UNIX_LOCAL + /// UNIX domain socket address family. Available on UNIX/POSIX platforms only. + #endif + }; +}; + + +} } // namespace Poco::Net + + #endif // Net_SocketDefs_INCLUDED diff --git a/Net/include/Poco/Net/StreamSocket.h b/Net/include/Poco/Net/StreamSocket.h index 302fb58bc..038e6b361 100644 --- a/Net/include/Poco/Net/StreamSocket.h +++ b/Net/include/Poco/Net/StreamSocket.h @@ -47,7 +47,7 @@ public: /// Creates a stream socket and connects it to /// the socket specified by address. - explicit StreamSocket(IPAddress::Family family); + explicit StreamSocket(SocketAddress::Family family); /// Creates an unconnected stream socket /// for the given address family. /// diff --git a/Net/include/Poco/Net/StreamSocketImpl.h b/Net/include/Poco/Net/StreamSocketImpl.h index ee91283a9..bfb588de4 100644 --- a/Net/include/Poco/Net/StreamSocketImpl.h +++ b/Net/include/Poco/Net/StreamSocketImpl.h @@ -35,7 +35,7 @@ public: StreamSocketImpl(); /// Creates a StreamSocketImpl. - explicit StreamSocketImpl(IPAddress::Family addressFamily); + explicit StreamSocketImpl(SocketAddress::Family addressFamily); /// Creates a SocketImpl, with the underlying /// socket initialized for the given address family. diff --git a/Net/src/DatagramSocket.cpp b/Net/src/DatagramSocket.cpp index a2089ab7e..ce5d6b7ee 100644 --- a/Net/src/DatagramSocket.cpp +++ b/Net/src/DatagramSocket.cpp @@ -31,7 +31,7 @@ DatagramSocket::DatagramSocket(): Socket(new DatagramSocketImpl) } -DatagramSocket::DatagramSocket(IPAddress::Family family): Socket(new DatagramSocketImpl(family)) +DatagramSocket::DatagramSocket(SocketAddress::Family family): Socket(new DatagramSocketImpl(family)) { } diff --git a/Net/src/DatagramSocketImpl.cpp b/Net/src/DatagramSocketImpl.cpp index 1b31b80d3..ef2b50881 100644 --- a/Net/src/DatagramSocketImpl.cpp +++ b/Net/src/DatagramSocketImpl.cpp @@ -31,13 +31,17 @@ DatagramSocketImpl::DatagramSocketImpl() } -DatagramSocketImpl::DatagramSocketImpl(IPAddress::Family family) +DatagramSocketImpl::DatagramSocketImpl(SocketAddress::Family family) { - if (family == IPAddress::IPv4) + if (family == SocketAddress::IPv4) init(AF_INET); #if defined(POCO_HAVE_IPv6) - else if (family == IPAddress::IPv6) + else if (family == SocketAddress::IPv6) init(AF_INET6); +#endif +#if defined(POCO_OS_FAMILY_UNIX) + else if (family == SocketAddress::UNIX_LOCAL) + init(AF_UNIX); #endif else throw InvalidArgumentException("Invalid or unsupported address family passed to DatagramSocketImpl"); } diff --git a/Net/src/ICMPClient.cpp b/Net/src/ICMPClient.cpp index a4b66bf10..d3a164f0e 100644 --- a/Net/src/ICMPClient.cpp +++ b/Net/src/ICMPClient.cpp @@ -36,7 +36,7 @@ namespace Poco { namespace Net { -ICMPClient::ICMPClient(IPAddress::Family family): +ICMPClient::ICMPClient(SocketAddress::Family family): _family(family) { } diff --git a/Net/src/IPAddress.cpp b/Net/src/IPAddress.cpp index 326fbbe9b..e3d0039a5 100644 --- a/Net/src/IPAddress.cpp +++ b/Net/src/IPAddress.cpp @@ -42,6 +42,12 @@ namespace Poco { namespace Net { +const IPAddress::Family IPAddress::IPv4; +#if defined(POCO_HAVE_IPv6) +const IPAddress::Family IPAddress::IPv6; +#endif + + IPAddress::IPAddress() { newIPv4(); diff --git a/Net/src/IPAddressImpl.cpp b/Net/src/IPAddressImpl.cpp index 5097bbb5d..dd20bd052 100644 --- a/Net/src/IPAddressImpl.cpp +++ b/Net/src/IPAddressImpl.cpp @@ -145,7 +145,7 @@ const void* IPv4AddressImpl::addr() const IPAddressImpl::Family IPv4AddressImpl::family() const { - return IPAddressImpl::IPv4; + return AddressFamily::IPv4; } @@ -499,7 +499,7 @@ const void* IPv6AddressImpl::addr() const IPAddressImpl::Family IPv6AddressImpl::family() const { - return IPAddressImpl::IPv6; + return AddressFamily::IPv6; } @@ -534,6 +534,8 @@ unsigned IPv6AddressImpl::prefixLength() const throw NotImplementedException("prefixLength() not implemented"); #endif } + + Poco::UInt32 IPv6AddressImpl::scope() const { return _scope; diff --git a/Net/src/MulticastSocket.cpp b/Net/src/MulticastSocket.cpp index e14f8ffb4..5dcd9a8e8 100644 --- a/Net/src/MulticastSocket.cpp +++ b/Net/src/MulticastSocket.cpp @@ -53,8 +53,12 @@ MulticastSocket::MulticastSocket() } -MulticastSocket::MulticastSocket(IPAddress::Family family): DatagramSocket(family) +MulticastSocket::MulticastSocket(SocketAddress::Family family): DatagramSocket(family) { +#if defined(POCO_OS_FAMILY_UNIX) + if (family == SocketAddress::UNIX_LOCAL) + throw Poco::InvalidArgumentException("Cannot create a MulticastSocket with UNIX_LOCAL socket"); +#endif } @@ -92,8 +96,7 @@ void MulticastSocket::setInterface(const NetworkInterface& interfc) impl()->setOption(IPPROTO_IPV6, IPV6_MULTICAST_IF, interfc.index()); } #endif - else - throw UnsupportedFamilyException("Unknown or unsupported socket family."); + else throw UnsupportedFamilyException("Unknown or unsupported socket family."); } diff --git a/Net/src/RawSocket.cpp b/Net/src/RawSocket.cpp index 3506a814d..2f35c3027 100644 --- a/Net/src/RawSocket.cpp +++ b/Net/src/RawSocket.cpp @@ -32,7 +32,7 @@ RawSocket::RawSocket(): } -RawSocket::RawSocket(IPAddress::Family family, int proto): +RawSocket::RawSocket(SocketAddress::Family family, int proto): Socket(new RawSocketImpl(family, proto)) { } diff --git a/Net/src/RawSocketImpl.cpp b/Net/src/RawSocketImpl.cpp index e06942f69..0377a08c1 100644 --- a/Net/src/RawSocketImpl.cpp +++ b/Net/src/RawSocketImpl.cpp @@ -31,12 +31,12 @@ RawSocketImpl::RawSocketImpl() } -RawSocketImpl::RawSocketImpl(IPAddress::Family family, int proto) +RawSocketImpl::RawSocketImpl(SocketAddress::Family family, int proto) { - if (family == IPAddress::IPv4) + if (family == SocketAddress::IPv4) init2(AF_INET, proto); #if defined(POCO_HAVE_IPv6) - else if (family == IPAddress::IPv6) + else if (family == SocketAddress::IPv6) init2(AF_INET6, proto); #endif else throw InvalidArgumentException("Invalid or unsupported address family passed to RawSocketImpl"); diff --git a/Net/src/SocketAddress.cpp b/Net/src/SocketAddress.cpp index 2b9bf26d8..324dfa9b5 100644 --- a/Net/src/SocketAddress.cpp +++ b/Net/src/SocketAddress.cpp @@ -58,6 +58,15 @@ struct AFLT // +const SocketAddress::Family SocketAddress::IPv4; +#if defined(POCO_HAVE_IPv6) +const SocketAddress::Family SocketAddress::IPv6; +#endif +#if defined(POCO_OS_FAMILY_UNIX) +const SocketAddress::Family SocketAddress::UNIX_LOCAL; +#endif + + SocketAddress::SocketAddress() { newIPv4(); @@ -117,17 +126,17 @@ SocketAddress::SocketAddress(const SocketAddress& socketAddress) SocketAddress::SocketAddress(const struct sockaddr* sockAddr, poco_socklen_t length) { - if (length == sizeof(struct sockaddr_in)) + if (length == sizeof(struct sockaddr_in) && sockAddr->sa_family == AF_INET) newIPv4(reinterpret_cast(sockAddr)); #if defined(POCO_HAVE_IPv6) - else if (length == sizeof(struct sockaddr_in6)) + else if (length == sizeof(struct sockaddr_in6) && sockAddr->sa_family == AF_INET6) newIPv6(reinterpret_cast(sockAddr)); #endif #if defined(POCO_OS_FAMILY_UNIX) else if (length > 0 && length <= sizeof(struct sockaddr_un) && sockAddr->sa_family == AF_UNIX) newLocal(reinterpret_cast(sockAddr)); #endif - else throw Poco::InvalidArgumentException("Invalid address length passed to SocketAddress()"); + else throw Poco::InvalidArgumentException("Invalid address length or family passed to SocketAddress()"); } @@ -263,6 +272,8 @@ void SocketAddress::init(Family family, const std::string& address) void SocketAddress::init(const std::string& hostAndPort) { + poco_assert (!hostAndPort.empty()); + std::string host; std::string port; std::string::const_iterator it = hostAndPort.begin(); @@ -332,7 +343,7 @@ Poco::BinaryReader& operator >> (Poco::BinaryReader& reader, Poco::Net::SocketAd } -inline std::ostream& operator << (std::ostream& ostr, const Poco::Net::SocketAddress& address) +std::ostream& operator << (std::ostream& ostr, const Poco::Net::SocketAddress& address) { ostr << address.toString(); return ostr; diff --git a/Net/src/SocketAddressImpl.cpp b/Net/src/SocketAddressImpl.cpp index 9cb60bb06..02715af8b 100644 --- a/Net/src/SocketAddressImpl.cpp +++ b/Net/src/SocketAddressImpl.cpp @@ -63,6 +63,7 @@ IPv4SocketAddressImpl::IPv4SocketAddressImpl(const void* addr, UInt16 port) { std::memset(&_addr, 0, sizeof(_addr)); _addr.sin_family = AF_INET; + poco_set_sin_len(&_addr); std::memcpy(&_addr.sin_addr, addr, sizeof(_addr.sin_addr)); _addr.sin_port = port; } @@ -73,7 +74,7 @@ std::string IPv4SocketAddressImpl::toString() const std::string result; result.append(host().toString()); result.append(":"); - NumberFormatter::append(result, port()); + NumberFormatter::append(result, ntohs(port())); return result; } @@ -120,7 +121,7 @@ std::string IPv6SocketAddressImpl::toString() const result.append(host().toString()); result.append("]"); result.append(":"); - NumberFormatter::append(result, port()); + NumberFormatter::append(result, ntohs(port())); return result; } diff --git a/Net/src/StreamSocket.cpp b/Net/src/StreamSocket.cpp index 8ff4b3921..ba35a9aff 100644 --- a/Net/src/StreamSocket.cpp +++ b/Net/src/StreamSocket.cpp @@ -41,7 +41,7 @@ StreamSocket::StreamSocket(const SocketAddress& address): Socket(new StreamSocke } -StreamSocket::StreamSocket(IPAddress::Family family): Socket(new StreamSocketImpl(family)) +StreamSocket::StreamSocket(SocketAddress::Family family): Socket(new StreamSocketImpl(family)) { } diff --git a/Net/src/StreamSocketImpl.cpp b/Net/src/StreamSocketImpl.cpp index 94e683cb3..06b736fa7 100644 --- a/Net/src/StreamSocketImpl.cpp +++ b/Net/src/StreamSocketImpl.cpp @@ -28,13 +28,17 @@ StreamSocketImpl::StreamSocketImpl() } -StreamSocketImpl::StreamSocketImpl(IPAddress::Family family) +StreamSocketImpl::StreamSocketImpl(SocketAddress::Family family) { - if (family == IPAddress::IPv4) + if (family == SocketAddress::IPv4) init(AF_INET); #if defined(POCO_HAVE_IPv6) - else if (family == IPAddress::IPv6) + else if (family == SocketAddress::IPv6) init(AF_INET6); +#endif +#if defined(POCO_OS_FAMILY_UNIX) + else if (family == SocketAddress::UNIX_LOCAL) + init(AF_UNIX); #endif else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to StreamSocketImpl"); } diff --git a/Net/testsuite/src/SocketAddressTest.cpp b/Net/testsuite/src/SocketAddressTest.cpp index bd1b22843..e174c15f4 100644 --- a/Net/testsuite/src/SocketAddressTest.cpp +++ b/Net/testsuite/src/SocketAddressTest.cpp @@ -43,8 +43,11 @@ void SocketAddressTest::testSocketAddress() assert (wild.port() == 0); SocketAddress sa1("192.168.1.100", 100); + assert (sa1.af() == AF_INET); + assert (sa1.family() == SocketAddress::IPv4); assert (sa1.host().toString() == "192.168.1.100"); assert (sa1.port() == 100); + assert (sa1.toString() == "192.168.1.100:100"); SocketAddress sa2("192.168.1.100", "100"); assert (sa2.host().toString() == "192.168.1.100"); @@ -135,6 +138,38 @@ void SocketAddressTest::testSocketRelationals() void SocketAddressTest::testSocketAddress6() { #ifdef POCO_HAVE_IPv6 + SocketAddress sa1("FE80::E6CE:8FFF:FE4A:EDD0", 100); + assert (sa1.af() == AF_INET6); + assert (sa1.family() == SocketAddress::IPv6); + assert (sa1.host().toString() == "fe80::e6ce:8fff:fe4a:edd0"); + assert (sa1.port() == 100); + assert (sa1.toString() == "[fe80::e6ce:8fff:fe4a:edd0]:100"); + + SocketAddress sa2("[FE80::E6CE:8FFF:FE4A:EDD0]:100"); + assert (sa2.af() == AF_INET6); + assert (sa2.family() == SocketAddress::IPv6); + assert (sa2.host().toString() == "fe80::e6ce:8fff:fe4a:edd0"); + assert (sa2.port() == 100); + assert (sa2.toString() == "[fe80::e6ce:8fff:fe4a:edd0]:100"); +#endif +} + + +void SocketAddressTest::testSocketAddressUnixLocal() +{ +#ifdef POCO_OS_FAMILY_UNIX + SocketAddress sa1(SocketAddress::UNIX_LOCAL, "/tmp/sock1"); + assert (sa1.af() == AF_UNIX); + assert (sa1.family() == SocketAddress::UNIX_LOCAL); + assert (sa1.toString() == "/tmp/sock1"); + + SocketAddress sa2(SocketAddress::UNIX_LOCAL, "/tmp/sock2"); + assert (sa1 != sa2); + assert (sa1 < sa2); + + SocketAddress sa3(SocketAddress::UNIX_LOCAL, "/tmp/sock1"); + assert (sa1 == sa3); + assert (!(sa1 < sa3)); #endif } @@ -156,6 +191,7 @@ CppUnit::Test* SocketAddressTest::suite() CppUnit_addTest(pSuite, SocketAddressTest, testSocketAddress); CppUnit_addTest(pSuite, SocketAddressTest, testSocketRelationals); CppUnit_addTest(pSuite, SocketAddressTest, testSocketAddress6); + CppUnit_addTest(pSuite, SocketAddressTest, testSocketAddressUnixLocal); return pSuite; } diff --git a/Net/testsuite/src/SocketAddressTest.h b/Net/testsuite/src/SocketAddressTest.h index 75cbe67b7..2faa081c5 100644 --- a/Net/testsuite/src/SocketAddressTest.h +++ b/Net/testsuite/src/SocketAddressTest.h @@ -29,6 +29,7 @@ public: void testSocketAddress(); void testSocketRelationals(); void testSocketAddress6(); + void testSocketAddressUnixLocal(); void setUp(); void tearDown(); From d55eab926418a6a870c2a64c200acd9fc95a1a3d Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 15:00:43 +0200 Subject: [PATCH 28/38] clean build with POCO_NET_NO_IPv6, add test for Unix domain sockets --- Net/include/Poco/Net/IPAddress.h | 88 +++++++++++++++------------- Net/include/Poco/Net/IPAddressImpl.h | 6 ++ Net/include/Poco/Net/SocketAddress.h | 4 +- Net/src/IPAddress.cpp | 15 +++-- Net/src/ServerSocket.cpp | 4 ++ Net/testsuite/src/EchoServer.cpp | 10 ++++ Net/testsuite/src/EchoServer.h | 3 + Net/testsuite/src/SocketTest.cpp | 24 ++++++++ Net/testsuite/src/SocketTest.h | 1 + 9 files changed, 108 insertions(+), 47 deletions(-) diff --git a/Net/include/Poco/Net/IPAddress.h b/Net/include/Poco/Net/IPAddress.h index fa6fe73f1..a8ae5e672 100644 --- a/Net/include/Poco/Net/IPAddress.h +++ b/Net/include/Poco/Net/IPAddress.h @@ -374,21 +374,15 @@ private: #endif Ptr pImpl() const; - - void newIPv4(const void* hostAddr); - - void newIPv6(const void* hostAddr); - - void newIPv6(const void* hostAddr, Poco::UInt32 scope); - - void newIPv4(unsigned prefix); - - void newIPv6(unsigned prefix); - void newIPv4(); - + void newIPv4(const void* hostAddr); + void newIPv4(unsigned prefix); +#if defined(POCO_HAVE_IPv6) void newIPv6(); - + void newIPv6(const void* hostAddr); + void newIPv6(const void* hostAddr, Poco::UInt32 scope); + void newIPv6(unsigned prefix); +#endif void destruct(); #ifdef POCO_HAVE_ALIGNMENT @@ -405,7 +399,11 @@ private: AlignerType aligner; } #else // !POCO_ENABLE_CPP11 - AlignedCharArrayUnion + #if defined(POCO_HAVE_IPv6) + AlignedCharArrayUnion + #else + AlignedCharArrayUnion + #endif #endif // POCO_ENABLE_CPP11 _memory; #else // !POCO_HAVE_ALIGNMENT @@ -438,6 +436,16 @@ inline IPAddress::Ptr IPAddress::pImpl() const } +inline void IPAddress::newIPv4() +{ +#ifdef POCO_HAVE_ALIGNMENT + new (storage()) Poco::Net::Impl::IPv4AddressImpl; +#else + _pImpl = new Poco::Net::Impl::IPv4AddressImpl; +#endif +} + + inline void IPAddress::newIPv4(const void* hostAddr) { #ifdef POCO_HAVE_ALIGNMENT @@ -448,6 +456,29 @@ inline void IPAddress::newIPv4(const void* hostAddr) } +inline void IPAddress::newIPv4(unsigned prefix) +{ +#ifdef POCO_HAVE_ALIGNMENT + new (storage()) Poco::Net::Impl::IPv4AddressImpl(prefix); +#else + _pImpl = new Poco::Net::Impl::IPv4AddressImpl(prefix); +#endif +} + + +#if defined(POCO_HAVE_IPv6) + + +inline void IPAddress::newIPv6() +{ +#ifdef POCO_HAVE_ALIGNMENT + new (storage()) Poco::Net::Impl::IPv6AddressImpl; +#else + _pImpl = new Poco::Net::Impl::IPv6AddressImpl; +#endif +} + + inline void IPAddress::newIPv6(const void* hostAddr) { #ifdef POCO_HAVE_ALIGNMENT @@ -468,16 +499,6 @@ inline void IPAddress::newIPv6(const void* hostAddr, Poco::UInt32 scope) } -inline void IPAddress::newIPv4(unsigned prefix) -{ -#ifdef POCO_HAVE_ALIGNMENT - new (storage()) Poco::Net::Impl::IPv4AddressImpl(prefix); -#else - _pImpl = new Poco::Net::Impl::IPv4AddressImpl(prefix); -#endif -} - - inline void IPAddress::newIPv6(unsigned prefix) { #ifdef POCO_HAVE_ALIGNMENT @@ -488,24 +509,7 @@ inline void IPAddress::newIPv6(unsigned prefix) } -inline void IPAddress::newIPv4() -{ -#ifdef POCO_HAVE_ALIGNMENT - new (storage()) Poco::Net::Impl::IPv4AddressImpl; -#else - _pImpl = new Poco::Net::Impl::IPv4AddressImpl; -#endif -} - - -inline void IPAddress::newIPv6() -{ -#ifdef POCO_HAVE_ALIGNMENT - new (storage()) Poco::Net::Impl::IPv6AddressImpl; -#else - _pImpl = new Poco::Net::Impl::IPv6AddressImpl; -#endif -} +#endif // POCO_HAVE_IPv6 #ifdef POCO_HAVE_ALIGNMENT diff --git a/Net/include/Poco/Net/IPAddressImpl.h b/Net/include/Poco/Net/IPAddressImpl.h index d68049cee..4be1e20cb 100644 --- a/Net/include/Poco/Net/IPAddressImpl.h +++ b/Net/include/Poco/Net/IPAddressImpl.h @@ -124,6 +124,9 @@ private: }; +#if defined(POCO_HAVE_IPv6) + + // // IPv6AddressImpl // @@ -174,6 +177,9 @@ private: }; +#endif // POCO_HAVE_IPv6 + + } } } // namespace Poco::Net::Impl diff --git a/Net/include/Poco/Net/SocketAddress.h b/Net/include/Poco/Net/SocketAddress.h index f0dcea2e6..164742d8b 100644 --- a/Net/include/Poco/Net/SocketAddress.h +++ b/Net/include/Poco/Net/SocketAddress.h @@ -139,7 +139,9 @@ public: enum { MAX_ADDRESS_LENGTH = -#if defined(POCO_HAVE_IPv6) +#if defined(POCO_OS_FAMILY_UNIX) + sizeof(struct sockaddr_un) +#elif defined(POCO_HAVE_IPv6) sizeof(struct sockaddr_in6) #else sizeof(struct sockaddr_in) diff --git a/Net/src/IPAddress.cpp b/Net/src/IPAddress.cpp index e3d0039a5..1f7b7945d 100644 --- a/Net/src/IPAddress.cpp +++ b/Net/src/IPAddress.cpp @@ -35,7 +35,9 @@ using Poco::UInt16; using Poco::UInt32; using Poco::Net::Impl::IPAddressImpl; using Poco::Net::Impl::IPv4AddressImpl; +#if defined(POCO_HAVE_IPv6) using Poco::Net::Impl::IPv6AddressImpl; +#endif namespace Poco { @@ -58,8 +60,10 @@ IPAddress::IPAddress(const IPAddress& addr) { if (addr.family() == IPv4) newIPv4(addr.addr()); +#if defined(POCO_HAVE_IPv6) else newIPv6(addr.addr(), addr.scope()); +#endif } @@ -71,8 +75,7 @@ IPAddress::IPAddress(Family family) else if (family == IPv6) newIPv6(); #endif - else - throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()"); + else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()"); } @@ -227,8 +230,12 @@ IPAddress& IPAddress::operator = (const IPAddress& addr) destruct(); if (addr.family() == IPAddress::IPv4) newIPv4(addr.addr()); - else +#if defined(POCO_HAVE_IPv6) + else if (addr.family() == IPAddress::IPv6) newIPv6(addr.addr(), addr.scope()); +#endif + else + throw Poco::InvalidArgumentException("Invalid or unsupported address family"); } return *this; } @@ -236,7 +243,7 @@ IPAddress& IPAddress::operator = (const IPAddress& addr) IPAddress::Family IPAddress::family() const { - return static_cast(pImpl()->family()); + return pImpl()->family(); } diff --git a/Net/src/ServerSocket.cpp b/Net/src/ServerSocket.cpp index 99e52b95f..d52e5977a 100644 --- a/Net/src/ServerSocket.cpp +++ b/Net/src/ServerSocket.cpp @@ -96,9 +96,13 @@ void ServerSocket::bind6(const SocketAddress& address, bool reuseAddress, bool i void ServerSocket::bind6(Poco::UInt16 port, bool reuseAddress, bool ipV6Only) { +#if defined(POCO_HAVE_IPv6) IPAddress wildcardAddr(IPAddress::IPv6); SocketAddress address(wildcardAddr, port); impl()->bind6(address, reuseAddress, ipV6Only); +#else + throw Poco::NotImplementedException("No IPv6 support available"); +#endif // POCO_HAVE_IPv6 } diff --git a/Net/testsuite/src/EchoServer.cpp b/Net/testsuite/src/EchoServer.cpp index 712acd8ff..c97f97d24 100644 --- a/Net/testsuite/src/EchoServer.cpp +++ b/Net/testsuite/src/EchoServer.cpp @@ -32,6 +32,16 @@ EchoServer::EchoServer(): } +EchoServer::EchoServer(const Poco::Net::SocketAddress& address): + _socket(address), + _thread("EchoServer"), + _stop(false) +{ + _thread.start(*this); + _ready.wait(); +} + + EchoServer::~EchoServer() { _stop = true; diff --git a/Net/testsuite/src/EchoServer.h b/Net/testsuite/src/EchoServer.h index ccab60ff1..5dfe3ec9d 100644 --- a/Net/testsuite/src/EchoServer.h +++ b/Net/testsuite/src/EchoServer.h @@ -29,6 +29,9 @@ public: EchoServer(); /// Creates the EchoServer. + EchoServer(const Poco::Net::SocketAddress& address); + /// Creates the EchoServer using the given address. + ~EchoServer(); /// Destroys the EchoServer. diff --git a/Net/testsuite/src/SocketTest.cpp b/Net/testsuite/src/SocketTest.cpp index 6f6780ea8..4c8603c15 100644 --- a/Net/testsuite/src/SocketTest.cpp +++ b/Net/testsuite/src/SocketTest.cpp @@ -23,6 +23,7 @@ #include "Poco/Buffer.h" #include "Poco/FIFOBuffer.h" #include "Poco/Delegate.h" +#include "Poco/File.h" #include @@ -501,6 +502,28 @@ void SocketTest::testSelect3() } +void SocketTest::testEchoUnixLocal() +{ +#if defined(POCO_OS_FAMILY_UNIX) + Poco::File socketFile("/tmp/SocketTest.sock"); + if (socketFile.exists()) socketFile.remove(); + SocketAddress localAddr(SocketAddress::UNIX_LOCAL, socketFile.path()); + EchoServer echoServer(localAddr); + StreamSocket ss(SocketAddress::UNIX_LOCAL); + ss.connect(localAddr); + int n = ss.sendBytes("hello", 5); + assert (n == 5); + char buffer[256]; + n = ss.receiveBytes(buffer, sizeof(buffer)); + assert (n == 5); + assert (std::string(buffer, n) == "hello"); + ss.close(); + socketFile.remove(); +#endif +} + + + void SocketTest::onReadable(bool& b) { if (b) ++_notToReadable; @@ -549,6 +572,7 @@ CppUnit::Test* SocketTest::suite() CppUnit_addTest(pSuite, SocketTest, testSelect); CppUnit_addTest(pSuite, SocketTest, testSelect2); CppUnit_addTest(pSuite, SocketTest, testSelect3); + CppUnit_addTest(pSuite, SocketTest, testEchoUnixLocal); return pSuite; } diff --git a/Net/testsuite/src/SocketTest.h b/Net/testsuite/src/SocketTest.h index 5a8033ffa..0b29662c0 100644 --- a/Net/testsuite/src/SocketTest.h +++ b/Net/testsuite/src/SocketTest.h @@ -42,6 +42,7 @@ public: void testSelect(); void testSelect2(); void testSelect3(); + void testEchoUnixLocal(); void setUp(); void tearDown(); From 515de4128fc6d1762463c819ce9de8836ee262e0 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 16:21:25 +0200 Subject: [PATCH 29/38] handle ENOENT error --- Net/src/SocketImpl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Net/src/SocketImpl.cpp b/Net/src/SocketImpl.cpp index 5c33434f4..40bda76a2 100644 --- a/Net/src/SocketImpl.cpp +++ b/Net/src/SocketImpl.cpp @@ -1092,6 +1092,8 @@ void SocketImpl::error(int code, const std::string& arg) throw IOException("Broken pipe", code); case EBADF: throw IOException("Bad socket descriptor", code); + case ENOENT: + throw IOException("Not found", arg, code); #endif default: throw IOException(NumberFormatter::format(code), arg, code); From 0494abc60388e3a3f2d296e5501622c602aa7f3c Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 17:06:30 +0200 Subject: [PATCH 30/38] make TCPServer and HTTPClientSession work with UNIX local sockets --- Net/src/HTTPClientSession.cpp | 2 +- Net/src/TCPServer.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Net/src/HTTPClientSession.cpp b/Net/src/HTTPClientSession.cpp index b79424217..bf536c988 100644 --- a/Net/src/HTTPClientSession.cpp +++ b/Net/src/HTTPClientSession.cpp @@ -205,7 +205,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request) reconnect(); if (!keepAlive) request.setKeepAlive(false); - if (!request.has(HTTPRequest::HOST)) + if (!request.has(HTTPRequest::HOST) && !_host.empty()) request.setHost(_host, _port); if (!_proxyConfig.host.empty() && !bypassProxy()) { diff --git a/Net/src/TCPServer.cpp b/Net/src/TCPServer.cpp index 1619ca0ef..ca4bef5b3 100644 --- a/Net/src/TCPServer.cpp +++ b/Net/src/TCPServer.cpp @@ -120,8 +120,13 @@ void TCPServer::run() try { StreamSocket ss = _socket.acceptConnection(); - // enabe nodelay per default: OSX really needs that - ss.setNoDelay(true); + // enable nodelay per default: OSX really needs that +#if defined(POCO_OS_FAMILY_UNIX) + if (ss.address().family() != AddressFamily::UNIX_LOCAL) +#endif + { + ss.setNoDelay(true); + } _pDispatcher->enqueue(ss); } catch (Poco::Exception& exc) From d53dc367da45b7109736e99da97f2c91340bb32e Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 17:17:29 +0200 Subject: [PATCH 31/38] HTTPClientSession: don't attempt to reconnect if no host is set (such as when creating a HTTPClientSession with a connected StreamSocket) --- Net/src/HTTPClientSession.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Net/src/HTTPClientSession.cpp b/Net/src/HTTPClientSession.cpp index bf536c988..a68ec0528 100644 --- a/Net/src/HTTPClientSession.cpp +++ b/Net/src/HTTPClientSession.cpp @@ -194,7 +194,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request) _pResponseStream = 0; bool keepAlive = getKeepAlive(); - if ((connected() && !keepAlive) || mustReconnect()) + if (((connected() && !keepAlive) || mustReconnect()) && !_host.empty()) { close(); _mustReconnect = false; From 3eca77450c7c794ce109341676778419c96bdf10 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 17:36:28 +0200 Subject: [PATCH 32/38] fix version no, style --- Foundation/include/Poco/Platform.h | 1 - Foundation/include/Poco/Version.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Foundation/include/Poco/Platform.h b/Foundation/include/Poco/Platform.h index 7330b3797..def8f0733 100644 --- a/Foundation/include/Poco/Platform.h +++ b/Foundation/include/Poco/Platform.h @@ -160,7 +160,6 @@ #else #error "MIPS but neither MIPSEL nor MIPSEB?" #endif - #elif defined(__hppa) || defined(__hppa__) #define POCO_ARCH POCO_ARCH_HPPA #define POCO_ARCH_BIG_ENDIAN 1 diff --git a/Foundation/include/Poco/Version.h b/Foundation/include/Poco/Version.h index a3ab2e367..cf2ae97a5 100644 --- a/Foundation/include/Poco/Version.h +++ b/Foundation/include/Poco/Version.h @@ -37,7 +37,7 @@ // Ax: alpha releases // Bx: beta releases // -#define POCO_VERSION 0x01060000 +#define POCO_VERSION 0x01070000 #endif // Foundation_Version_INCLUDED From aac6aba66c75dc2010a8a11f21aaadbec2881f1c Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 8 Sep 2015 17:49:02 +0200 Subject: [PATCH 33/38] check if specified address fits specified address family --- Net/src/SocketAddress.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Net/src/SocketAddress.cpp b/Net/src/SocketAddress.cpp index 324dfa9b5..72520be09 100644 --- a/Net/src/SocketAddress.cpp +++ b/Net/src/SocketAddress.cpp @@ -257,15 +257,18 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber } -void SocketAddress::init(Family family, const std::string& address) +void SocketAddress::init(Family fam, const std::string& address) { - if (family == UNIX_LOCAL) +#if defined(POCO_OS_FAMILY_UNIX) + if (fam == UNIX_LOCAL) { newLocal(address); } else +#endif { init(address); + if (fam != family()) throw Poco::InvalidArgumentException("address does not fit family"); } } From 15f034cbbd30bc3c314a1df49b29547ab96bf2c4 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 9 Sep 2015 11:14:29 +0200 Subject: [PATCH 34/38] fix GH #931: make strToInt() more strict in what it accepts --- Foundation/include/Poco/NumericString.h | 18 +------- Foundation/testsuite/src/NumberParserTest.cpp | 42 +++++++------------ Foundation/testsuite/src/StringTest.h | 16 ------- 3 files changed, 17 insertions(+), 59 deletions(-) diff --git a/Foundation/include/Poco/NumericString.h b/Foundation/include/Poco/NumericString.h index a6bd35b39..48563f4c2 100644 --- a/Foundation/include/Poco/NumericString.h +++ b/Foundation/include/Poco/NumericString.h @@ -107,9 +107,6 @@ bool strToInt(const char* pStr, I& result, short base, char thSep = ',') { switch (*pStr) { - case 'x': case 'X': - if (base != 0x10) return false; - case '0': if (state < STATE_SIGNIFICANT_DIGITS) break; @@ -142,19 +139,12 @@ bool strToInt(const char* pStr, I& result, short base, char thSep = ',') case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': if (base != 0x10) return false; - if (state < STATE_SIGNIFICANT_DIGITS) state = STATE_SIGNIFICANT_DIGITS; if (result > limitCheck) return false; result = result * base + (10 + *pStr - 'A'); break; - case 'U': - case 'u': - case 'L': - case 'l': - goto done; - case '.': if ((base == 10) && (thSep == '.')) break; else return false; @@ -165,19 +155,13 @@ bool strToInt(const char* pStr, I& result, short base, char thSep = ',') case ' ': if ((base == 10) && (thSep == ' ')) break; - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - goto done; + // fallthrough default: return false; } } -done: if ((sign < 0) && (base == 10)) result *= sign; return true; diff --git a/Foundation/testsuite/src/NumberParserTest.cpp b/Foundation/testsuite/src/NumberParserTest.cpp index f810a519c..54a57a8e3 100644 --- a/Foundation/testsuite/src/NumberParserTest.cpp +++ b/Foundation/testsuite/src/NumberParserTest.cpp @@ -22,6 +22,7 @@ #include #include #include +#include using Poco::NumberParser; @@ -69,20 +70,11 @@ void NumberParserTest::testParse() assert(NumberParser::parse("-123") == -123); assert(NumberParser::parse("0") == 0); assert(NumberParser::parse("000") == 0); - assert(NumberParser::parse(" 123 ") == 123); - assert(NumberParser::parse(" 123") == 123); - assert(NumberParser::parse("123 ") == 123); assert(NumberParser::parse("0123") == 123); assert(NumberParser::parse("+0123") == 123); assert(NumberParser::parse("-0123") == -123); - assert(NumberParser::parse("-123") == -123); assert(NumberParser::parseUnsigned("123") == 123); assert(NumberParser::parseHex("12AB") == 0x12ab); - assert(NumberParser::parseHex("0X12AB") == 0x12ab); - assert(NumberParser::parseHex("0x12AB") == 0x12ab); - assert(NumberParser::parseHex("0x12aB") == 0x12ab); - assert(NumberParser::parseHex("0X98Fe") == 0x98fe); - assert(NumberParser::parseHex("0x0") == 0); assert(NumberParser::parseHex("00") == 0); assert(NumberParser::parseOct("123") == 0123); assert(NumberParser::parseOct("0123") == 0123); @@ -101,9 +93,9 @@ void NumberParserTest::testParse() assert(NumberParser::parse64("-123") == -123); assert(NumberParser::parse64("0123") == 123); assert(NumberParser::parse64("-0123") == -123); + assert(NumberParser::parse64("123456789123456789") == UINT64_C(123456789123456789)); assert(NumberParser::parseUnsigned64("123") == 123); assert(NumberParser::parseHex64("12AB") == 0x12ab); - assert(NumberParser::parseHex64("0x12AB") == 0x12ab); assert(NumberParser::parseOct64("123") == 0123); assert(NumberParser::parseOct64("0123") == 0123); #endif @@ -155,35 +147,26 @@ void NumberParserTest::testParse() assertEqualDelta(d, NumberParser::parseFloat(format("-1%c234e+100", dp), dp, ts), 0.01); assertEqualDelta(d, NumberParser::parseFloat(format("-1%c234E100", dp), dp, ts), 0.01); - d = 1.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" 1%c234e-100 ", dp), dp, ts), 0.01); - assertEqualDelta(d, NumberParser::parseFloat(format(" 1%c234e-100 ", dp), dp, ts), 0.01); - assertEqualDelta(d, NumberParser::parseFloat(format(" 1%c234e-100 ", dp), dp, ts), 0.01); - d = 1234.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" 1%c234%c234e-100 ", ts, dp), dp, ts), 0.01); + assertEqualDelta(d, NumberParser::parseFloat(format("1%c234%c234e-100", ts, dp), dp, ts), 0.01); d = 12345.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" 12%c345%c234e-100 ", ts, dp), dp, ts), 0.01); + assertEqualDelta(d, NumberParser::parseFloat(format("12%c345%c234e-100", ts, dp), dp, ts), 0.01); d = 123456.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" 123%c456%c234e-100 ", ts, dp), dp, ts), 0.01); + assertEqualDelta(d, NumberParser::parseFloat(format("123%c456%c234e-100", ts, dp), dp, ts), 0.01); d = -1234.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" -1%c234%c234e-100 ", ts, dp), dp, ts), 0.01); + assertEqualDelta(d, NumberParser::parseFloat(format("-1%c234%c234e-100", ts, dp), dp, ts), 0.01); d = -12345.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" -12%c345%c234e-100 ", ts, dp), dp, ts), 0.01); + assertEqualDelta(d, NumberParser::parseFloat(format("-12%c345%c234e-100", ts, dp), dp, ts), 0.01); d = -123456.234e-100; - assertEqualDelta(d, NumberParser::parseFloat(format(" -123%c456%c234e-100 ", ts, dp), dp, ts), 0.01); + assertEqualDelta(d, NumberParser::parseFloat(format("-123%c456%c234e-100", ts, dp), dp, ts), 0.01); } double d = 12.34e-10; assertEqualDelta(d, NumberParser::parseFloat(format("12%c34e-10", dp), dp, ts), 0.01); assertEqualDelta(-12.34, NumberParser::parseFloat(format("-12%c34", dp), dp, ts), 0.01); - assertEqualDelta(12.34, NumberParser::parseFloat(format(" 12%c34", dp),dp, ts), 0.01); - assertEqualDelta(12.34, NumberParser::parseFloat(format("12%c34 ", dp), dp, ts), 0.01); - assertEqualDelta(12.34, NumberParser::parseFloat(format(" 12%c34 ", dp), dp, ts), 0.01); - - assertEqualDelta(12.34, NumberParser::parseFloat(format("\t\n 12%c34 \v\f\r", dp), dp, ts), 0.01); + assertEqualDelta(12.34, NumberParser::parseFloat(format("12%c34", dp), dp, ts), 0.01); } } #endif // POCO_NO_FPENVIRONMENT @@ -232,6 +215,13 @@ void NumberParserTest::testParseError() failmsg("must throw SyntaxException"); } catch (SyntaxException&) { } + try + { + NumberParser::parse(" 123"); + NumberParser::parseBool(""); + failmsg("must throw SyntaxException"); + } catch (SyntaxException&) { } + try { NumberParser::parse("1 1"); diff --git a/Foundation/testsuite/src/StringTest.h b/Foundation/testsuite/src/StringTest.h index f24fea056..9974d930d 100644 --- a/Foundation/testsuite/src/StringTest.h +++ b/Foundation/testsuite/src/StringTest.h @@ -76,28 +76,12 @@ private: assert(Poco::strToInt("0", result, 10)); assert(result == 0); assert(Poco::strToInt("000", result, 10)); assert(result == 0); - if (123 < std::numeric_limits::max()) - { assert(Poco::strToInt(" 123 ", result, 10)); assert(result == 123); } - if (123 < std::numeric_limits::max()) - { assert(Poco::strToInt(" 123", result, 10)); assert(result == 123); } - if (123 < std::numeric_limits::max()) - { assert(Poco::strToInt("123 ", result, 10)); assert(result == 123); } if (std::numeric_limits::is_signed && (-123 > std::numeric_limits::min())) { assert(Poco::strToInt("-123", result, 10)); assert(result == -123); } if (0x123 < std::numeric_limits::max()) { assert(Poco::strToInt("123", result, 0x10)); assert(result == 0x123); } if (0x12ab < std::numeric_limits::max()) { assert(Poco::strToInt("12AB", result, 0x10)); assert(result == 0x12ab); } - if (0x12ab < std::numeric_limits::max()) - { assert(Poco::strToInt("0X12AB", result, 0x10)); assert(result == 0x12ab); } - if (0x12ab < std::numeric_limits::max()) - { assert(Poco::strToInt("0x12AB", result, 0x10)); assert(result == 0x12ab); } - if (0x12ab < std::numeric_limits::max()) - { assert(Poco::strToInt("0x12aB", result, 0x10)); assert(result == 0x12ab); } - if (0x98fe < std::numeric_limits::max()) - { assert(Poco::strToInt("0X98Fe", result, 0x10)); assert(result == 0x98fe); } - if (123 < std::numeric_limits::max()) - { assert(Poco::strToInt("0x0", result, 0x10)); assert(result == 0); } if (123 < std::numeric_limits::max()) { assert(Poco::strToInt("00", result, 0x10)); assert(result == 0); } if (0123 < std::numeric_limits::max()) From f315dc603e83c0ad645f0361fec136124865049a Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 9 Sep 2015 12:59:35 +0200 Subject: [PATCH 35/38] fix for pre-C++11 compilers --- Foundation/testsuite/src/NumberParserTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Foundation/testsuite/src/NumberParserTest.cpp b/Foundation/testsuite/src/NumberParserTest.cpp index 54a57a8e3..c31e2cf2f 100644 --- a/Foundation/testsuite/src/NumberParserTest.cpp +++ b/Foundation/testsuite/src/NumberParserTest.cpp @@ -93,7 +93,9 @@ void NumberParserTest::testParse() assert(NumberParser::parse64("-123") == -123); assert(NumberParser::parse64("0123") == 123); assert(NumberParser::parse64("-0123") == -123); +#if defined(POCO_ENABLE_CPP11) assert(NumberParser::parse64("123456789123456789") == UINT64_C(123456789123456789)); +#endif assert(NumberParser::parseUnsigned64("123") == 123); assert(NumberParser::parseHex64("12AB") == 0x12ab); assert(NumberParser::parseOct64("123") == 0123); From ea52ac5358d8106ba0b2d61b43e3cc7769ed702e Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 9 Sep 2015 13:30:14 +0200 Subject: [PATCH 36/38] do not use of UINT64_C --- Foundation/testsuite/src/NumberParserTest.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Foundation/testsuite/src/NumberParserTest.cpp b/Foundation/testsuite/src/NumberParserTest.cpp index c31e2cf2f..7e774ec4d 100644 --- a/Foundation/testsuite/src/NumberParserTest.cpp +++ b/Foundation/testsuite/src/NumberParserTest.cpp @@ -22,7 +22,6 @@ #include #include #include -#include using Poco::NumberParser; @@ -93,9 +92,6 @@ void NumberParserTest::testParse() assert(NumberParser::parse64("-123") == -123); assert(NumberParser::parse64("0123") == 123); assert(NumberParser::parse64("-0123") == -123); -#if defined(POCO_ENABLE_CPP11) - assert(NumberParser::parse64("123456789123456789") == UINT64_C(123456789123456789)); -#endif assert(NumberParser::parseUnsigned64("123") == 123); assert(NumberParser::parseHex64("12AB") == 0x12ab); assert(NumberParser::parseOct64("123") == 0123); From 7a6f54e0f04e92db6def9222b90910cb06a6e9fb Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 9 Sep 2015 14:26:26 +0200 Subject: [PATCH 37/38] fix for NumberParser changes --- JSON/src/Parser.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/JSON/src/Parser.cpp b/JSON/src/Parser.cpp index 469a46684..b96fc586e 100644 --- a/JSON/src/Parser.cpp +++ b/JSON/src/Parser.cpp @@ -19,11 +19,13 @@ #include "Poco/Ascii.h" #include "Poco/Token.h" #include "Poco/UTF8Encoding.h" +#include "Poco/String.h" #undef min #undef max #include #include #include +#include namespace Poco { @@ -407,9 +409,11 @@ void Parser::parseBuffer() case JSON_T_INTEGER: { #if defined(POCO_HAVE_INT64) + std::string numStr(_parseBuffer.begin(), _parseBuffer.size()); try { - Int64 value = NumberParser::parse64(std::string(_parseBuffer.begin(), _parseBuffer.size())); + Poco::trimInPlace(numStr); + Int64 value = NumberParser::parse64(numStr); // if number is 32-bit, then handle as such if (value > std::numeric_limits::max() || value < std::numeric_limits::min() ) @@ -424,7 +428,7 @@ void Parser::parseBuffer() // try to handle error as unsigned in case of overflow catch ( const SyntaxException& ) { - UInt64 value = NumberParser::parseUnsigned64(std::string(_parseBuffer.begin(), _parseBuffer.size())); + UInt64 value = NumberParser::parseUnsigned64(numStr); // if number is 32-bit, then handle as such if ( value > std::numeric_limits::max() ) { @@ -438,13 +442,13 @@ void Parser::parseBuffer() #else try { - int value = NumberParser::parse(std::string(_parseBuffer.begin(), _parseBuffer.size())); + int value = NumberParser::parse(numStr); _pHandler->value(value); } // try to handle error as unsigned in case of overflow catch ( const SyntaxException& ) { - unsigned value = NumberParser::parseUnsigned(std::string(_parseBuffer.begin(), _parseBuffer.size())); + unsigned value = NumberParser::parseUnsigned(numStr); _pHandler->value(value); } #endif From 622d9d4c6c4855fdde2fa199b81f085aa3c4d2ad Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 9 Sep 2015 14:38:08 +0200 Subject: [PATCH 38/38] NumberParser::parseHex[64](): allow 0x/0X prefix --- Foundation/src/NumberParser.cpp | 8 ++++++-- Foundation/testsuite/src/NumberParserTest.cpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Foundation/src/NumberParser.cpp b/Foundation/src/NumberParser.cpp index cf32ef2a6..ef5177f26 100644 --- a/Foundation/src/NumberParser.cpp +++ b/Foundation/src/NumberParser.cpp @@ -84,7 +84,9 @@ unsigned NumberParser::parseHex(const std::string& s) bool NumberParser::tryParseHex(const std::string& s, unsigned& value) { - return strToInt(s.c_str(), value, NUM_BASE_HEX); + int offset = 0; + if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2; + return strToInt(s.c_str() + offset, value, NUM_BASE_HEX); } @@ -151,7 +153,9 @@ UInt64 NumberParser::parseHex64(const std::string& s) bool NumberParser::tryParseHex64(const std::string& s, UInt64& value) { - return strToInt(s.c_str(), value, NUM_BASE_HEX); + int offset = 0; + if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2; + return strToInt(s.c_str() + offset, value, NUM_BASE_HEX); } diff --git a/Foundation/testsuite/src/NumberParserTest.cpp b/Foundation/testsuite/src/NumberParserTest.cpp index 7e774ec4d..cb656494b 100644 --- a/Foundation/testsuite/src/NumberParserTest.cpp +++ b/Foundation/testsuite/src/NumberParserTest.cpp @@ -74,6 +74,8 @@ void NumberParserTest::testParse() assert(NumberParser::parse("-0123") == -123); assert(NumberParser::parseUnsigned("123") == 123); assert(NumberParser::parseHex("12AB") == 0x12ab); + assert(NumberParser::parseHex("0x12AB") == 0x12ab); + assert(NumberParser::parseHex("0X12AB") == 0x12ab); assert(NumberParser::parseHex("00") == 0); assert(NumberParser::parseOct("123") == 0123); assert(NumberParser::parseOct("0123") == 0123);