On Sat, Jun 9, 2012 at 10:25 AM, Andre Arpin <[email protected]> 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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to