473,625 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cumbersome string handling...

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
4 1577
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

"Heraklit" <ma**@akhuettel .de> wrote in message
news:7c******** *************** ***@posting.goo gle.com...
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::ostringstr eam oss;
oss << i;
std::string s(oss.str());
"split"ting some string into parts has gone
missing, ...
std::string::fi nd()
std::string::su bstr()

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
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
On Wed, 01 Sep 2004 18:11:43 +0100, tom_usenet
<to********@hot mail.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1888
by: Ken Fine | last post by:
No joy on Macromedia's boards after a few days; maybe someone can help me here. I got an excellent string handling function off of planet-source-code.com that converts text strings to proper case, i.e. "the REMAINS of the DAY" is converted to "The Remains Of The Day". This function is particularly good in that it handles certain exceptions. Can you help me make it handle more? I'm interested in two tweaks, one easy, one hard.
4
2040
by: Rajeev | last post by:
Hi I am a VB programmer. I need to do a simple thing in VC++. char strNWUserName; DWORD dBufferLength = 256; HRESULT hr; hr = WNetGetUserA("DOMAIN", strNWUserName, &dBufferLength); The strNWUserName returns .CN=UserName.O=DOMAIN I just need to extract the UserName from this using VC++. I don't need the .CN= and O.=DOMAIN.
17
4651
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some analysis and I'm led to believe (but can't yet quantitatively establish as fact) that the two basic culprits are a lot of calls to: 1.) if( someString.ToLower() == "somestring" ) and
32
14831
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
8
6861
by: Frank Rizzo | last post by:
How do I serialize Font object into a string that I can store in either INI file or the registry (I know it’s a bad thing, but need to do it nevertheless). Then, also, how do I deserialize it from that string back into a font object? Thanks.
4
3480
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if substrings need be replaced, or one character needs be changed, what shall I do? Is it better to convert strings to UCS-32 before manipulation? But on Windows, wchar_t is 16 bits which isn't enough for characters which can't be simply encoded...
2
2344
by: Garth | last post by:
I ran into a small issue and I found a solution however it is cumbersome to use. The problem and solution is describe within the MSDN article http://msdn2.microsoft.com/en-us/library/ms171728(d=ide).aspx I would like to create one subroutine for all my textboxes and not one for each textbox, given the sample subroutine below, how can I add the textbox name into this subroutine? Cumbersome Solution Private Sub SetText(ByVal As...
11
10854
by: Peter Kirk | last post by:
Hi i have a string variable which can take one of a set of many values. Depending on the value I need to take different (but related) actions. So I have a big if/else-if construct - but what is a better way of doing this? if ("control" == commandString) { } else if ("execute" == commandString)
12
1914
by: kevineller794 | last post by:
I want to make a split string function, but it's getting complicated. What I want to do is make a function with a String, BeginStr and an EndStr variable, and I want it to return it in a char array. For example: char teststr; strcpy(teststr, "test:blah;");
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.