Boron 0.1.0

Datatype String
[Urlan Datatype System]

Strings are stored using the single word per character Latin-1 and UCS-2 encodings (UR_ENC_LATIN1/UR_ENC_UCS2). More...

Defines

#define ur_cstr(strC, bin)   ur_cstring(ur_bufferSer(strC), bin, strC->series.it, strC->series.end)
 Make null terminated UTF-8 string in binary buffer.
#define ur_strFree   ur_arrFree
 A string is a simple array.

Functions

UIndex ur_makeString (UThread *ut, int enc, int size)
 Generate and initialize a single string buffer.
UBufferur_makeStringCell (UThread *ut, int enc, int size, UCell *cell)
 Generate a single string and set cell to reference it.
UIndex ur_makeStringUtf8 (UThread *ut, const uint8_t *it, const uint8_t *end)
 Generate and initialize a single string buffer from memory holding a UTF-8 string.
void ur_strInit (UBuffer *buf, int enc, int size)
 Initialize buffer to type UT_STRING.
void ur_strAppendChar (UBuffer *str, int uc)
 Append a single UCS2 character to a string.
void ur_strAppendCStr (UBuffer *str, const char *cstr)
 Append a null-terminated ASCII string to a string buffer.
void ur_strAppendInt (UBuffer *str, int32_t n)
 Append an integer to a string.
void ur_strAppendInt64 (UBuffer *str, int64_t n)
 Append an 64-bit integer to a string.
void ur_strAppendHex (UBuffer *str, uint32_t n, uint32_t hi)
 Append a hexidecimal integer to a string.
void ur_strAppendDouble (UBuffer *str, double n)
 Append a double to a string.
void ur_strAppendIndent (UBuffer *str, int depth)
 Append tabs to a string.
void ur_strAppend (UBuffer *str, const UBuffer *strB, UIndex itB, UIndex endB)
 Append another string buffer to this string.
void ur_strTermNull (UBuffer *str)
 Terminate with null character so buffer can be used as a C string.
int ur_strIsAscii (const UBuffer *str)
 Test if all characters are ASCII.
void ur_strFlatten (UBuffer *str)
 Convert a UTF-8 or UCS-2 string buffer to Latin-1 if possible.
void ur_strLowercase (UBuffer *buf, UIndex start, UIndex send)
 Convert characters of string slice to lowercase.
void ur_strUppercase (UBuffer *buf, UIndex start, UIndex send)
 Convert characters of string slice to uppercase.
int ur_charLowercase (int c)
 Convert UCS2 character to lowercase.
int ur_charUppercase (int c)
 Convert UCS2 character to uppercase.
UIndex ur_strFindChar (const UBuffer *str, UIndex start, UIndex end, int ch)
 Find the first instance of a character in a string.
UIndex ur_strFindChars (const UBuffer *str, UIndex start, UIndex end, uint8_t *charSet, int len)
 Find the first character of a set in a string.
UIndex ur_strFind (const USeriesIter *ai, const USeriesIter *bi, int matchCase)
 Find string in another string.
UIndex ur_strMatch (const USeriesIter *ai, const USeriesIter *bi, int matchCase)
 Compare characters in two strings.
int ur_strChar (const UBuffer *str, UIndex pos)
 Return the character at a given position.
char * ur_cstring (const UBuffer *str, UBuffer *bin, UIndex start, UIndex end)
 Make null terminated UTF-8 string in binary buffer.

Detailed Description

Strings are stored using the single word per character Latin-1 and UCS-2 encodings (UR_ENC_LATIN1/UR_ENC_UCS2).

UTF-8 (UR_ENC_UTF8) is only handled by ur_strAppend() and ur_makeStringUtf8() in order to bring UTF-8 strings into or out of the datatype system.


Define Documentation

#define ur_cstr ( strC,
bin   )     ur_cstring(ur_bufferSer(strC), bin, strC->series.it, strC->series.end)

Make null terminated UTF-8 string in binary buffer.

This calls ur_cstring().

Parameters:
strC Valid UT_STRING or UT_FILE cell.
bin Initialized binary buffer to use.


Function Documentation

char* ur_cstring ( const UBuffer str,
UBuffer bin,
UIndex  start,
UIndex  end 
)

Make null terminated UTF-8 string in binary buffer.

Parameters:
str Valid string buffer.
bin Initialized binary buffer. The contents are replaced with the C string.
start Start position in str.
end End position in str. A negative number is the same as str->used.
Returns:
Pointer to C string in bin.

