Re: Glib::ustring conversion



On Thu, 2005-10-13 at 13:05 -0300, Arthur wrote:
> Bob Caryl wrote:
> 
> > Arthur wrote:
> >
> >> Hi there.
> >>
> >> I'm building a simple calculator with Glade(mm) and I would like to 
> >> know if it is possible to convert Glib::ustring to double and then 
> >> double to Glib::ustring.
> >> I need this because the calculator has an entrytext widget and when I 
> >> press the numbers and signs (plus, minus, multiply, divide, left 
> >> parenthesis and right parenthesis) a string is shown at this entry 
> >> text: "1254 + 13241 - (13241 * 1341)". When the equal button (=) is 
> >> pressed I want to pass this string as a double and make C++ to solve 
> >> this mathematic expression for me and return the result, so I can set 
> >> it as the entry text string again.

this is a standard undergraduate CS problem, normally solved by writing
a genuine parser in bison/yacc with a lexical parser in lex.

there are some less generic parser functions in glib that you might be
able to leverage, but inevitably any half-hearted effort here will lead
to early discovery of expressions that your design could not handle.

--p





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]