Description | String management |
Header file | LString.h |
Author | Camil Demetrescu |
Created | Dec 19, 2001 |
Last updated | Sep 25, 2003 |
Constants |
|
LString_ID |
Types |
|
LString |
Functions |
|
i1* LString_Clone (const i1* inStr) void LString_Copy (const i1* inStr, i1* outStr) void LString_Append (const i1* inStr, i1* thruStr) ui4 LString_Len (const i1* inStr) i1 LString_Compare (const i1* inStr1, const i1* inStr2) void LString_Format (i1* outStr, const i1* inFormatStr, ...) i1* LString_Tokenizer (i1* inLine, const i1* inSeparators) i4 LString_ToI4 (const i1* inStr) ui4 LString_ToUI4 (const i1* inStr) f8 LString_ToF8 (const i1* inStr) void LString_PToXP (i1** thruText, ui4* thruSize) void LString_XPToP (i1** thruText, ui4* thruSize) |
Function | Arguments | Description | Returns | Throws | ||||||||||||||||||
Clone | const i1* inStr | Creates a copy of C string inStr. Caller is responsible of dellocating the created memory block using LMemory_Free. |
i1* pointer to a newly created string |
- | ||||||||||||||||||
Copy
|
const i1* inStr | Copies C string inStr into outStr. | - | - | ||||||||||||||||||
i1* outStr | ||||||||||||||||||||||
Append | const i1* inStr | Appends C string inStr to C string thruStr. | - | - | ||||||||||||||||||
i1* thruStr | ||||||||||||||||||||||
Len | const i1* inStr | Computes the length of C string inStr. |
ui4 Number of characters in C string inStr (zero-terminator is excluded) |
- | ||||||||||||||||||
Compare | const i1* inStr1 | Compares inStr1 with inStr2. |
i1 Zero if strings are equal, positive if inStr1 is greater than inStr2. according to the lexicographic order. Negative otherwise. |
- | ||||||||||||||||||
const i1* inStr2 | ||||||||||||||||||||||
Format | i1* outStr | Writes a formatted output as a
string to buffer outStr.Wrapper for the sprintf C function.
We recommend using the following specifiers:
Example: i1 theBuf[256]; ui4 theCode = 27; i1 theChannel = 'k'; LString_Format(theBuf,"Opening stream %lu at channel %c\n", theCode, theChannel); LDebug_Print(theBuf); |
- | - | ||||||||||||||||||
const i1* inFormatStr | ||||||||||||||||||||||
... | ||||||||||||||||||||||
Tokenizer |
i1* inLine |
Decomposes inLine in substrings (tokens) separated by characters in inSeparators. In the first call to Tokenizer, inLine must contain the string to be tokenized. In successive calls, let inLine be NULL. Notice that the buffer pointed to inLine by is modified by Tokenizer. Example: i1* theLine = "the quick brown fox"; i1* theToken = LString_Tokenizer(theLine, " "); while (theToken!=NULL) { LDebug_Print("token: %s\n", theToken); theToken = LString_Tokenizer(NULL, " "); }produces the following output: token: the token: quick token: brown token: fox |
i1* Pointer to the current token, or NULL if no more tokens can be extracted from inLine. |
|||||||||||||||||||
const i1* inSeparators | ||||||||||||||||||||||
ToI4 | const i1* inStr | Converts string inStr to an i4 value (as performed by the strtol C standard function) |
i4 Converted number |
- | ||||||||||||||||||
ToUI4 | const i1* inStr | Converts string inStr to an ui4 value (as performed by the strtoul C standard function) |
ui4 Converted number |
- | ||||||||||||||||||
ToF8 | const i1* inStr | Converts string inStr to an f8 value (as performed by the strtod C standard function) |
f8 Converted number |
- | ||||||||||||||||||
PToXP |
i1** thruText |
Converts the text buffer pointed to by *thruText of size *thruSize from a platform-dependent newline format (i.e., CR, LF, CR+LF, depending on the target operating system) to the LF-based (UNIX) format (used as a standard cross-platform format in the LL). This function is useful, e.g., when loading a text file that has to be processed by the program. | - | - | ||||||||||||||||||
ui4* thruSize | ||||||||||||||||||||||
XPToP |
i1** thruText |
Converts the text buffer pointed to by *thruText of size *thruSize from the LF-based (UNIX) newline format (used as a standard cross-platform format in the LL) to the platform-dependent newline format (i.e., CR, LF, CR+LF, depending on the target operating system). This function is useful, e.g., when saving a text file that has been processed by the program. | - | - | ||||||||||||||||||
ui4* thruSize |