From e803ff9a9e6e7a530f6ce766985ad50fe0e112a9 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Sat, 5 Aug 2017 08:36:58 +0200 Subject: [PATCH 1/4] Added clang to travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bf39ee..9665a6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ env: # - CXX_STANDARD=c++14 compiler: -# - clang - gcc + - clang before_install: - CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz" @@ -29,6 +29,6 @@ before_install: script: - mkdir build/cmake - cd build/cmake - - cmake -G "Unix Makefiles" ../.. + - cmake ../.. - make - ctest From eec16fec3850fa07279e50c49570c2ebd27e0846 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Sat, 5 Aug 2017 09:12:24 +0200 Subject: [PATCH 2/4] Fixed clang warnings --- src/libraries/xeumeuleu/bridges/xerces/detail/import.hpp | 2 +- .../xeumeuleu/bridges/xerces/detail/locator_handler.hpp | 4 ++++ src/libraries/xeumeuleu/streams/id.hpp | 2 +- src/tests/xeumeuleu_test/attribute_test.cpp | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libraries/xeumeuleu/bridges/xerces/detail/import.hpp b/src/libraries/xeumeuleu/bridges/xerces/detail/import.hpp index 225514b..ccf56cf 100644 --- a/src/libraries/xeumeuleu/bridges/xerces/detail/import.hpp +++ b/src/libraries/xeumeuleu/bridges/xerces/detail/import.hpp @@ -54,7 +54,7 @@ namespace detail XERCES_CPP_NAMESPACE::DOMNode& to ) { xerces_ptr< XERCES_CPP_NAMESPACE::DOMNode > child( document.importNode( const_cast< XERCES_CPP_NAMESPACE::DOMNode* >( &from ), false ) ); - *to.appendChild( child.get() ); + to.appendChild( child.get() ); return child.release(); } } diff --git a/src/libraries/xeumeuleu/bridges/xerces/detail/locator_handler.hpp b/src/libraries/xeumeuleu/bridges/xerces/detail/locator_handler.hpp index 56e6fed..ffdd58e 100644 --- a/src/libraries/xeumeuleu/bridges/xerces/detail/locator_handler.hpp +++ b/src/libraries/xeumeuleu/bridges/xerces/detail/locator_handler.hpp @@ -76,10 +76,14 @@ class locator_handler : public XERCES_CPP_NAMESPACE::DOMUserDataHandler break; case NODE_CLONED: case NODE_IMPORTED: + { const locator* l = static_cast< locator* >( src->getUserData( key ) ); delete static_cast< locator* >( dst->getUserData( key ) ); dst->setUserData( key, l ? new locator( *l ) : 0, this ); break; + } + default: + break; } } //@} diff --git a/src/libraries/xeumeuleu/streams/id.hpp b/src/libraries/xeumeuleu/streams/id.hpp index 6fa4e24..30db8c6 100644 --- a/src/libraries/xeumeuleu/streams/id.hpp +++ b/src/libraries/xeumeuleu/streams/id.hpp @@ -45,7 +45,7 @@ namespace xml */ // Created: MAT 2014-12-04 // ============================================================================= - class id +class id { public: //! @name Constructors/Destructor diff --git a/src/tests/xeumeuleu_test/attribute_test.cpp b/src/tests/xeumeuleu_test/attribute_test.cpp index 35cd388..ced71a5 100644 --- a/src/tests/xeumeuleu_test/attribute_test.cpp +++ b/src/tests/xeumeuleu_test/attribute_test.cpp @@ -324,7 +324,7 @@ BOOST_AUTO_TEST_CASE( writing_attribute_pointer_equal_to_nullptr_fallback_value_ BOOST_AUTO_TEST_CASE( writing_attribute_pointer_different_from_nullptr_fallback_value_writes_it ) { xml::xostringstream xos; - const user_type t; + const user_type t = user_type(); xos << xml::start( "root" ) << xml::attribute( "attribute", &t, nullptr ); const std::string expected = "\n" From 0fa44d8d6b70801548c3b3350b6c3ddfc4464e77 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Sat, 5 Aug 2017 21:19:54 +0200 Subject: [PATCH 3/4] Fixed clang compilation --- src/libraries/xeumeuleu/streams/xistringstream.hpp | 14 ++++++++++++-- src/libraries/xeumeuleu/streams/xofstream.hpp | 9 ++++++++- src/libraries/xeumeuleu/streams/xostreamstream.hpp | 9 ++++++++- src/libraries/xeumeuleu/streams/xostringstream.hpp | 7 ++++++- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/libraries/xeumeuleu/streams/xistringstream.hpp b/src/libraries/xeumeuleu/streams/xistringstream.hpp index 54e7254..2c171b1 100644 --- a/src/libraries/xeumeuleu/streams/xistringstream.hpp +++ b/src/libraries/xeumeuleu/streams/xistringstream.hpp @@ -60,12 +60,22 @@ class xistringstream : private document, public xistream public: //! @name Constructors/Destructor //@{ - xistringstream( const std::string& data, const grammar& grammar = null_grammar(), const id& id = id() ) + explicit xistringstream( const std::string& data, const grammar& grammar = null_grammar() ) + : document( data.c_str(), data.size(), 0, grammar, id() ) + , xistream( input_ ) + , input_( *document_ ) + {} + xistringstream( const std::string& data, const grammar& grammar, const id& id ) : document( data.c_str(), data.size(), 0, grammar, id ) , xistream( input_ ) , input_( *document_ ) {} - xistringstream( const std::string& data, const encoding& encoding, const grammar& grammar = null_grammar(), const id& id = id() ) + xistringstream( const std::string& data, const encoding& encoding, const grammar& grammar = null_grammar() ) + : document( data.c_str(), data.size(), &encoding, grammar, id() ) + , xistream( input_ ) + , input_( *document_ ) + {} + xistringstream( const std::string& data, const encoding& encoding, const grammar& grammar, const id& id ) : document( data.c_str(), data.size(), &encoding, grammar, id ) , xistream( input_ ) , input_( *document_ ) diff --git a/src/libraries/xeumeuleu/streams/xofstream.hpp b/src/libraries/xeumeuleu/streams/xofstream.hpp index 06aeb02..d4f244c 100644 --- a/src/libraries/xeumeuleu/streams/xofstream.hpp +++ b/src/libraries/xeumeuleu/streams/xofstream.hpp @@ -61,7 +61,14 @@ class xofstream : private document, private flushable, public xostream public: //! @name Constructors/Destructor //@{ - explicit xofstream( const std::string& filename, const encoding& encoding = encoding() ) + explicit xofstream( const std::string& filename ) + : xostream( output_ ) + , output_ ( *document_, *document_, *this ) + , filename_( filename ) + , encoding_( encoding() ) + , flushed_ ( false ) + {} + xofstream( const std::string& filename, const encoding& encoding ) : xostream( output_ ) , output_ ( *document_, *document_, *this ) , filename_( filename ) diff --git a/src/libraries/xeumeuleu/streams/xostreamstream.hpp b/src/libraries/xeumeuleu/streams/xostreamstream.hpp index 4afeb71..5315f8b 100644 --- a/src/libraries/xeumeuleu/streams/xostreamstream.hpp +++ b/src/libraries/xeumeuleu/streams/xostreamstream.hpp @@ -58,7 +58,14 @@ class xostreamstream : private document, private flushable, public xostream public: //! @name Constructors/Destructor //@{ - explicit xostreamstream( std::basic_ostream< char >& stream, const encoding& encoding = encoding() ) + explicit xostreamstream( std::basic_ostream< char >& stream ) + : xostream( output_ ) + , output_ ( *document_, *document_, *this ) + , stream_ ( stream ) + , encoding_( encoding() ) + , flushed_ ( false ) + {} + xostreamstream( std::basic_ostream< char >& stream, const encoding& encoding ) : xostream( output_ ) , output_ ( *document_, *document_, *this ) , stream_ ( stream ) diff --git a/src/libraries/xeumeuleu/streams/xostringstream.hpp b/src/libraries/xeumeuleu/streams/xostringstream.hpp index fdcbae4..2afa5d7 100644 --- a/src/libraries/xeumeuleu/streams/xostringstream.hpp +++ b/src/libraries/xeumeuleu/streams/xostringstream.hpp @@ -58,7 +58,12 @@ class xostringstream : private document, public xostream public: //! @name Constructors/Destructor //@{ - explicit xostringstream( const encoding& encoding = encoding() ) + xostringstream() + : xostream( output_ ) + , output_ ( *document_, *document_ ) + , encoding_( encoding() ) + {} + explicit xostringstream( const encoding& encoding ) : xostream( output_ ) , output_ ( *document_, *document_ ) , encoding_( encoding ) From a6950b920292cde09c8a141d0b52183ce236bad5 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Sun, 6 Aug 2017 08:58:10 +0200 Subject: [PATCH 4/4] Removed conversion operator to base class This was likely part of an attempt at allowing namespace { void f( xml::xostream& ) { } } BOOST_AUTO_TEST_CASE( temporary_output_sub_stream ) { xml::xostringstream xos; f( xml::xosubstream( xos ) ); } which seems error prone and not very C++-ish. --- src/libraries/xeumeuleu/streams/xisubstream.hpp | 8 -------- src/libraries/xeumeuleu/streams/xosubstream.hpp | 8 -------- 2 files changed, 16 deletions(-) diff --git a/src/libraries/xeumeuleu/streams/xisubstream.hpp b/src/libraries/xeumeuleu/streams/xisubstream.hpp index b470d27..a2b7173 100644 --- a/src/libraries/xeumeuleu/streams/xisubstream.hpp +++ b/src/libraries/xeumeuleu/streams/xisubstream.hpp @@ -76,14 +76,6 @@ class xisubstream : private xi_base_member, public xistream virtual ~xisubstream() {} //@} - - //! @name Operators - //@{ - operator xistream&() const - { - return const_cast< xisubstream& >( *this ); - } - //@} }; } diff --git a/src/libraries/xeumeuleu/streams/xosubstream.hpp b/src/libraries/xeumeuleu/streams/xosubstream.hpp index be55b3e..b9c3d1f 100644 --- a/src/libraries/xeumeuleu/streams/xosubstream.hpp +++ b/src/libraries/xeumeuleu/streams/xosubstream.hpp @@ -75,14 +75,6 @@ class xosubstream : private xo_base_member, public xostream {} //@} - //! @name Operators - //@{ - operator xostream&() const - { - return const_cast< xosubstream& >( *this ); - } - //@} - private: //! @name Operations //@{