#include <stringutils.h>
Static Public Member Functions | |
| static string | replaceAll (string haystack, string needle, string s) |
| static string | stripWhite (string s) |
| static bool | begins (string source, string sub) |
| static bool | ends (string source, string sub) |
| static string | itos (int num) |
| static string | ltos (long num) |
| static int | split (const string &input, const string &delimiter, vector< string > &items, const bool clean=true) |
| Split the string by delimiter and return each resultant string in items. | |
| static string | join (vector< string > &items, const string &delimiter) |
| Join the contents of items with the given delimiter. | |
|
||||||||||||
|
Definition at line 57 of file stringutils.cc. Referenced by SMIL::Time::parseTimeValue(), and SMIL::MediaClippingTime::parseValue(). 00058 {
00059 return ( source.substr ( 0, sub.length() ) == sub );
00060 }
|
|
||||||||||||
|
Definition at line 62 of file stringutils.cc. Referenced by SMIL::Time::parseClockValue(). 00063 {
00064 if ( sub.length() >= source.length() )
00065 return false;
00066 return ( source.substr( source.length() - sub.length() ) == sub );
00067 }
|
|
|
Definition at line 77 of file stringutils.cc. 00078 {
00079 char s[ 81 ];
00080
00081 sprintf ( s, "%d", num );
00082 return string( s );
00083 }
|
|
||||||||||||
|
Join the contents of items with the given delimiter. Note that the no leading or trailing delimters are output. Definition at line 126 of file stringutils.cc. Referenced by directory_utils::get_relative_path_to_file(), and directory_utils::join_file_to_directory(). 00127 {
00128 string output( "" );
00129
00130 // Loop through the items
00131 for ( vector< string >::iterator item = items.begin( ); item != items.end( ); item ++ )
00132 {
00133 if ( item == items.begin() )
00134 output += *item;
00135 else
00136 output += delimiter + *item;
00137 }
00138
00139 return string( output );
00140 }
|
|
|
Definition at line 69 of file stringutils.cc. 00070 {
00071 char s[ 81 ];
00072
00073 sprintf ( s, "%ld", num );
00074 return string( s );
00075 }
|
|
||||||||||||||||
|
Definition at line 31 of file stringutils.cc. Referenced by DVPipeTool::execute(), KinoCommon::importFile(), PipeImport::Open(), SrtContext::printEntry(), and KinoCommon::updateRecentFiles(). 00032 {
00033 string::size_type pos = 0;
00034 while ( ( pos = haystack.find ( needle, pos ) ) != string::npos )
00035 {
00036 haystack.erase ( pos, needle.length() );
00037 haystack.insert ( pos, s );
00038 pos += s.length();
00039 }
00040 return haystack;
00041 }
|
|
||||||||||||||||||||
|
Split the string by delimiter and return each resultant string in items. Note that the items vector is not cleaned betweeen iterations. Definition at line 90 of file stringutils.cc. References end_position. Referenced by directory_utils::expand_directory(), directory_utils::get_relative_path_to_file(), directory_utils::join_file_to_directory(), on_name_edited(), on_name_show_popup(), Preferences::Preferences(), and showScenesThread(). 00091 {
00092 int delimiter_size = delimiter.size();
00093 int input_size = input.size();
00094
00095 // Find the first delimiter
00096 int position = 0;
00097 int end_position = input.find( delimiter, 0 );
00098
00099 // While we have a valid position
00100 while ( end_position >= position )
00101 {
00102 // Obtain the substr and push if valid
00103 string s = input.substr( position, end_position - position );
00104 if ( !clean || s.size() > 0 )
00105 items.push_back( s );
00106
00107 // Find the next delimiter
00108 position = end_position + delimiter_size;
00109 end_position = input.find( delimiter, position );
00110 }
00111
00112 // Obtain the substr of what's left and push if valid
00113 string s = input.substr( position, input_size - position );
00114 if ( !clean || s.size() > 0 )
00115 items.push_back( s );
00116
00117 // Return the number of items found
00118 return items.size();
00119 }
|
|
|
Definition at line 43 of file stringutils.cc. Referenced by SMIL::Time::parseTimeValue(), and SMIL::MediaClippingTime::parseValue(). 00044 {
00045 ostringstream dest;
00046 char c;
00047 for ( string::size_type pos = 0; pos < s.size(); ++pos )
00048 {
00049 c = s.at( pos );
00050 if ( c != 0x20 && c != 0x09 && c != 0x0d && c != 0x0a )
00051 dest << c;
00052 }
00053 return dest.str();
00054 }
|
1.4.2