Click here to Skip to main content
12,458,005 members (52,743 online)
Click here to Skip to main content
Add your own
alternative version

Stats

66.6K views
223 downloads
8 bookmarked
Posted

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 .

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralTwo Words Pin
Phil Harding10-Feb-05 3:37
memberPhil Harding10-Feb-05 3:37 
GeneralRe: Two Words Pin
verger6-Oct-05 21:11
memberverger6-Oct-05 21:11 
GeneralSample will not compile in C++ 6.0 Pin
JCrane27-Feb-05 5:51
memberJCrane27-Feb-05 5:51 
GeneralRe: Sample will not compile in C++ 6.0 Pin
TomKat7-Feb-05 7:00
memberTomKat7-Feb-05 7:00 
GeneralRe: Sample will not compile in C++ 6.0 Pin
JCrane27-Feb-05 9:09
memberJCrane27-Feb-05 9:09 
GeneralRe: Sample will not compile in C++ 6.0 Pin
TomKat7-Feb-05 10:05
memberTomKat7-Feb-05 10:05 
GeneralRe: Sample will not compile in C++ 6.0 Pin
JCrane27-Feb-05 11:07
memberJCrane27-Feb-05 11:07 
GeneralRe: Sample will not compile in C++ 6.0 Pin
TomKat7-Feb-05 11:41
memberTomKat7-Feb-05 11:41 
GeneralRe: Sample will not compile in C++ 6.0 Pin
JCrane27-Feb-05 14:49
memberJCrane27-Feb-05 14:49 
GeneralRe: Sample will not compile in C++ 6.0 Pin
TomKat8-Feb-05 0:17
memberTomKat8-Feb-05 0:17 
GeneralRe: Sample will not compile in C++ 6.0 Pin
rocky_pulley9-Feb-05 16:35
sussrocky_pulley9-Feb-05 16:35 
GeneralRe: Sample will not compile in C++ 6.0 Pin
TomKat9-Feb-05 19:55
memberTomKat9-Feb-05 19:55 
GeneralRe: Sample will not compile in C++ 6.0 Pin
rocky_pulley10-Feb-05 3:50
sussrocky_pulley10-Feb-05 3:50 
GeneralI Will try Pin
ThatsAlok5-Feb-05 19:50
memberThatsAlok5-Feb-05 19:50 
GeneralRe: I Will try Pin
ThatsAlok19-Feb-05 5:41
memberThatsAlok19-Feb-05 5:41 
GeneralAnother ones completely hand written... Pin
Kochise5-Feb-05 5:12
memberKochise5-Feb-05 5:12 
GeneralRe: Another ones completely hand written... Pin
TheAuthor5-Feb-05 5:22
sussTheAuthor5-Feb-05 5:22 
GeneralThese projects... Pin
Kochise5-Feb-05 5:50
memberKochise5-Feb-05 5:50 
GeneralRe: These projects... Pin
TheAuthor5-Feb-05 6:04
sussTheAuthor5-Feb-05 6:04 
GeneralYou made me fun ! Pin
Kochise5-Feb-05 9:03
memberKochise5-Feb-05 9:03 
GeneralRe: You made me fun ! Pin
TheAuthor5-Feb-05 9:39
sussTheAuthor5-Feb-05 9:39 
GeneralRe: You made me fun ! Pin
Jeremy Falcon5-Feb-05 11:26
memberJeremy Falcon5-Feb-05 11:26 
GeneralRe: You made me fun ! Pin
TheAuthor5-Feb-05 13:49
sussTheAuthor5-Feb-05 13:49 
GeneralRe: You made me fun ! Pin
Jeremy Falcon6-Feb-05 16:39
memberJeremy Falcon6-Feb-05 16:39 
GeneralYes, I'm a long haired man ! Pin
Kochise5-Feb-05 11:40
memberKochise5-Feb-05 11:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 5 Feb 2005
Article Copyright 2005 by TomKat
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid