Re: Glib::ustring conversion
- From: Bram Neijt <bneijt gmail com>
- To: gtkmm-list gnome org
- Subject: Re: Glib::ustring conversion
- Date: Tue, 28 Jun 2005 16:46:26 +0200
Although a bit clumsy, this works:
#include <gtkmm.h>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
Glib::ustring test("1002");
istringstream out(test);
unsigned value;
out >> value;
cout << value << "\n";
return 0;
}
However, you might want to use the BOOST lexical_cast.
As a side note I would like to say that: NEVER SHOULD A get_int
FUNCTION BE MADE!
For this C++ provides insertion and extraction operators, which can be
overloaded. So if anybody is thinking "hey that's a good idea" NO
IT'S NOT!
Happy hacking!
Bram
On 6/28/05, Ariel Aguirre <leiraaguirre hotmail com> wrote:
> hello to all.
> Using Glib::ustring I am followed with the necessity to make conversions to
> other data types.
> I ask myself if he is not advisable to add method of conversion this class
> to him.
> For example:
> to_int() or get_int()
> to_double() or get_double()
> to_date() or get_date()
>
> Ariel Aguirre
>
> _________________________________________________________________
> MSN Amor: busca tu ½ naranja http://latam.msn.com/amor/
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]