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

Discussion in 'C++' started by varsha.gadekar@gmail.com, Jan 10, 2007.

  1. Guest

    I want to convert the message of type RWCString to std::string type.
    How can we do this?
    , Jan 10, 2007
    #1
    1. Advertising

  2. Ondra Holub Guest

    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::eek:stringstream and get the string with method str() from there
    Ondra Holub, Jan 10, 2007
    #2
    1. Advertising

  3. Jim Langston Guest

    <> wrote in message
    news:...
    >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.
    Jim Langston, Jan 10, 2007
    #3
  4. Guest

    Thanks to you both it is working. But i need to check if it works for
    large message stream
    ..
    Jim Langston wrote:
    > <> wrote in message
    > news:...
    > >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.
    , Jan 10, 2007
    #4
  5. Frank Potter Guest

    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, ""
    <> wrote:
    > Thanks to you both it is working. But i need to check if it works for
    > large message stream
    > .
    >
    > Jim Langston wrote:
    > > <> wrote in message
    > >news:...
    > > >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, Jan 10, 2007
    #5
  6. Guest

    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.
    , Jan 10, 2007
    #6
  7. Satish Guest

    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:
    > 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::eek:stringstream and get the string with method str() from there
    Satish, Jan 10, 2007
    #7
  8. BobR Guest

    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
    BobR, Jan 10, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. stepheng
    Replies:
    0
    Views:
    2,129
    stepheng
    Jan 15, 2004
  2. Peter Jansson
    Replies:
    5
    Views:
    6,272
    Ivan Vecerina
    Mar 17, 2005
  3. teo
    Replies:
    3
    Views:
    518
  4. Jeffrey Walton
    Replies:
    10
    Views:
    929
    Mathias Gaunard
    Nov 26, 2006
  5. Jamie Herre
    Replies:
    1
    Views:
    179
    why the lucky stiff
    Jan 7, 2005
Loading...

Share This Page