| |
Main Page Namespace List Class Hierarchy Alphabetical List Compound List Namespace Members Compound Members
PLMText Class ReferenceArray of strings.
More...
#include <PLMText.hpp>
Inheritance diagram for PLMText:
[legend]List of all members.
|
Public Types |
| enum | { FORMAT_TXT = 1,
FORMAT_PLMTXT = 2
} |
| enum | { FORMAT_UNK = 0,
FORMAT_DEF = 1
} |
Public Methods |
| | PLMText (u32 size=0) |
| | PLMText (const char *filename, int format=PLMResource::FORMAT_UNK) |
| | PLMText (PLMResFile &f, int format=PLMResource::FORMAT_UNK) |
| u32 | Size () const |
| u32 | Length () const |
| void | ChangeSize (u32 newsize) |
| char * | Get (u32 index) const |
| char * | operator[] (u32 index) const |
| void | SetString (u32 index, const char *newstr, u32 start=0, u32 nb=PLM::INDEX_ERROR) |
| u32 | Append (const char *newstr, u32 start=0, u32 nb=PLM::INDEX_ERROR) |
| void | Clear () |
| virtual bool | Load (PLMResFile &src, int format=PLMResource::FORMAT_UNK) |
| virtual bool | Save (PLMResFile &dest, int format=PLMResource::FORMAT_DEF) |
| virtual u32 | MemoryUsed () const |
| void | PrintInfo () const |
| virtual bool | LoadName (const char *filename, int format=FORMAT_UNK) |
| virtual bool | SaveName (const char *filename, int format=FORMAT_DEF) |
Detailed Description
Array of strings.
Notes :
- The array is implemented as a vector that will grow on demand, or if ChangeSize() is called (for example to avoid reallocations if you know the final number of strings you need)
- Size() returns the size of the array (allocated cells), and not the number of (non-empty) strings (Length())
- to get the string at index i, call Get(i) or use operator [i]
- Clear() remove and delete all strings in the array
- PLMText always works with its own copies, so the strings given as parameter to DupString() are copied. If i > size, the vector is reallocated (only the pointers are copied, not the strings).
- Load() completely replaces the contents and reallocate the vector to exactly match the number of strings in the file (one string per line).
Member Enumeration Documentation
|
|
- Enumeration values:
-
| FORMAT_TXT |
(default) standard text file |
| FORMAT_PLMTXT |
PLM own text format. |
|
anonymous enum [inherited]
|
|
|
|
- Enumeration values:
-
| FORMAT_UNK |
unknown format (usually for load) |
| FORMAT_DEF |
default format (usually for save) |
|
Constructor & Destructor Documentation
| PLMText::PLMText |
( |
u32 |
size = 0 |
) |
|
|
|
|
Create a new array of strings.
Allocate size elements. |
| PLMText::PLMText |
( |
const char * |
filename, |
|
|
int |
format = PLMResource::FORMAT_UNK |
|
) |
|
|
|
|
Create a new array and load strings from filename.
|
| PLMText::PLMText |
( |
PLMResFile & |
f, |
|
|
int |
format = PLMResource::FORMAT_UNK |
|
) |
|
|
|
|
Create a new list and load strings from the resource file f.
|
Member Function Documentation
| u32 PLMText::Size |
( |
|
) |
[inline] |
|
|
|
Get the size of the list.
The size is the current number of allocated elements and not the number of strings (see Length()). Note: no string may have an index > Size(). |
|
|
Get the number of non-empty strings in the list.
This method checks the list to find non-NULL strings. Note: some strings may be at index >= Length() since any entry in the array can be NULL. |
| void PLMText::ChangeSize |
( |
u32 |
newsize |
) |
|
|
|
|
Change the size of the array.
Allocate a new array of newsize elements. If newsize is smaller than current size, the last strings are deleted. |
| char * PLMText::Get |
( |
u32 |
index |
) |
const [inline] |
|
|
|
Get the string at index index (NULL if index is too large). - See also:
-
operator[].
|
| char * PLMText::operator[] |
( |
u32 |
index |
) |
const [inline] |
|
|
|
Get the string at index index (NULL if index is too large). - See also:
-
Get().
|
| void PLMText::SetString |
( |
u32 |
index, |
|
|
const char * |
newstr, |
|
|
u32 |
start = 0, |
|
|
u32 |
nb = PLM::INDEX_ERROR |
|
) |
|
|
|
|
Replace one entry of the array by a new string.
- Parameters:
-
| index |
the index of the string to overwrite in the array. |
| newstr |
the string to copy (the array stores its own copy), if NULL, the existing string is deleted. |
| start |
the beginning of the text to copy from newstr. |
| nb |
the number of characters to copy from newstr, use PLM::INDEX_ERROR for all characters. |
|
| u32 PLMText::Append |
( |
const char * |
newstr, |
|
|
u32 |
start = 0, |
|
|
u32 |
nb = PLM::INDEX_ERROR |
|
) |
|
|
|
|
Add a string to the first index available (containing an empty string).
The array is reallocated if necessary to add the string at the end. You may consider calling ChangeSize() first, if you need to add several strings. See SetString() for details on parameters. - Returns:
-
the index where the string has been added, PLM::INDEX_ERROR on error.
|
|
|
Remove (and delete) all strings. Allocated size is not modified.
|
| virtual bool PLMText::Load |
( |
PLMResFile & |
src, |
|
|
int |
format = PLMResource::FORMAT_UNK |
|
) |
[virtual] |
|
|
|
Load strings from a file (usually a text file), one string for each line.
All existing strings are cleared, and the array is reallocated to exactly match the number of lines/strings in the file.
Implements PLMResource. |
| virtual bool PLMText::Save |
( |
PLMResFile & |
dest, |
|
|
int |
format = PLMResource::FORMAT_DEF |
|
) |
[virtual] |
|
|
|
Save current array of strings to a file (PLM private format or standard text format).
Each string is ended by a newline, NULL entries are saved as empty lines.
Implements PLMResource. |
| virtual u32 PLMText::MemoryUsed |
( |
|
) |
[virtual] |
|
|
|
Get the total amount of memory used by this resource.
Implements PLMResource. |
| void PLMText::PrintInfo |
( |
|
) |
|
|
|
|
Print some information on current log.
|
| virtual bool PLMResource::LoadName |
( |
const char * |
filename, |
|
|
int |
format = FORMAT_UNK |
|
) |
[virtual, inherited] |
|
|
|
Load data from the file filename.
Reimplemented in PLMMusic. |
| virtual bool PLMResource::SaveName |
( |
const char * |
filename, |
|
|
int |
format = FORMAT_DEF |
|
) |
[virtual, inherited] |
|
|
|
Save data to the file filename.
|
The documentation for this class was generated from the following file:
Generated by
Doxygen 1.2.18 on Tue Oct 26 12:07:39 2004.
|