From: John L. <jla...@gm...> - 2012-06-11 04:18:01
|
On Sat, Jun 9, 2012 at 10:25 AM, Andre Arpin <ar...@ki...> wrote: > I am having a hard time understanding the use of iterator in wxlua. > > I guess an iterator is created by wxString::const_iterator end() or > wxString::const_iterator begin() for wxString which would be coded > wx.wxString(str):end() but end is a reserve word in Lua. I guess end could be > renamed. That is unfortunate. You can get the function using this... s = wx.wxString() e = s['end'] iter_end = e(s) > aa = wx.wxString("09-06-2012") > print(date:ParseDate(aa, wx.wxString_const_iterator(aa:begin()))) > aa = wx.wxString("") > print(date:ParseDate(aa, wx.wxString_const_iterator(aa:begin()))) This is probably not right, you would need to call it like this. it = aa:const_iterator() print(date:ParseDate(aa, it)) > Are iterators useful in wxLua? The addition in wxWidget maybe justified for > saving copying of strings in a tight loop but most of the time C++ programmer > will replace their code in the following way and live with the overhead. They're required for using UTF8 since not every code point is a single char. I think the simplest solution is to return two values, [bool, Lua String of start of input on failure] where the second Lua String is only returned on failure and contains the start of the input string up until the failure. I hope to have time to do it tomorrow night. Regards, John |