By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,497 Members | 2,534 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,497 IT Pros & Developers. It's quick & easy.

Cumbersome string handling...

P: n/a
Dear experts,

a long time ago I spent a lot of time writing a useful program on
linux/g++ with the String.h package (maybe somebody remembers this
class String).

Now, I am trying to reactivate this, but cannot compile it anywhere
anymore, since the library is obsolete for a long time and has been
removed from current g++ distributions.

I've started implementing everything with the string class present in
the ansi c++ standard library, but I am getting more and more the
impression that I have to keep reinventing the wheel. There are no
automatic conversions integer->string available (how do I do something
like sprintf here?!?), "split"ting some string into parts has gone
missing, ...

What's your advice, how should I handle this problem? Are there any
(free as GPL or LGPL) equivalent libraries available?

Somebody must have had this difficulty before...

Regards, Andreas
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Heraklit wrote:
I've started implementing everything with the string class present in
the ansi c++ standard library, but I am getting more and more the
impression that I have to keep reinventing the wheel. There are no
automatic conversions integer->string available (how do I do something
like sprintf here?!?), "split"ting some string into parts has gone
missing, ...
[38.1] How do I convert a value (a number, for example) to a std::string?
http://www.parashift.com/c++-faq-lit....html#faq-38.1

[38.2] How do I convert a std::string to a number?
http://www.parashift.com/c++-faq-lit....html#faq-38.2
What's your advice, how should I handle this problem? Are there any
(free as GPL or LGPL) equivalent libraries available?


std::string, comes with the standard C++.

If you have lots of code and you find it easier to write your own string
class, try to do it so that you use as much std::string in it as
possible, to make things easier for you. Implement only functions which
you are using so spare yourself from extra work.
Jul 22 '05 #2

P: n/a

"Heraklit" <ma**@akhuettel.de> wrote in message
news:7c**************************@posting.google.c om...
Dear experts,

a long time ago I spent a lot of time writing a useful program on
linux/g++ with the String.h package (maybe somebody remembers this
class String).

Now, I am trying to reactivate this, but cannot compile it anywhere
anymore, since the library is obsolete for a long time and has been
removed from current g++ distributions.

I've started implementing everything with the string class present in
the ansi c++ standard library,
Why?
but I am getting more and more the
impression that I have to keep reinventing the wheel.
You are.
There are no
automatic conversions integer->string available
Yes, there are.
(how do I do something
like sprintf here?!?),
int i(123);
std::ostringstream oss;
oss << i;
std::string s(oss.str());
"split"ting some string into parts has gone
missing, ...
std::string::find()
std::string::substr()

What's your advice, how should I handle this problem?
Study the documentation for standard types 'std::string'
and the stringstream types.

Are there any
(free as GPL or LGPL) equivalent libraries available?
Somebody must have had this difficulty before...


I don't have difficulty with std::string at all. After
using 'C-style strings' for almost two decades, I find
'std::string' a joy to use.

$.02,
-Mike
Jul 22 '05 #3

P: n/a
On 1 Sep 2004 08:06:18 -0700, ma**@akhuettel.de (Heraklit) wrote:
Dear experts,

a long time ago I spent a lot of time writing a useful program on
linux/g++ with the String.h package (maybe somebody remembers this
class String).

Now, I am trying to reactivate this, but cannot compile it anywhere
anymore, since the library is obsolete for a long time and has been
removed from current g++ distributions.

I've started implementing everything with the string class present in
the ansi c++ standard library, but I am getting more and more the
impression that I have to keep reinventing the wheel. There are no
automatic conversions integer->string available (how do I do something
like sprintf here?!?), "split"ting some string into parts has gone
missing, ...

What's your advice, how should I handle this problem? Are there any
(free as GPL or LGPL) equivalent libraries available?

Somebody must have had this difficulty before...


Yes, std::string has an over-fat interface, doesn't do anything really
well, and yet doesn't offer much functionality; if it were to be
created from scratch right now with the benefit of the experience
gained since the early '90s when it was written, it would look a lot
different.

A commercial alternative is:
http://www.utilitycode.com/str/

Boost are adding a string utility library. 1.32 will be formally
released soon, but in the meantime:
http://boost-consulting.com/boost/index.htm

Boost already has useful stuff for converting between types and to
strings - see lexical_cast and the Format library in 1.31 at
www.boost.org

Tom
Jul 22 '05 #4

P: n/a
On Wed, 01 Sep 2004 18:11:43 +0100, tom_usenet
<to********@hotmail.com> wrote:

[...]

Yes, std::string has an over-fat interface, doesn't do anything really
well, and yet doesn't offer much functionality; if it were to be
created from scratch right now with the benefit of the experience
gained since the early '90s when it was written, it would look a lot
different.
Couldn't agree more. It's a shame when I look at the perfomance
penalties of std::string for some of our applications where runtime
perfomance is extremely critical.
A commercial alternative is:
http://www.utilitycode.com/str/
Never seen this before, nontheless, pretty slick ...
Boost are adding a string utility library. 1.32 will be formally
released soon, but in the meantime:
http://boost-consulting.com/boost/index.htm

Boost already has useful stuff for converting between types and to
strings - see lexical_cast and the Format library in 1.31 at
www.boost.org

Tom

Haven't jumped on the boost bandwagon yet. In any event, ...

Mark
--
[ C++ FAQ: http://www.parashift.com/c++-faq-lite/ ]
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.