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,1);
- 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
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.