Example: There are some items in a wxArrayString. I want them all in one string seperated by '\n'. There is now standard way implemented yet.
please see http://forums.wxwidgets.org/viewtopic.php?t=7492 for the previous discussion.
There are some ways I think
1. a cast operator in wxArrayString so it is possible to handle it like a wxString
2. ask wxArrayString for a string of all items (GetAsString())
3. a wxString ctor wxString::wxString(wxArrayString)
4. an other solution?
For me I choose the #2 and patched the wxArrayString class.
What is the official way to get such patches in the official wxWidget source?
get a wxArrayString as a wxString Topic is solved
Code: Select all
wxString s = "";
for(int i=0;i<arr_str->GetCount();i++)
{
s << arr_str->Item(i);
// Don't draw a \n at the end of the string
if(i != arr_str->GetCount()-1)
s << '\n';
}
But what is the use of such a function ?
If you want to write it to file you usually use
a stream, and not a string. So, wxTextCtrl
also has a streaminterface.
For what and how often do you use such a function ?
to #2&3: Hm, could be a way, but how often is this needed ? And wheres the sense for it ?
Hm, and for int, float etc ?
Maybe it would make more sense to implement a templatefunction:
phlox
If you want to write it to file you usually use
a stream, and not a string. So, wxTextCtrl
also has a streaminterface.
For what and how often do you use such a function ?
to #1: I think thats the worst way, it could leed to unexpected behavoir in your code.MoonKid wrote:There are some ways I think
1. a cast operator in wxArrayString so it is possible to handle it like a wxString
2. ask wxArrayString for a string of all items (GetAsString())
3. a wxString ctor wxString::wxString(wxArrayString)
4. an other solution?
to #2&3: Hm, could be a way, but how often is this needed ? And wheres the sense for it ?
Hm, and for int, float etc ?
Maybe it would make more sense to implement a templatefunction:
Code: Select all
template<class type>wxString Array2Type(type& array,wxString delimeter)
{
// do the stuff
}
MoonKid, I don't know if you read the reactions that are posted thoroughly or not, but I explained WHY it cannot be part of the class here;
http://forums.wxwidgets.org/viewtopic.php?t=7492
Read my reply ..
- Jorgen
http://forums.wxwidgets.org/viewtopic.php?t=7492
Read my reply ..
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb