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 » U++ Library support » U++ Core » Can we get a Join that uses WString?
Can we get a Join that uses WString? [message #16239] Tue, 03 June 2008 16:23 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Like this one:
WString Join(const Vector<WString>& im, const WString& delim) {
	WString r;
	for(int i = 0; i < im.GetCount(); i++) {
		if(i) r.Cat(delim);
		r.Cat(im[i]);
	}
	return r;
}
Re: Can we get a Join that uses WString? [message #16245 is a reply to message #16239] Tue, 03 June 2008 19:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, why not. In Core. (Too lazy to do Split at the moment, though...Smile

Mirek
Re: Can we get a Join that uses WString? [message #16252 is a reply to message #16239] Wed, 04 June 2008 00:40 Go to previous messageGo to next message
phirox is currently offline  phirox
Messages: 49
Registered: December 2007
Member
I was a bit bored so did an attempt for a Split function:

Vector<WString> Split(const WString& im, const WString& delim) {
	Vector<WString> r;
	if(im.IsEmpty() || delim.IsEmpty()) return r;
	int n = 0, i = 0;
	while(n >= 0) {
		n = im.Find(delim, i);
		if(n >= 0) {
			r.Add(im.Mid(i, n-i));
			i = n + delim.GetLength();
		}
	}
	r.Add(im.Mid(i));
	return r;
}
Re: Can we get a Join that uses WString? [message #16253 is a reply to message #16252] Wed, 04 June 2008 09:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, but this is not as rich interface as for String...

Mirek
Re: Can we get a Join that uses WString? [message #16258 is a reply to message #16253] Wed, 04 June 2008 13:29 Go to previous messageGo to next message
phirox is currently offline  phirox
Messages: 49
Registered: December 2007
Member
Ah my bad, I didn't realize there was already an implementation for String. I looked for it in String.h but it is in Util.h Rolling Eyes

I don't know enough about the inner workings of WString though to create a similar implementation.
Re: Can we get a Join that uses WString? [message #16259 is a reply to message #16258] Wed, 04 June 2008 14:06 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
phirox wrote on Wed, 04 June 2008 07:29

Ah my bad, I didn't realize there was already an implementation for String. I looked for it in String.h but it is in Util.h Rolling Eyes

I don't know enough about the inner workings of WString though to create a similar implementation.


Well, forget about it.

I think that templated implementation is in order here anyway...

Mirek
Previous Topic: Suggest Xmlize support for Value
Next Topic: how can i use iterators with NTL?
Goto Forum:
  


Current Time: Tue Apr 16 12:31:54 CEST 2024

Total time taken to generate the page: 0.01907 seconds