Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Split/Join/Merge
Split/Join/Merge [message #42983] Mon, 21 April 2014 17:42 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I have refactored utility functions for splitting and merging strings. New Split is 2 times faster in typical usage and comes in String/WString variants. Separator can be specified as char, string, character filter or text filter (returns position after text if accepted or NULL). It is now also possible to specify the maximum of substrings returned.

SplitTo is variant that splits into String references (does not return Vector<String>).

Join joins Vector<String> with defined separator text.

Merge joins individual strings with defined separator text, ignores empty ones.

MergeWith is similiar, but merges with target string (provided as first parameter).

Documentation, reference example (and autotest) are provided.
Re: Split/Join/Merge [message #42988 is a reply to message #42983] Mon, 21 April 2014 22:18 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Mirek.

Thanks for these handy functions, they are really useful!
But latest SplitMerge.cpp fails to compile on gcc 4.2+;
Also, api doc for Split/Merge/Join stays as a no-name entry in Topic++. Maybe it should go under String utilities topic?
Below errors basically say "no match with function, etc..."
/Ultimate++/uppsrc/Core/SplitMerge.cpp: In function 'Upp::Vector<Upp::String> Upp::Split(int, const char*, int (*)(int), bool)':
Ultimate++/uppsrc/Core/SplitMerge.cpp:38:61: hata: 'SplitGeneric(int&, Upp::Split(int, const char*, int (*)(int), bool)::<anonymous struct>&, const char*&, bool&)' çağrısı ile eşleşen bir işlev yok
  return SplitGeneric<String>(maxcount, delim, s, ignoreempty);
                                                             ^
/Ultimate++/uppsrc/Core/SplitMerge.cpp:38:61: bilgi: candidate is:
/Ultimate++/uppsrc/Core/SplitMerge.cpp:6:11: bilgi: template<class S, class Char, class F> Upp::Vector<T> Upp::SplitGeneric(int, const F&, const Char*, bool)
 Vector<S> SplitGeneric(int maxcount, const F& delim, const Char *s, bool ignoreempty = true)
           ^
/Ultimate++/uppsrc/Core/SplitMerge.cpp:6:11: bilgi:   template argument deduction/substitution failed:
/Ultimate++/uppsrc/Core/SplitMerge.cpp: In substitution of 'template<class S, class Char, class F> Upp::Vector<T> Upp::SplitGeneric(int, const F&, const Char*, bool) [with S = Upp::String; Char = char;
	 F = Upp::Split(int, const char*, int (*)(int), bool)::<anonymous struct>]':
Ultimate++/uppsrc/Core/SplitMerge.cpp:38:61:   required from here
Ultimate++/uppsrc/Core/SplitMerge.cpp:38:61: hata: 'Upp::Split(int, const char*, int (*)(int), bool)::<anonymous struct>' anonim türdür/tür kullanır
  return SplitGeneric<String>(maxcount, delim, s, ignoreempty);
                                                             ^
/Ultimate++/uppsrc/Core/SplitMerge.cpp:38:61: hata:   'template<class S, class Char, class F> Upp::Vector<T> Upp::SplitGeneric(int, const F&, const Char*, bool)' örneklenmeye çalışılıyor
/Ultimate++/uppsrc/Core/SplitMerge.cpp: In function 'Upp::Vector<Upp::String> Upp::Split(int, const char*, int, bool)':
Ultimate++/uppsrc/Core/SplitMerge.cpp:48:61: hata: 'SplitGeneric(int&, Upp::Split(int, const char*, int, bool)::<anonymous struct>&, const char*&, bool&)' çağrısı ile eşleşen bir işlev yok
  return SplitGeneric<String>(maxcount, delim, s, ignoreempty);
                                                             ^
/Ultimate++/uppsrc/Core/SplitMerge.cpp:48:61: bilgi: candidate is:
/Ultimate++/uppsrc/Core/SplitMerge.cpp:6:11: bilgi: template<class S, class Char, class F> Upp::Vector<T> Upp::SplitGeneric(int, const F&, const Char*, bool)
 Vector<S> SplitGeneric(int maxcount, const F& delim, const Char *s, bool ignoreempty = true)
           ^
/Ultimate++/uppsrc/Core/SplitMerge.cpp:6:11: bilgi:   template argument deduction/substitution failed:
/Ultimate++/uppsrc/Core/SplitMerge.cpp: In substitution of 'template<class S, class Char, class F> Upp::Vector<T> Upp::SplitGeneric(int, const F&, const Char*, bool) [with S = Upp::String; Char = char;
	 F = Upp::Split(int, const char*, int, bool)::<anonymous struct>]':
/Ultimate++/uppsrc/Core/SplitMerge.cpp:48:61:   required from here
/Ultimate++/uppsrc/Core/SplitMerge.cpp:48:61: hata: 'Upp::Split(int, const char*, int, bool)::<anonymous struct>' anonim türdür/tür kullanır
  return SplitGeneric<String>(maxcount, delim, s, ignoreempty);
                                                             ^
...



Regards.


[Updated on: Mon, 21 April 2014 22:25]

Report message to a moderator

Re: Split/Join/Merge [message #42989 is a reply to message #42988] Tue, 22 April 2014 08:03 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Sorry, should have tested with Linux, failed due to lack of time. Now fixed.
Previous Topic: plugin/ppm
Next Topic: ValueArray, ValueMap now have Pick
Goto Forum:
  


Current Time: Fri Mar 29 08:09:34 CET 2024

Total time taken to generate the page: 0.01059 seconds