Testing string utils due to a heap problem when using static linking

parent 572470c3
......@@ -385,11 +385,10 @@ std::vector< std::string > splitString( const std::string& s, const std::string&
return splitString( s, char( sSeparator[ 0 ] ) );
else
ITA_EXCEPT0( NOT_IMPLEMENTED ); // TODO: Implement for strings
return v;
}
void regexSplitString( const std::string& src, std::vector< std::string >& dest, const std::string& regex, bool bMatchCase ) {
void regexSplitString( const std::string& src, std::vector< std::string >& dest, const std::string& regex, bool bMatchCase )
{
dest.clear();
if( src.empty() ) return;
......@@ -587,7 +586,8 @@ bool ITAConversion::StringToDouble( const std::string& s, double& d ) {
return bValid;
}
bool ITAConversion::StringToIntVec( const std::string& s, std::vector<int>& v, std::string sSeparatorRegex, bool bMatchCase ) {
bool ITAConversion::StringToIntVec( const std::string& s, std::vector<int>& v, std::string sSeparatorRegex, bool bMatchCase )
{
// [fwe 2008-07-09] TODO: Diese Implementierung ist mal eben gebaut und hemdsärmelig! Verbessern!
pcrecpp::RE_Options re_opts;
re_opts.set_multiline( true );
......@@ -598,19 +598,23 @@ bool ITAConversion::StringToIntVec( const std::string& s, std::vector<int>& v, s
std::string part;
v.clear();
while( re.FindAndConsume( &input, &part ) ) {
while( re.FindAndConsume( &input, &part ) )
{
int i;
if( !StringToInt( part, i ) ) {
if( !StringToInt( part, i ) )
{
v.clear();
return false;
}
v.push_back( i );
}
std::string e = re.error();
return true;
}
bool ITAConversion::StringToUIntVec( const std::string& s, std::vector<unsigned int>& v, std::string sSeparatorRegex, bool bMatchCase ) {
bool ITAConversion::StringToUIntVec( const std::string& s, std::vector<unsigned int>& v, std::string sSeparatorRegex, bool bMatchCase )
{
// [fwe 2008-07-09] TODO: Diese Implementierung ist mal eben gebaut und hemdsärmelig! Verbessern!
pcrecpp::RE_Options re_opts;
re_opts.set_multiline( true );
......@@ -621,9 +625,11 @@ bool ITAConversion::StringToUIntVec( const std::string& s, std::vector<unsigned
std::string part;
v.clear();
while( re.FindAndConsume( &input, &part ) ) {
while( re.FindAndConsume( &input, &part ) )
{
unsigned int i;
if( !StringToUInt( part, i ) ) {
if( !StringToUInt( part, i ) )
{
v.clear();
return false;
}
......
......@@ -7,6 +7,15 @@ include( VistaCommon )
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
add_executable( ITAStringUtilsTest ITAStringUtilsTest.cpp )
target_link_libraries( ITAStringUtilsTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITAStringUtilsTest )
vista_install( ITAStringUtilsTest )
vista_create_default_info_file( ITAStringUtilsTest )
set_property( TARGET ITAStringUtilsTest PROPERTY FOLDER "ITACoreLibs/Tests/ITABase" )
add_executable( ITABaseSampleBufferTest ITABaseSampleBufferTest.cpp )
target_link_libraries( ITABaseSampleBufferTest ${VISTA_USE_PACKAGE_LIBRARIES} )
......
#include <ITAStringUtils.h>
#include <iostream>
using namespace std;
int main( int, char** )
{
std::vector< int > v = StringToIntVec( "1,2,3,4" );
for( int n : v )
cout << n << endl;
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment