[lug] C++ libraries in Linux

D. Stimits stimits at idcomm.com
Tue Sep 18 12:01:59 MDT 2001


Keith Brown wrote:
> 
> I hate to reply to my own mail, but my example is not correct.  The buf should be
> unfrozen with buf.freeze(false), at least according to Josuttis.  Additionally,
> strstream has been depreciated and he suggest you use stringstream.

I went and replied before I saw your reply :(

But I would avoid stringstream unless you will not be porting to older
machines. Even RH 6.2 did not have stringstream, at least I recall it
was bare in that area. In RH, I think 7.0 is the first to offer it?

D. Stimits, stimits at idcomm.com

> 
> Keith
> 
> Keith Brown wrote:
> 
> > Hi,
> >
> > I believe you have memory leak in your example.  Once you do buf.str(), the
> > program owns the *char that is returned, unless it tells strstream otherwise,
> > which I forget how to do.  I believe you need to do it like:
> >
> > char * s = buf.str();
> > rtnval = s;
> > delete [] s;
> > return rtnval;
> >
> > Keith
> >
> > "Scott A. Herod" wrote:
> >
> > > Hi,
> > >   I use something like the following:
> > >
> > > #include
> > > <strstream>
> > > string paraNode::toString()
> > > {
> > >     string rtnval;
> > >     strstream buf;
> > >
> > >     buf << "Paragraph: "
> > >         << ATTR_ALIGN << " = " << _align << ", "
> > >         << ATTR_WRAP_MODE << " = " << _mode
> > >         << ends;
> > >
> > >     rtnval = buf.str();
> > >     return rtnval;
> > > }
> > >
> > > > Can it be true?  There are no converters to go from an int to a string?  Or
> > > > a double to a string?
> > > >
> > > > --Keith
> > > _______________________________________________
> > > Web Page:  http://lug.boulder.co.us
> > > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> >
> > --
> > Keith Brown
> > 12640 Xavier St
> > Broomfield, CO 80020
> > 303.438.8169
> >
> > _______________________________________________
> > Web Page:  http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> 
> --
> Keith Brown
> 12640 Xavier St
> Broomfield, CO 80020
> 303.438.8169
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list