Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Can we convert the RWCString to std::string? If yes how? (http://www.velocityreviews.com/forums/t459754-can-we-convert-the-rwcstring-to-std-string-if-yes-how.html)

varsha.gadekar@gmail.com 01-10-2007 12:59 PM

Can we convert the RWCString to std::string? If yes how?
 
I want to convert the message of type RWCString to std::string type.
How can we do this?


Ondra Holub 01-10-2007 01:07 PM

Re: Can we convert the RWCString to std::string? If yes how?
 

varsha.gadekar@gmail.com napsal:
> I want to convert the message of type RWCString to std::string type.
> How can we do this?


Since RWCString is not C++ standard class, there is no C++ standard way
how to do it. I do not know RWCString, so I can only guess:

- look into RWCString documentation and try to find there some
converting function
- there may be also some method, whcih gives the buffer occupied by
RWCString. This may be used as one input parameters for std::string
- if RWCString can be written into output stream, you can srite it to
std::ostringstream and get the string with method str() from there


Jim Langston 01-10-2007 01:09 PM

Re: Can we convert the RWCString to std::string? If yes how?
 
<varsha.gadekar@gmail.com> wrote in message
news:1168433993.133688.126750@o58g2000hsb.googlegr oups.com...
>I want to convert the message of type RWCString to std::string type.
> How can we do this?


I googled for RWCString, and see it has an operator char*. So:
std::string MyString( RWCString );
*should* work.



varsha.gadekar@gmail.com 01-10-2007 01:42 PM

Re: Can we convert the RWCString to std::string? If yes how?
 
Thanks to you both it is working. But i need to check if it works for
large message stream
..
Jim Langston wrote:
> <varsha.gadekar@gmail.com> wrote in message
> news:1168433993.133688.126750@o58g2000hsb.googlegr oups.com...
> >I want to convert the message of type RWCString to std::string type.
> > How can we do this?

>
> I googled for RWCString, and see it has an operator char*. So:
> std::string MyString( RWCString );
> *should* work.



Frank Potter 01-10-2007 02:11 PM

Re: Can we convert the RWCString to std::string? If yes how?
 
then read a very large text file and test it,
it's easy to find out if it works for huge strings.

On Jan 10, 9:42 pm, "varsha.gade...@gmail.com"
<varsha.gade...@gmail.com> wrote:
> Thanks to you both it is working. But i need to check if it works for
> large message stream
> .
>
> Jim Langston wrote:
> > <varsha.gade...@gmail.com> wrote in message
> >news:1168433993.133688.126750@o58g2000hsb.googleg roups.com...
> > >I want to convert the message of type RWCString to std::string type.
> > > How can we do this?

>
> > I googled for RWCString, and see it has an operator char*. So:
> > std::string MyString( RWCString );
> > *should* work.



Mehturt@gmail.com 01-10-2007 02:17 PM

Re: Can we convert the RWCString to std::string? If yes how?
 
Jim Langston wrote:
> I googled for RWCString, and see it has an operator char*. So:
> std::string MyString( RWCString );
> *should* work.


This won't work if the string contains character with ascii value 0.
In this case you need the length of RWCString as well.


Satish 01-10-2007 04:46 PM

Re: Can we convert the RWCString to std::string? If yes how?
 
You can use the data() function of RWCString class to get char *

RWCString testString("Hellow")
cout << testString.data()

You can use this further to initialise std::string objects. Hope this
helps.

Ondra Holub wrote:
> varsha.gadekar@gmail.com napsal:
> > I want to convert the message of type RWCString to std::string type.
> > How can we do this?

>
> Since RWCString is not C++ standard class, there is no C++ standard way
> how to do it. I do not know RWCString, so I can only guess:
>
> - look into RWCString documentation and try to find there some
> converting function
> - there may be also some method, whcih gives the buffer occupied by
> RWCString. This may be used as one input parameters for std::string
> - if RWCString can be written into output stream, you can srite it to
> std::ostringstream and get the string with method str() from there



BobR 01-10-2007 09:02 PM

Re: Can we convert the RWCString to std::string? If yes how?
 

Frank Potter wrote in message ...
>then read a very large text file and test it,
>it's easy to find out if it works for huge strings.


Do not top-post!

{
std::string Tst("");
std::cout<<"Tst.max_size()="<<Tst.max_size()<<std: :endl;
}

--
Bob R
POVrookie




All times are GMT. The time now is 01:27 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.