Commit 27c61c02 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX #130] - removed boost lexical cast completely. This solves the locale issue.

parent e0515a6f
......@@ -24,7 +24,7 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include "WStringUtils.h"
#include "WAssert.h"
......@@ -39,7 +39,7 @@ void wAssertFailed( std::string const& expression, std::string const& file, std:
std::cerr << std::endl;
abort();
#else
std::string s = "Assertion failed: " + expression + " (in file " + file + " at line " + boost::lexical_cast< std::string >( line ) + ")";
std::string s = "Assertion failed: " + expression + " (in file " + file + " at line " + string_utils::toString( line ) + ")";
if( !msg.empty() )
{
s += ", Message: " + msg;
......
......@@ -26,7 +26,6 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "../common/exceptions/WOutOfBounds.h"
#include "../common/WStringUtils.h"
......
......@@ -25,8 +25,6 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "WStringUtils.h"
#include "WItemSelection.h"
......@@ -91,7 +89,7 @@ WItemSelector WItemSelector::newSelector( const std::string asString ) const
IndexList l;
for( size_t i = 0; i < tokens.size(); ++i )
{
l.push_back( boost::lexical_cast< size_t >( tokens[i] ) );
l.push_back( string_utils::fromString< size_t >( tokens[i] ) );
}
return createSelector( l );
......
......@@ -28,7 +28,6 @@
#include <vector>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include "WLogger.h"
......
......@@ -28,9 +28,9 @@
#include <vector>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include "WStringUtils.h"
#include "WLogger.h"
#include "exceptions/WPropertyUnknown.h"
#include "exceptions/WPropertyNotUnique.h"
......@@ -129,7 +129,7 @@ boost::shared_ptr< WPropertyBase > WPropertyGroupBase::findProperty( std::string
}
// get the properties along the path
result = findProperty( curProps, boost::lexical_cast< std::string >( *it ) );
result = findProperty( curProps, string_utils::toString( *it ) );
if( !result )
{
// not found? Return NULL.
......
......@@ -25,6 +25,7 @@
#include <string>
#include <vector>
#include "WStringUtils.h"
#include "WPropertyTypes.h"
#include "WTransferFunction.h"
......@@ -91,16 +92,17 @@ namespace PROPERTY_TYPE_HELPER
{
if( innerTokens[ 0 ] == "c" )
{
tf.addColor( boost::lexical_cast< double >( innerTokens[ 1 ].c_str() ), // isovalue
WColor( boost::lexical_cast< double >( innerTokens[ 2 ].c_str() ), // red
boost::lexical_cast< double >( innerTokens[ 3 ].c_str() ), // green
boost::lexical_cast< double >( innerTokens[ 4 ].c_str() ), // blue
1. ) ); // blue
tf.addColor( string_utils::fromString< double >( innerTokens[ 1 ].c_str() ), // isovalue
WColor( string_utils::fromString< double >( innerTokens[ 2 ].c_str() ), // red
string_utils::fromString< double >( innerTokens[ 3 ].c_str() ), // green
string_utils::fromString< double >( innerTokens[ 4 ].c_str() ), // blue
1. )
); // blue
}
else if( innerTokens[ 0 ] == "a" )
{
tf.addAlpha( boost::lexical_cast< double >( innerTokens[ 1 ].c_str() ),
boost::lexical_cast< double >( innerTokens[ 2 ].c_str() ) );
tf.addAlpha( string_utils::fromString< double >( innerTokens[ 1 ].c_str() ),
string_utils::fromString< double >( innerTokens[ 2 ].c_str() ) );
}
idx++;
}
......
......@@ -33,8 +33,8 @@
#include <utility>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include "WStringUtils.h"
#include "math/linearAlgebra/WLinearAlgebra.h"
#include "math/linearAlgebra/WMatrixFixed.h"
#include "math/linearAlgebra/WVectorFixed.h"
......@@ -308,7 +308,7 @@ namespace PROPERTY_TYPE_HELPER
/**
* Class helping to create a new instance of the property content from an old one. This might be needed by some types (some need to have a
* predecessor for creation).
* You only need to specialize this class for types not allowing the direct use of boost::lexical_cast.
* You only need to specialize this class for types not allowing the direct use of string_utils::fromString
*/
template< typename T >
class WStringConversion
......@@ -323,7 +323,7 @@ namespace PROPERTY_TYPE_HELPER
*/
T create( const T& /*old*/, const std::string str )
{
return boost::lexical_cast< T >( str );
return string_utils::fromString< T >( str );
}
/**
......@@ -335,7 +335,7 @@ namespace PROPERTY_TYPE_HELPER
*/
std::string asString( const T& v )
{
return boost::lexical_cast< std::string >( v );
return string_utils::toString( v );
}
};
......@@ -477,7 +477,7 @@ namespace PROPERTY_TYPE_HELPER
*/
std::string asString( const WPVBaseTypes::PV_SELECTION& v )
{
return boost::lexical_cast< std::string >( v );
return string_utils::toString( v );
}
};
......@@ -580,7 +580,7 @@ namespace PROPERTY_TYPE_HELPER
{
for( size_t col = 0; col < 4; ++col )
{
c( row, col ) = boost::lexical_cast< double >( tokens[ idx ] );
c( row, col ) = string_utils::fromString< double >( tokens[ idx ] );
idx++;
}
}
......@@ -679,7 +679,7 @@ namespace PROPERTY_TYPE_HELPER
size_t idx = 0;
for( size_t col = 0; col < 3; ++col )
{
c[ col ] = boost::lexical_cast< double >( tokens[ idx ] );
c[ col ] = string_utils::fromString< double >( tokens[ idx ] );
idx++;
}
return c;
......
......@@ -598,7 +598,7 @@ bool WPropertyVariable< T >::setAsString( std::string value )
PROPERTY_TYPE_HELPER::WStringConversion< T > h = PROPERTY_TYPE_HELPER::WStringConversion< T >();
return set( h.create( WFlag< T >::get(), value ) );
}
catch( const boost::bad_lexical_cast &e )
catch( const std::exception &e )
{
return false;
}
......
......@@ -32,8 +32,7 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include "WStringUtils.h"
#include "WException.h"
......@@ -64,7 +63,7 @@ private:
static void SignalHandler( int signum )
{
throw SignalExceptionClass( std::string( "SIGNAL: " ) +
boost::lexical_cast<std::string>( signum ) );
string_utils::toString( signum ) );
}
};
};
......
......@@ -35,7 +35,6 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
......@@ -59,6 +58,39 @@
*/
namespace string_utils
{
/**
* Convert a given value to a string. The input value must provide a operator<< or be a standard scalar type.
*
* \tparam T the source type. You do not need to specify this directly as it can be deducted from the given parameter
* \param value the value to cast to string
*
* \return the string.
*/
template< typename T >
inline std::string toString( const T& value )
{
std::stringstream ss;
ss << value;
return ss.str();
}
/**
* Convert a given string to a value of a certain type. The target type must provide a operator>> to work or be a standard scalar type.
*
* \tparam T the source type.
* \param value the value to cast to string
*
* \return the string.
*/
template< typename T >
inline T fromString( const std::string& str )
{
std::stringstream ss( str );
T value;
ss >> value;
return value;
}
/** We consider the following characters as whitespace:
* - <tt>\\r</tt> carriage return
* - <tt>\\n</tt> newline
......@@ -153,7 +185,7 @@ namespace string_utils
* Also wrapping brackets '[' ']' are expected. In general this is the opposite of the
* output operator above.
* \warning The inputstream is first written into a string then the convertion into T
* via boost::lexical_cast takes place.
* via fromString takes place.
* \warning The delimiter should not be in an elements string representation since then
* the tokenizer may gets confused
*
......@@ -172,7 +204,7 @@ namespace string_utils
v.reserve( tokens.size() );
for( size_t i = 0; i < tokens.size(); ++i )
{
v.push_back( boost::lexical_cast< T >( tokens[i] ) );
v.push_back( fromString< T >( tokens[i] ) );
}
return in;
}
......@@ -210,39 +242,6 @@ namespace string_utils
os << rTrim( result.str(), ", " ) << "}";
return os;
}
/**
* Convert a given value to a string. The input value must provide a operator<< or be a standard scalar type.
*
* \tparam T the source type. You do not need to specify this directly as it can be deducted from the given parameter
* \param value the value to cast to string
*
* \return the string.
*/
template< typename T >
inline std::string toString( const T& value )
{
std::stringstream ss;
ss << value;
return ss.str();
}
/**
* Convert a given string to a value of a certain type. The target type must provide a operator>> to work or be a standard scalar type.
*
* \tparam T the source type.
* \param value the value to cast to string
*
* \return the string.
*/
template< typename T >
inline T fromString( const std::string& str )
{
std::stringstream ss( str );
T value;
ss >> value;
return value;
}
} // end of namespace
#endif // WSTRINGUTILS_H
......@@ -29,7 +29,6 @@
#include <algorithm>
#include <boost/static_assert.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
// Needed for conversion: OSG Types
......@@ -975,8 +974,8 @@ public:
{
if( ( row >= Rows ) || ( col >= Cols ) )
{
throw WOutOfBounds( "Index pair (" + boost::lexical_cast< std::string >( row ) + ", " + boost::lexical_cast< std::string >( col ) +
") is invalid for " + boost::lexical_cast< std::string >( Rows ) + "x" + boost::lexical_cast< std::string >( Cols ) +
throw WOutOfBounds( "Index pair (" + string_utils::toString( row ) + ", " + string_utils::toString( col ) +
") is invalid for " + string_utils::toString( Rows ) + "x" + string_utils::toString( Cols ) +
" matrix." );
}
return operator()( row, col );
......@@ -998,8 +997,8 @@ public:
{
if( ( row >= Rows ) || ( col >= Cols ) )
{
throw WOutOfBounds( "Index pair (" + boost::lexical_cast< std::string >( row ) + ", " + boost::lexical_cast< std::string >( col ) +
") is invalid for " + boost::lexical_cast< std::string >( Rows ) + "x" + boost::lexical_cast< std::string >( Cols ) +
throw WOutOfBounds( "Index pair (" + string_utils::toString( row ) + ", " + string_utils::toString( col ) +
") is invalid for " + string_utils::toString( Rows ) + "x" + string_utils::toString( Cols ) +
" matrix." );
}
return operator()( row, col );
......@@ -1460,7 +1459,7 @@ std::istream& operator>>( std::istream& in, WMatrixFixed< ValueT, Rows, Cols, Va
{
return in;
}
m( row, col ) = boost::lexical_cast< ValueT >( *it );
m( row, col ) = string_utils::fromString< ValueT >( *it );
++it;
}
}
......
......@@ -26,12 +26,12 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "WSubject.h"
#include "exceptions/WDHNoSuchSubject.h"
#include "../common/WLogger.h"
#include "../common/WStringUtils.h"
#include "WDataHandler.h"
......@@ -52,7 +52,7 @@ WDataHandler::~WDataHandler()
void WDataHandler::addSubject( boost::shared_ptr< WSubject > subject )
{
WLogger::getLogger()->addLogMessage( "Adding subject with ID \"" +
boost::lexical_cast< std::string >( subject->getPersonalInformation().getSubjectID() ) + "\" and Name \""
string_utils::toString( subject->getPersonalInformation().getSubjectID() ) + "\" and Name \""
+ subject->getName() + "\".",
"Data Handler", LL_DEBUG );
......@@ -65,7 +65,7 @@ void WDataHandler::removeSubject( boost::shared_ptr< WSubject > subject )
SubjectSharedContainerType::WriteTicket l = m_subjects.getWriteTicket();
WLogger::getLogger()->addLogMessage( "Removing subject with ID \"" +
boost::lexical_cast< std::string >( subject->getPersonalInformation().getSubjectID() ) + "\" and Name \""
string_utils::toString( subject->getPersonalInformation().getSubjectID() ) + "\" and Name \""
+ subject->getName() + "\".",
"Data Handler", LL_DEBUG );
......@@ -91,7 +91,7 @@ void WDataHandler::clear()
++iter )
{
WLogger::getLogger()->addLogMessage( "Removing subject \"" +
boost::lexical_cast< std::string >( ( *iter )->getPersonalInformation().getSubjectID() ) + "\".",
string_utils::toString( ( *iter )->getPersonalInformation().getSubjectID() ) + "\".",
"Data Handler", LL_DEBUG );
( *iter )->clear();
......
......@@ -29,7 +29,6 @@
#include <vector>
#include <boost/filesystem/fstream.hpp>
#include <boost/lexical_cast.hpp>
#include "../common/datastructures/WFiber.h"
#include "../common/WBoundingBox.h"
......
......@@ -25,7 +25,6 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "../common/WLogger.h"
......
......@@ -27,7 +27,6 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include "../../common/WAssert.h"
......@@ -105,9 +104,9 @@ void WReaderMatrixSymVTK::readTable( boost::shared_ptr< std::vector< double > >
}
try
{
numDistances = boost::lexical_cast< size_t >( tokens.at( 1 ) );
numDistances = string_utils::fromString< size_t >( tokens.at( 1 ) );
}
catch( const boost::bad_lexical_cast &e )
catch( const std::exception &e )
{
throw WDHException( std::string( "Invalid number of elements: " + tokens.at( 1 ) ) );
}
......
......@@ -28,6 +28,8 @@
#include <string>
#include "../common/WLogger.h"
#include "../common/WStringUtils.h"
#include "WGETextureUtils.h"
#include "exceptions/WGESignalSubscriptionFailed.h"
......@@ -50,8 +52,8 @@ void setDefines( osg::ref_ptr< WGEShader > shader, size_t start = 0 )
// disable textures with invalid unit numbers
if( unit < wge::getMaxTexUnits() - start )
{
shader->setDefine( "Colormap" + boost::lexical_cast< std::string >( unit ) + "Enabled", true );
shader->setDefine( "Colormap" + boost::lexical_cast< std::string >( unit ) + "Unit", start + unit );
shader->setDefine( "Colormap" + string_utils::toString( unit ) + "Enabled", true );
shader->setDefine( "Colormap" + string_utils::toString( unit ) + "Unit", start + unit );
}
}
}
......@@ -282,7 +284,7 @@ void WGEColormapping::callback( osg::Node* node )
( unit < maxTexUnits ) && ( iter != rt->get().end() );
++iter )
{
wge::bindTexture( node, *iter, unit, "u_colormap" + boost::lexical_cast< std::string >( unit - info->m_texUnitStart ) );
wge::bindTexture( node, *iter, unit, "u_colormap" + string_utils::toString( unit - info->m_texUnitStart ) );
unit++;
}
......
......@@ -39,6 +39,8 @@
#include "../common/math/linearAlgebra/WLinearAlgebra.h"
#include "../common/math/WMath.h"
#include "../common/WPathHelper.h"
#include "../common/WStringUtils.h"
#include "shaders/WGEShader.h"
#include "WGEGeodeUtils.h"
#include "WGEGeometryUtils.h"
......@@ -410,8 +412,8 @@ osg::ref_ptr< osg::PositionAttitudeTransform > wge::addLabel( osg::Vec3 position
osg::ref_ptr< osg::PositionAttitudeTransform > wge::vector2label( osg::Vec3 position )
{
std::string label = "(" + boost::lexical_cast< std::string >( position[0] ) + "," +
boost::lexical_cast< std::string >( position[1] ) + "," + boost::lexical_cast< std::string >( position[2] ) + ")";
std::string label = "(" + string_utils::toString( position[0] ) + "," +
string_utils::toString( position[1] ) + "," + string_utils::toString( position[2] ) + ")";
return ( addLabel( position, label ) );
}
......
......@@ -25,12 +25,13 @@
#include <string>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <osg/Camera>
#include "../common/WLogger.h"
#include "../common/WStringUtils.h"
#include "WGraphicsEngine.h"
#include "WGEViewer.h"
......@@ -68,7 +69,7 @@ double* parseDoubleSequence( std::string seq, unsigned int size )
unsigned int i = 0;
for( tokenizer::iterator it = tok.begin(); ( it != tok.end() ) && ( i < size ); ++it )
{
values[ i ] = boost::lexical_cast< double >( ( *it ) );
values[ i ] = string_utils::fromString< double >( ( *it ) );
++i;
}
......@@ -119,7 +120,7 @@ bool WGEProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Camera \"" << matches[2] << "\" with ID " << matches[1];
// store it
m_cameras[ boost::lexical_cast< unsigned int >( matches[1] ) ] = matches[2];
m_cameras[ string_utils::fromString< unsigned int >( matches[1] ) ] = matches[2];
return true;
}
......@@ -131,8 +132,8 @@ bool WGEProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Camera Manipulator Matrix with ID " << matches[1];
// is there already a matrix for this camera? -> we do not care :-). Overwrite it.
m_manipulatorMatrices[ boost::lexical_cast< unsigned int >( matches[1] ) ] =
osg::Matrixd( parseMatrix( boost::lexical_cast< std::string >( matches[2] ) ) );
m_manipulatorMatrices[ string_utils::fromString< unsigned int >( matches[1] ) ] =
osg::Matrixd( parseMatrix( string_utils::toString( matches[2] ) ) );
return true;
}
......@@ -145,8 +146,8 @@ bool WGEProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Camera Manipulator Home Eye Point with ID " << matches[1];
// is there already a vector set? -> ignore.
double* vals = parseVector( boost::lexical_cast< std::string >( matches[2] ) );
m_homeEyeVectors[ boost::lexical_cast< unsigned int >( matches[1] ) ] = osg::Vec3d( vals[0], vals[1], vals[2] );
double* vals = parseVector( string_utils::toString( matches[2] ) );
m_homeEyeVectors[ string_utils::fromString< unsigned int >( matches[1] ) ] = osg::Vec3d( vals[0], vals[1], vals[2] );
return true;
}
......@@ -159,8 +160,8 @@ bool WGEProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Camera Manipulator Home Center Point with ID " << matches[1];
// is there already a vector set? -> ignore.
double* vals = parseVector( boost::lexical_cast< std::string >( matches[2] ) );
m_homeCenterVectors[ boost::lexical_cast< unsigned int >( matches[1] ) ] = osg::Vec3d( vals[0], vals[1], vals[2] );
double* vals = parseVector( string_utils::toString( matches[2] ) );
m_homeCenterVectors[ string_utils::fromString< unsigned int >( matches[1] ) ] = osg::Vec3d( vals[0], vals[1], vals[2] );
return true;
}
......@@ -173,8 +174,8 @@ bool WGEProjectFileIO::parse( std::string line, unsigned int lineNumber )
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Camera Manipulator Home Up Point with ID " << matches[1];
// is there already a vector set? -> ignore.
double* vals = parseVector( boost::lexical_cast< std::string >( matches[2] ) );
m_homeUpVectors[ boost::lexical_cast< unsigned int >( matches[1] ) ] = osg::Vec3d( vals[0], vals[1], vals[2] );
double* vals = parseVector( string_utils::toString( matches[2] ) );
m_homeUpVectors[string_utils::fromString< unsigned int >( matches[1] ) ] = osg::Vec3d( vals[0], vals[1], vals[2] );
return true;
}
......
......@@ -27,7 +27,6 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include <osg/Node>
......
......@@ -34,13 +34,11 @@
#include <osg/Texture2D>
#include <osg/Texture3D>
#include <boost/lexical_cast.hpp>
#include "../common/WStringUtils.h"
#include "shaders/WGEPropertyUniform.h"
#include "callbacks/WGEPropertyTransformationCallback.h"
template < typename T > class WGETexture;
class WDataTexture3D;
......@@ -148,7 +146,7 @@ void wge::bindTexture( osg::ref_ptr< osg::Node > node, osg::ref_ptr< T > texture
{
if( prefix == "" )
{
prefix = "u_texture" + boost::lexical_cast< std::string >( unit );
prefix = "u_texture" + string_utils::toString( unit );
}
osg::StateSet* state = node->getOrCreateStateSet();
......@@ -165,7 +163,7 @@ void wge::bindTexture( osg::ref_ptr< osg::Node > node, osg::ref_ptr< WGETexture<
{
if( prefix == "" )
{
prefix = "u_texture" + boost::lexical_cast< std::string >( unit );
prefix = "u_texture" + string_utils::toString( unit );
}
wge::bindTexture< T >( node, osg::ref_ptr< T >( texture ), unit, prefix );
......
......@@ -28,7 +28,6 @@
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include <osg/Array>
#include <osg/Vec3>
......
......@@ -24,7 +24,6 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include <osg/Texture>
#include <osg/Texture2D>
......
......@@ -31,7 +31,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/tokenizer.hpp>
......