Skip to content

Commit

Permalink
Merge pull request #23 from mat007/fix-ci
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
Mathieu Champlon authored Mar 18, 2018
2 parents 49adb93 + b698292 commit 354d32a
Show file tree
Hide file tree
Showing 22 changed files with 156 additions and 350 deletions.
26 changes: 10 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@ sudo: required
language: cpp

env:
- CXX_STANDARD=c++98
# - CXX_STANDARD=c++0x
# - CXX_STANDARD=c++11
# - CXX_STANDARD=c++14
- CXX_STANDARD=98
- CXX_STANDARD=11
- CXX_STANDARD=14
- CXX_STANDARD=17

compiler:
- gcc
- clang

before_install:
- CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz"
- mkdir cmake
- travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
- export PATH=${TRAVIS_BUILD_DIR}/cmake/bin:${PATH}
- cmake --version
- sudo apt-get -qq update
- sudo apt-get install libboost-all-dev
- sudo apt-get install libxerces-c-dev
- sudo apt-get install libxalan-c-dev
- sudo apt-get install cmake libboost-all-dev libxerces-c-dev libxalan-c-dev
- cmake --version
- travis_retry wget https://github.com/mat007/turtle/archive/master.zip
- unzip master.zip
- cp -r turtle-master/include/turtle src/libraries

script:
- mkdir build/cmake
- mkdir -p build/cmake
- cd build/cmake
- cmake ../..
- make
- ctest
- cmake ../.. -DCMAKE_CXX_STANDARD=${CXX_STANDARD}
- cmake --build .
- ctest --verbose
43 changes: 43 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
skip_branch_with_pr: true

environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
BOOST: 1_59_0
MSVC: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
BOOST: 1_64_0
MSVC: 15

platform:
- x86
- x64

configuration:
- Debug
- Release

cache: c:\tools\vcpkg\installed\

init:
- set BOOST_ROOT=C:\Libraries\boost_%BOOST%
- if "%PLATFORM%"=="x86" set BOOST_LIBRARYDIR=%BOOST_ROOT%\lib32-msvc-%MSVC%.0
- if "%PLATFORM%"=="x64" set BOOST_LIBRARYDIR=%BOOST_ROOT%\lib64-msvc-%MSVC%.0
- if "%PLATFORM%"=="x86" set CMAKE_GENERATOR_NAME=Visual Studio %MSVC%
- if "%PLATFORM%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio %MSVC% Win64
- if "%CONFIGURATION%"=="Release" set VCPKG_LIBRARYDIR=c:\tools\vcpkg\installed\%PLATFORM%-windows\lib
- if "%CONFIGURATION%"=="Debug" set VCPKG_LIBRARYDIR=c:\tools\vcpkg\installed\%PLATFORM%-windows\debug\lib
- set VCPKG_INCLUDEDIR=c:\tools\vcpkg\installed\%PLATFORM%-windows\include

install:
- appveyor-retry vcpkg install xerces-c:%PLATFORM%-windows xalan-c:%PLATFORM%-windows
- appveyor-retry appveyor DownloadFile https://github.com/mat007/turtle/archive/master.zip -FileName turtle-master.zip
- 7z x turtle-master.zip
- mv turtle-master/include/turtle src/libraries/turtle

build_script:
- mkdir %APPVEYOR_BUILD_FOLDER%\build\cmake
- cd %APPVEYOR_BUILD_FOLDER%\build\cmake
- cmake ../.. -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_INCLUDE_PATH=%VCPKG_INCLUDEDIR% -DCMAKE_LIBRARY_PATH=%VCPKG_LIBRARYDIR% -DBoost_USE_STATIC_LIBS=ON
- cmake --build . --config %CONFIGURATION%
- ctest -C %CONFIGURATION% --verbose
1 change: 0 additions & 1 deletion build/build.properties

This file was deleted.

131 changes: 0 additions & 131 deletions build/build.xml

This file was deleted.

90 changes: 38 additions & 52 deletions src/libraries/xeumeuleu/bridges/xerces/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
#include <xeumeuleu/bridges/xerces/detail/chained_exception.hpp>
#include <xeumeuleu/bridges/xerces/detail/translate.hpp>
#include <xeumeuleu/bridges/xerces/detail/locator.hpp>
#include <typeinfo>
#include <limits>
#include <cstdio>
#ifdef __GNUC__
#include <cxxabi.h>
#include <cstdlib>
#endif
#include <limits>
#include <typeinfo>