UIndex ur_makeString ( UThread ut,
int  enc,
int  size 
)

Generate and initialize a single string buffer.

If you need multiple buffers then ur_genBuffers() should be used.

The caller must create a UCell for this string in a held block before the next ur_recycle() or else it will be garbage collected.

Parameters:
enc Encoding type.
size Number of characters to reserve.
Returns:
Buffer id of string.

UBuffer* ur_makeStringCell ( UThread ut,
int  enc,
int  size,
UCell cell 
)

Generate a single string and set cell to reference it.

If you need multiple buffers then ur_genBuffers() should be used.

Parameters:
enc Encoding type.
size Number of characters to reserve.
cell Cell to initialize.
Returns:
Pointer to string buffer.

UIndex ur_makeStringUtf8 ( UThread ut,
const uint8_t *  it,
const uint8_t *  end 
)

Generate and initialize a single string buffer from memory holding a UTF-8 string.

This calls ur_makeString() internally.

Parameters:
it Start of UTF-8 data.
end End of UTF-8 data.
Returns:
Buffer id of string.

void ur_strAppend ( UBuffer str,
const UBuffer strB,
UIndex  itB,
UIndex  endB 
)

Append another string buffer to this string.

Parameters:
str Destination string.
strB String to append.
itB Start character of strB.
endB End character of strB.

void ur_strAppendIndent ( UBuffer str,
int  depth 
)

Append tabs to a string.

Parameters:
depth Number of tabs to append.

int ur_strChar ( const UBuffer str,
UIndex  pos 
)

Return the character at a given position.

If the str->form is UR_ENC_UTF8, then the return value will be the byte at pos, not the UCS2 character.

Parameters:
str Valid string buffer.
pos Character index. Pass negative numbers to index from the end (e.g. -1 will return the last character).
Returns:
UCS2 value or -1 if pos is out of range.

UIndex ur_strFind ( const USeriesIter *  ai,
const USeriesIter *  bi,
int  matchCase 
)

Find string in another string.

Parameters:
ai String to search.
bi Pattern to look for.
matchCase If non-zero, compare character cases.
Returns:
Index of pattern in string or -1 if not found.

UIndex ur_strFindChar ( const UBuffer str,
UIndex  start,
UIndex  end,
int  ch 
)

Find the first instance of a character in a string.

Parameters:
str Valid string buffer.
start Start index in str.
end Ending index in str.
ch Bitset of characters to look for.
Returns:
First index where character is found or -1 if not found.

UIndex ur_strFindChars ( const UBuffer str,
UIndex  start,
UIndex  end,
uint8_t *  charSet,
int  len 
)

Find the first character of a set in a string.

Parameters:
str Valid string buffer.
start Start index in str.
end Ending index in str.
charSet Bitset of characters to look for.
len Byte length of charSet.
Returns:
First index where any characters in charSet are found or -1 if none are found.

void ur_strFlatten ( UBuffer str  ) 

Convert a UTF-8 or UCS-2 string buffer to Latin-1 if possible.

Parameters:
str Valid string buffer.

void ur_strInit ( UBuffer buf,
int  enc,
int  size 
)

Initialize buffer to type UT_STRING.

Parameters:
enc Encoding type.
size Number of characters to reserve.
Examples:
calculator.c.

int ur_strIsAscii ( const UBuffer str  ) 

Test if all characters are ASCII.

Parameters:
str Valid string buffer.
Returns:
Non-zero if all characters are ASCII.

void ur_strLowercase ( UBuffer buf,
UIndex  start,
UIndex  send 
)

Convert characters of string slice to lowercase.

Parameters:
buf Pointer to valid string buffer.
start Start position.
send Slice end position.

UIndex ur_strMatch ( const USeriesIter *  ai,
const USeriesIter *  bi,
int  matchCase 
)

Compare characters in two strings.

Parameters:
ai String slice A.
bi String slice B.
matchCase If non-zero, compare character cases.
Returns:
Number of characters which match in strings.

void ur_strTermNull ( UBuffer str  ) 

Terminate with null character so buffer can be used as a C string.

Str->used is not changed.

Examples:
calculator.c.

void ur_strUppercase ( UBuffer buf,
UIndex  start,
UIndex  send 
)

Convert characters of string slice to uppercase.

Parameters:
buf Pointer to valid string buffer.
start Start position.
send Slice end position.


Generated on 27 Jan 2012 by Doxygen 1.5.1