Click here to Skip to main content
Click here to Skip to main content

Ultimate String and String-List classes

, 5 Feb 2005
Rate this:
Please Sign up or sign in to vote.
String and String-List classes compatible with both ASCII and UNICODE strings.

Warning: This has been built using VS.NET 7.1. If you can't handle some errors due to default parameter values and some minor thing, don't bother. Read the discussions for more info.

Introduction

No matter what you code, you will always bump into string management and everyone knows that sometimes it can really be a pain in the ... you know. Well, this article hopes (and I think it succeeds) in making the whole thing easier.

Description

The code presented in this article has the next goals to achieve:

  • Manage both UNICODE and ASCII strings and string-lists.
  • Provided tools for simple conversion between them.
  • Provide a simple wrapper to allow working with them.

Let's go to the next level.

Classes Details

The code contains the following classes with their functions:

  • plStringT

    This class is a template class with one param szBlock. The size of the plStringT used memory will always be a multiple of szBlock. When a memory of szBlock is allocated then, as long as the string's length doesn't top this value no memory will be allocated. This is for performance.

    Internal functions are self explanatory and there's no point in describing all the 125 of them.

  • plStringList

    This class is for managing string-lists.

    Internal functions are self explanatory and there's no point in describing all the 49 of them.

  • plToStringW, plToStringA, plToStringB, plToString

    These are helping classes. Used for conversion.

    Internal functions are self explanatory and there's no point in describing all of them.

  • plArrayT, plPointerT

    These are helping classes. An array and a pointer array. The pointer array can also free pointers on deletion.

    Internal functions are self explanatory and there's no point in describing all of them.

How to...

Some how-to points:
  • Append a formatted string:
     plString string;
     string+=plString(_T("%d %s"),100,_T("string"));
  • Load a file (UNICODE or ASCII):
     plString string;
     string.Load(_T("anytypeoffile.txt"));
  • Save a UNICODE file:
     plString string;
     string.Save(_T("anytypeoffile.txt"),0/*append*/,1/*UNICODE*/);
  • Append ASCII string:
     plString string;
     string+=plToString("ascii stuff %d",1000);
  • Read all lines:
     plString Lines;
     plString Line;
     INT Pos=0;
     while(Lines.ReadLine(Pos,Line))
     {
        _tprintf(_T("%s\r\n",Line.GetString());
     }
  • Split a text into lines:
     plString Lines;
     plStrings lstLines;
     lstLines.SplitText(Lines,_T("\r\n"),0);

Once you get a hold of it you'll be able to do anything. Easy, huh?

History

  • 05.02.2005

    First release.

  • 07.02.2005

    Fixed some bugs in plArrayT.

For any problems contact me or write here and I`ll look into them quickly . I use this classes extensively and I need them in best shape.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

TomKat
Web Developer
Romania Romania
I have been programming for the past 6 years in VBasic, Delphi, C, C++ .
I also have extended knowledge of webdesign (HTML, CSS, JavaScript, VBScript), webprogramming (PHP, ASP, ASP.NET (C#)) and database integration (mySql, MSSQL Server).
And when I`m not programming I`m working out or working on some personal projects .
Last but not least I`m looking for a project-based job in programming or webdesign .

Comments and Discussions

 
GeneralTwo Words PinmemberPhil Harding10-Feb-05 3:37 
GeneralRe: Two Words Pinmemberverger6-Oct-05 21:11 
GeneralSample will not compile in C++ 6.0 PinmemberJCrane27-Feb-05 5:51 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberTomKat7-Feb-05 7:00 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberJCrane27-Feb-05 9:09 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberTomKat7-Feb-05 10:05 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberJCrane27-Feb-05 11:07 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberTomKat7-Feb-05 11:41 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberJCrane27-Feb-05 14:49 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberTomKat8-Feb-05 0:17 
GeneralRe: Sample will not compile in C++ 6.0 Pinsussrocky_pulley9-Feb-05 16:35 
GeneralRe: Sample will not compile in C++ 6.0 PinmemberTomKat9-Feb-05 19:55 
GeneralRe: Sample will not compile in C++ 6.0 Pinsussrocky_pulley10-Feb-05 3:50 
GeneralI Will try PinmemberThatsAlok5-Feb-05 19:50 
GeneralRe: I Will try PinmemberThatsAlok19-Feb-05 5:41 
GeneralAnother ones completely hand written... PinmemberKochise5-Feb-05 5:12 
GeneralRe: Another ones completely hand written... PinsussTheAuthor5-Feb-05 5:22 
GeneralThese projects... PinmemberKochise5-Feb-05 5:50 
GeneralRe: These projects... PinsussTheAuthor5-Feb-05 6:04 
GeneralYou made me fun ! PinmemberKochise5-Feb-05 9:03 
GeneralRe: You made me fun ! PinsussTheAuthor5-Feb-05 9:39 
GeneralRe: You made me fun ! PinmemberJeremy Falcon5-Feb-05 11:26 
GeneralRe: You made me fun ! PinsussTheAuthor5-Feb-05 13:49 
GeneralRe: You made me fun ! PinmemberJeremy Falcon6-Feb-05 16:39 
GeneralYes, I'm a long haired man ! PinmemberKochise5-Feb-05 11:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 5 Feb 2005
Article Copyright 2005 by TomKat
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid