Re: Help using giomm



On Thu, 11 Nov 2010 11:35:03 -0500
ArbolOne <arbolone gmail com> wrote:
> Hi kids!
> I just need a little bit of help to find my bearing when using giomm.
> If some body would be so kind as to show me how this method would be
> change from std to giomm.
> 
> TKNX!!
> 
> const char* jme::strtools::toStr( const int x ) {
>      std::stringstream num;
>      num << x;
>      tmp = num.str();
>      return tmp.c_str();
> }


This function doesn't compile and if tmp is a std::string object in
local scope then also returns a dangling pointer (a pointer to an array
owned by tmp which is destroyed as soon as the function ends).  If it
isn't a local object then it is not thread safe, so either way you lose.

This function is just the C++ way of converting an integer value to its
string representation.  That is irrelevant to the purposes of gio, the
main purpose of which is synchronous and asynchronous input/output
(with some additional sort-of-io-related things such as a dbus
implementation and icon interfaces): the high level socket interface
is particularly nice.  GDBus is also a big improvement over dbus-glib.

If what you are looking for is an integer to string converter then stick
with std::stringstream or you can use the formatting functions
available in glibmm.  If you are looking for a standard iostream
interface for gio streams, then there is one at
http://cxx-gtk-utils.sourceforge.net/group__gstreams.html . If you
scroll down to "gtkmm users" section it will tell you how to use them
with giomm, should you want to do so.

Chris




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