Modules | Functions

Stringbuffer, A class for manipulating strings with dynamic buffers

Modules

 Create/Destroy StrBufs
 Cast operators to interact with char based code
 Create/Replace/Append Content into a StrBuf
 Fast tokenizer to pull tokens in sequence
 tokenizer Functions; Slow ones.
 Buffered IO with Asynchroneous reads and no unneeded memmoves (the fast ones)
 FileIO; Prefer @ref StrBuf_BufferedIO
 functions to translate the contents of a buffer

Functions

long StrTol (const StrBuf *Buf)
 Wrapper around atol.
int StrToi (const StrBuf *Buf)
 Wrapper around atoi.
int StrBufIsNumber (const StrBuf *Buf)
 Checks to see if the string is a pure number.
int StrBufSub (StrBuf *dest, const StrBuf *Source, unsigned long Offset, size_t nChars)
 extracts a substring from Source into dest
void StrBufCutLeft (StrBuf *Buf, int nChars)
 Cut nChars from the start of the string.
void StrBufCutRight (StrBuf *Buf, int nChars)
 Cut the trailing n Chars from the string.
void StrBufCutAt (StrBuf *Buf, int AfternChars, const char *At)
 Cut the string after n Chars.
void StrBufTrim (StrBuf *Buf)
 Strip leading and trailing spaces from a string; with premeasured and adjusted length.
void StrBufReplaceChars (StrBuf *buf, char search, char replace)
 replaces all occurances of 'search' by 'replace'
void StrBufToUnixLF (StrBuf *buf)
 removes all s from the string, or replaces them with
if its not a combination of both.
long StrBuf_Utf8StrLen (StrBuf *Buf)
 measure the number of glyphs in an UTF8 string...
long StrBuf_Utf8StrCut (StrBuf *Buf, int maxlen)
 cuts a string after maxlen glyphs

Detailed Description

StrBuf is a versatile class, aiding the handling of dynamic strings * reduce de/reallocations * reduce the need to remeasure it * reduce scanning over the string (in Tokenizers) * allow asyncroneous IO for line and Blob based operations * reduce the use of memove in those * Quick filling in several operations with append functions


Function Documentation

long StrBuf_Utf8StrCut ( StrBuf Buf,
int  maxlen 
)

cuts a string after maxlen glyphs

Parameters:
Buf string to cut to maxlen glyphs
maxlen how long may the string become?
Returns:
current length of the string
long StrBuf_Utf8StrLen ( StrBuf Buf  ) 

measure the number of glyphs in an UTF8 string...

Parameters:
Buf string to measure
Returns:
the number of glyphs in Buf
void StrBufCutAt ( StrBuf Buf,
int  AfternChars,
const char *  At 
)

Cut the string after n Chars.

Parameters:
Buf Buffer to modify
AfternChars after how many chars should we trunkate the string?
At if non-null and points inside of our string, cut it there.
void StrBufCutLeft ( StrBuf Buf,
int  nChars 
)

Cut nChars from the start of the string.

Parameters:
Buf Buffer to modify
nChars how many chars should be skipped?
void StrBufCutRight ( StrBuf Buf,
int  nChars 
)

Cut the trailing n Chars from the string.

Parameters:
Buf Buffer to modify
nChars how many chars should be trunkated?
int StrBufIsNumber ( const StrBuf Buf  ) 

Checks to see if the string is a pure number.

Parameters:
Buf The buffer to inspect
Returns:
1 if its a pure number, 0, if not.
void StrBufReplaceChars ( StrBuf buf,
char  search,
char  replace 
)

replaces all occurances of 'search' by 'replace'

Parameters:
buf Buffer to modify
search character to search
replace character to replace search by
int StrBufSub ( StrBuf dest,
const StrBuf Source,
unsigned long  Offset,
size_t  nChars 
)

extracts a substring from Source into dest

Parameters:
dest buffer to place substring into
Source string to copy substring from
Offset chars to skip from start
nChars number of chars to copy
Returns:
the number of chars copied; may be different from nChars due to the size of Source
void StrBufToUnixLF ( StrBuf buf  ) 

removes all s from the string, or replaces them with
if its not a combination of both.

Parameters:
buf Buffer to modify
void StrBufTrim ( StrBuf Buf  ) 

Strip leading and trailing spaces from a string; with premeasured and adjusted length.

Parameters:
Buf the string to modify
 All Classes Variables