namespace xml
{
Expand Down Expand Up @@ -74,17 +75,17 @@ class data
//@{
void to( std::string& v ) const { XEUMEULEU_TRY if( node_ ) v = translate( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( bool& v ) const { XEUMEULEU_TRY if( node_ ) v = to_bool( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( short& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< short >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( int& v ) const { XEUMEULEU_TRY if( node_ ) v = to_int( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( long& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( long long& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< long long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( float& v ) const { XEUMEULEU_TRY if( node_ ) v = to_float( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( double& v ) const { XEUMEULEU_TRY if( node_ ) v = to_double( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( long double& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< long double >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned short& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< unsigned short >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned int& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< unsigned int >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned long& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< unsigned long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned long long& v ) const { XEUMEULEU_TRY if( node_ ) v = convert< unsigned long long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( short& v ) const { XEUMEULEU_TRY if( node_ ) v = to_signed< short >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( int& v ) const { XEUMEULEU_TRY if( node_ ) v = to_signed< int >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( long& v ) const { XEUMEULEU_TRY if( node_ ) v = to_signed< long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( long long& v ) const { XEUMEULEU_TRY if( node_ ) v = to_signed< long long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( float& v ) const { XEUMEULEU_TRY if( node_ ) v = to_float< float > ( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( double& v ) const { XEUMEULEU_TRY if( node_ ) v = to_float< double >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( long double& v ) const { XEUMEULEU_TRY if( node_ ) v = to_float< long double >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned short& v ) const { XEUMEULEU_TRY if( node_ ) v = to_unsigned< unsigned short >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned int& v ) const { XEUMEULEU_TRY if( node_ ) v = to_unsigned< unsigned int >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned long& v ) const { XEUMEULEU_TRY if( node_ ) v = to_unsigned< unsigned long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
void to( unsigned long long& v ) const { XEUMEULEU_TRY if( node_ ) v = to_unsigned< unsigned long long >( get_data() ); XEUMEULEU_CATCH_WITH_CONTEXT }
//@}

private:
Expand All @@ -109,51 +110,36 @@ class data
#endif
return name;
}
template< typename T > T convert( const XMLCh* from ) const
template< typename T > T to_signed( const XMLCh* from ) const
{
const double data = XERCES_CPP_NAMESPACE::XMLDouble( from ).getValue();
const T result = static_cast< T >( data );
if( static_cast< double >( result ) != data )
throw exception( context() + "value of " + location() + " is not a " + name( typeid( T ) ) );
return result;
return convert< T >( trim( translate( from ) ) );
}
float to_float( const XMLCh* from ) const
template< typename T > T to_unsigned( const XMLCh* from ) const
{
const XERCES_CPP_NAMESPACE::XMLFloat data( from );
if( data.isDataOverflowed() )
throw exception( context() + "value of " + location() + " overflowed (probably a double instead of a float)" );
switch( data.getType() )
{
case XERCES_CPP_NAMESPACE::XMLDouble::NegINF :
return - std::numeric_limits< float >::infinity();
case XERCES_CPP_NAMESPACE::XMLDouble::PosINF :
return std::numeric_limits< float >::infinity();
case XERCES_CPP_NAMESPACE::XMLDouble::NaN :
return std::numeric_limits< float >::quiet_NaN();
default:
return static_cast< float >( data.getValue() );
}
const std::string data = trim( translate( from ) );
if( data.empty() || data[0] == '-' )
throw exception( context() + "value of " + location() + " is not a " + name( typeid( T ) ) + ": " + data );
return convert< T >( data );
}
double to_double( const XMLCh* from ) const
template< typename T > T to_float( const XMLCh* from ) const
{
const XERCES_CPP_NAMESPACE::XMLDouble data( from );
if( data.isDataOverflowed() )
throw exception( context() + "value of " + location() + " overflowed (probably more than a double)" );
switch( data.getType() )
{
case XERCES_CPP_NAMESPACE::XMLDouble::NegINF :
return - std::numeric_limits< double >::infinity();
case XERCES_CPP_NAMESPACE::XMLDouble::PosINF :
return std::numeric_limits< double >::infinity();
case XERCES_CPP_NAMESPACE::XMLDouble::NaN :
return std::numeric_limits< double >::quiet_NaN();
default:
return data.getValue();
}
const std::string data = trim( translate( from ) );
if( data == "INF" )
return std::numeric_limits< T >::infinity();
if( data == "-INF" )
return - std::numeric_limits< T >::infinity();
if( data == "NaN" )
return - std::numeric_limits< T >::quiet_NaN();
return convert< T >( data );
}
int to_int( const XMLCh* from ) const
template< typename T > T convert( const std::string& data ) const
{
return XERCES_CPP_NAMESPACE::XMLString::parseInt( from );
std::stringstream stream( data );
T value;
stream >> value;
if( stream && stream.eof() )
return value;
throw exception( context() + "value of " + location() + " is not a " + name( typeid( T ) ) + ": " + data );
}
bool to_bool( const XMLCh* from ) const
{
Expand All @@ -162,7 +148,7 @@ class data
return true;
if( data == "false" || data == "0" )
return false;
throw exception( context() + "value of " + location() + " is not a boolean" );
throw exception( context() + "value of " + location() + " is not a boolean: " + trim( translate( from ) ) );
}

std::string context() const
Expand Down
7 changes: 4 additions & 3 deletions src/libraries/xeumeuleu/bridges/xerces/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
#include <xeumeuleu/bridges/xerces/detail/chained_exception.hpp>
#include <xeumeuleu/bridges/xerces/detail/translate.hpp>
#include <xeumeuleu/bridges/xerces/detail/import.hpp>
#include <sstream>
#include <cstdio>
#include <limits>
#include <memory>
#include <sstream>

namespace xml
{
Expand Down Expand Up @@ -277,7 +278,7 @@ class output : public output_base
# pragma warning( push )
# pragma warning( disable : 4996 )
#endif
sprintf( buffer, format, max_digits< T >(), value );
std::sprintf( buffer, format, max_digits< T >(), value );
#ifdef _MSC_VER
# pragma warning( pop )
#endif
Expand All @@ -288,7 +289,7 @@ class output : public output_base
int max_digits() const
{
// actually std::numeric_limits< T >::max_digits10 in C++11
return 2 + std::numeric_limits< T >::digits10;
return 2 + std::numeric_limits< T >::digits10;
}

XERCES_CPP_NAMESPACE::DOMAttr* create_attribute( XERCES_CPP_NAMESPACE::DOMNamedNodeMap& attributes, const std::string& ns, const std::string& name )
Expand Down
Loading

0 comments on commit 354d32a

Please sign in to comment.