Boost logo

Boost Users :

Subject: Re: [Boost-users] [uuid] to string problem
From: Saygin Arkan (saygenius_at_[hidden])
Date: 2010-05-12 04:31:59


ooopps, ok
I forgot to include uuid_io.hpp file. Now it compiled... Thanks a lot for
your helps.
And about the discussions, I agree that there would be nice to have a
function u.to_string() =)

Saygin

On Mon, May 10, 2010 at 11:04 PM, Andy Tompkins <atompkins_at_[hidden]>wrote:

> On Mon, 10 May 2010 14:26 +0300, "Saygin Arkan" <saygenius_at_[hidden]>
> wrote:
>
> Hi,
> I'm a newbie on boost.
> I've downloaded and used some features.
>
> I couldn't find how to cast uuid into string.
>
> #include "boost/date_time/gregorian/gregorian.hpp"
> #include <boost/uuid/uuid.hpp>
> #include <boost/uuid/uuid_generators.hpp>
> #include <boost/uuid/random_generator.hpp>
> #include <boost/uuid/string_generator.hpp>
>
> ...
>
> date GeneratorUtils::getRandomDate() {
> int year, month ,day;
> day = rand() % 30;
> month = rand() % 12;
> year = 1980 + rand() % 25;
> string str_date = "" + day + month + year ;
> date d(from_simple_string(str_date));
>
> return d;
>
> string GeneratorUtils::getRandomID(){
>
> random_generator gen;
> uuid u = gen();
>
> return u.uuid_to_string(); // ERROR
> }
>
>
> It does not accept any to_string() function. Is there a way to convert from
> uuid to string in C++?
> (by the way, I can use the other things such as date d, uuid u etc.)
>
>
> see
> http://www.boost.org/doc/libs/1_43_0/libs/uuid/uuid.html#boost/uuid/uuid_io.hpp
> one can also use lexical_cast eg:
>
> uuid u;
> string s = lexical_cast<string>(u);
>
> I'll update the documentation to include this example.
>
> Regards,
> Andy.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
H. Saygin Arkan
Tampere University of Tech.
CS / III - +358466646156


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net