 |
MPLABĀ® Harmony Graphics Suite
|
Fixed string functions and definitions.
More...
Go to the source code of this file.
|
#define | LE_STRING_VTABLE(THIS_TYPE) |
|
#define | THIS_TYPE struct leWidget |
|
|
LIB_EXPORT void | leString_Delete (leString *str) |
| Delete string. More...
|
|
virtual void | destructor (leString *_this) |
| Destruct string. More...
|
|
virtual leFont * | getFont (const leString *_this) |
| Get font. More...
|
|
virtual leResult | setFont (leString *_this, const leFont *font) |
| Set font. More...
|
|
virtual leResult | setFromString (leString *_this, const struct leString *src) |
| Set string value from another string. More...
|
|
virtual leResult | setFromChar (leString *_this, const leChar *buf, uint32_t size) |
| Set string value from a leChar buffer. More...
|
|
virtual leResult | setFromCStr (leString *_this, const char *cstr) |
| Set string value from a C string buffer. More...
|
|
virtual leChar | charAt (const leString *_this, uint32_t idx) |
| Get codepoint at the given index. More...
|
|
virtual uint32_t | length (const leString *_this) |
| Get length of the string. More...
|
|
virtual leBool | isEmpty (const leString *_this) |
| Determine if string is empty. More...
|
|
virtual int32_t | compare (const leString *_this, const struct leString *tgt) |
| Compare string to another string. More...
|
|
virtual leResult | append (leString *_this, const struct leString *val) |
| Append string. More...
|
|
virtual leResult | insert (leString *_this, const struct leString *val, uint32_t idx) |
| Insert string at a given index. More...
|
|
virtual leResult | remove (leString *_this, uint32_t idx, uint32_t count) |
| Remove substring. More...
|
|
virtual void | clear (leString *_this) |
| Clear string. More...
|
|
virtual uint32_t | toChar (const leString *_this, leChar *buf, uint32_t size) |
| Convert string to a C-style string. More...
|
|
virtual virtual leResult | getRect (const leString *_this, leRect *rect) |
| Get rectangle of the rendered string in pixels. More...
|
|
uint32_t | getLineCount (const leString *_this) |
| Get number of lines in the string. More...
|
|
virtual leResult | getLineRect (const leString *_this, uint32_t line, leRect *rect) |
| Get rectangle of a string line. More...
|
|
virtual leResult | getLineIndices (const leString *_this, uint32_t line, uint32_t *start, uint32_t *end) |
| Get indices of a string line. More...
|
|
virtual leResult | getCharRect (const leString *_this, uint32_t idx, leRect *rect) |
| Get rendered rectangle of a string codepoint. More...
|
|
virtual leResult | getCharIndexAtPoint (const leString *_this, const lePoint *pt, uint32_t *idx) |
| Get character index at point. More...
|
|
virtual leResult | _draw (const leString *_this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a) |
| Draw. More...
|
|
virtual void | preinvalidate (leString *_this) |
| Raise pre-invalidate event. More...
|
|
virtual void | invalidate (leString *_this) |
| Invalidate. More...
|
|
virtual leResult | setPreInvalidateCallback (leString *_this, leString_InvalidateCallback, void *userData) |
| Set string invalidate event. More...
|
|
virtual leResult | setInvalidateCallback (leString *_this, leString_InvalidateCallback cb, void *userData) |
| Set string invalidate event. More...
|
|
Fixed string functions and definitions.
This is a string library implementation that is used internally by the Legato user interface library.
This implementation relies on the leChar definition for characters. This chararcter definition is 16 bits in size and allows the library to support international character code points and Unicode encoding standards
◆ LE_STRING_VTABLE
#define LE_STRING_VTABLE |
( |
|
THIS_TYPE | ) |
|
Value:
leFont* (*getFont)(const THIS_TYPE* _this); \
leResult (*
setFromCStr)(THIS_TYPE* _this,
const char* cstr); \
leChar (*
charAt)(
const THIS_TYPE* _this, uint32_t idx); \
uint32_t (*
length)(
const THIS_TYPE* _this); \
leBool (*
isEmpty)(
const THIS_TYPE* _this); \
leResult (*
insert)(THIS_TYPE* _this,
const struct leString* val, uint32_t idx); \
leResult (*remove)(THIS_TYPE* _this, uint32_t idx, uint32_t count); \
void (*
clear)(THIS_TYPE* _this); \
uint32_t (*
toChar)(
const THIS_TYPE* _this,
leChar* buf, uint32_t size); \
leResult (*
getLineIndices)(
const THIS_TYPE* _this, uint32_t line, uint32_t* start, uint32_t* end); \
leResult (*
_draw)(
const THIS_TYPE* _this, int32_t x, int32_t y,
leHAlignment align, leColor clr, uint32_t a); \
◆ leString
This struct represents a string.
Generic string definition
◆ _draw()
Draw.
Draws string at location x and y with the specified align clr a.
uint32_t idx;
leResult res = str->fn->_draw(_this, x, y, align, clr, a);
- Parameters
-
str | is the string to examine. |
- Returns
- leResult.
◆ append()
Append string.
Appends a string val using _this.
- Parameters
-
_this | is the string to append to. |
val | is the string to append with. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ charAt()
Get codepoint at the given index.
Gets the codepoint at index using _this.
- Parameters
-
str | is the string to query. |
idx | is the location within the str. |
- Returns
- the leChar contained at the index or -1.
◆ clear()
Clear string.
Clears the contents of string using _this.
- Parameters
-
_this | is the string to append to. |
- Returns
- void.
◆ compare()
Compare string to another string.
Compares the string to tgt.
int32_t res = str->
fn->compare(str, tgt);
- Parameters
-
str | is the string to compare against. |
tgt | is the string to compare with. |
- Returns
- returns an integer indicating the result of the comparison. It returns 0, if both strings are the same.
◆ destructor()
virtual void destructor |
( |
leString * |
_this | ) |
|
|
virtual |
Destruct string.
Destruct the string _this.
str->
fn->destructor(str);
- Parameters
-
_this | is the string to destruct. |
- Returns
- void.
◆ getCharIndexAtPoint()
Get character index at point.
Gets a character idx at pt.
uint32_t idx;
leResult res = str->
fn->getCharIndexAtPoint(_this, pt, idx);
- Parameters
-
str | is the string to examine. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ getCharRect()
Get rendered rectangle of a string codepoint.
Gets the rendered rect of a char at index.
uint32_t idx;
leResult res = str->
fn->getCharRect(_this, idx, rect);
- Parameters
-
str | is the string to examine. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ getFont()
Get font.
Gets font using _this.
- Parameters
-
_this | is the string to query. |
- Returns
- the font assigned to the string.
◆ getLineCount()
uint32_t getLineCount |
( |
const leString * |
_this | ) |
|
Get number of lines in the string.
Gets the number of lines using _this.
uint32_t count = str->
fn->getLineCount(_this);
- Parameters
-
_this | is the string to examine. |
- Returns
- the number of lines in string.
◆ getLineIndices()
virtual leResult getLineIndices |
( |
const leString * |
_this, |
|
|
uint32_t |
line, |
|
|
uint32_t * |
start, |
|
|
uint32_t * |
end |
|
) |
| |
|
virtual |
Get indices of a string line.
Gets the indices of line from start to end.
uint32_t* start;
uint32_t* end;
leResult res = str->
fn->getLineIndices(_this, line, start, end);
- Parameters
-
_this | is the string to examine. |
line | the line to query |
start | the starting offset of the line in the string |
end | the ending offset of the line in the string |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ getLineRect()
Get rectangle of a string line.
Gets the rect of _this at line.
uint32_t line;
leResult res = str->
fn->getLineCount(_this, line, rect);
- Parameters
-
_this | is the string to examine. |
line | |
rect | |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ getRect()
Get rectangle of the rendered string in pixels.
Gets the rectangle of the rendered string to pixels rect using _this.
- Parameters
-
str | is the string to examine. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ insert()
Insert string at a given index.
Inserts a string val at idx using _this.
- Parameters
-
str | is the string to append to. |
val | is the string to append with. |
idx | is the string to append with. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ invalidate()
virtual void invalidate |
( |
leString * |
_this | ) |
|
|
virtual |
Invalidate.
Sets the pre invalidate callback to func with userData arguments.
str->
fn->setPreInvalidateCallback(_this, func, userData);
- Parameters
-
str | is the string to examine. |
func | is of type leString_InvalidateCallback. |
userData | is arguments to receive. |
- Returns
- leResult.
◆ isEmpty()
Determine if string is empty.
Checks if string is empty using _this.
- Parameters
-
_this | is the string to query. |
- Returns
- returns LE_TRUE if string is empty, otherwise LE_FALSE.
◆ length()
virtual uint32_t length |
( |
const leString * |
_this | ) |
|
|
virtual |
Get length of the string.
Gets length of string at idx using _this.
uint32_t idx;
uint32_t
length = str->
fn->charAt(_this, idx);
- Parameters
-
_this | is the string to query. |
idx | is the location within the str. |
- Returns
- length of the string.
◆ leString_Delete()
LIB_EXPORT void leString_Delete |
( |
leString * |
str | ) |
|
Delete string.
Deletes str. Frees the memory that was allocated using the la{TYPE}String_New type allocator functions
- See also
- leString_New().
- Parameters
-
str | is the string to delete. |
- Returns
- void.
◆ preinvalidate()
virtual void preinvalidate |
( |
leString * |
_this | ) |
|
|
virtual |
Raise pre-invalidate event.
Raises a pre-invalidate event for _this.
str->
fn->preinvalidate(_this);
- Parameters
-
str | is the string to examine. |
- Returns
- leResult.
◆ remove()
Remove substring.
Removes a substring at idx for up to count characters using _this.
uint32_t count;
leResult res = str->
fn->remove(_this, idx, count);
- Parameters
-
_this | is the string to append to. |
idx | is the string to append with. |
count | is the number of chars |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ setFont()
Set font.
Sets the font using _this to font.
- Parameters
-
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ setFromChar()
Set string value from a leChar buffer.
Sets the string value from buf using the first size bytes.
uint32_t size;
leResult res = str->
fn->setFromString(str, buf, size);
- Parameters
-
buf | is the string to set. |
size | is the number of chars to set. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ setFromCStr()
Set string value from a C string buffer.
Sets the string value from cstr.
const char* cstr;
leResult res = str->
fn->setFromString(_this, cstr);
- Parameters
-
cstr | is the string to set. |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ setFromString()
Set string value from another string.
Sets the string value from src.
leResult res =_this->
fn->setFromString(_this, src);
- Parameters
-
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ setInvalidateCallback()
virtual leResult setInvalidateCallback |
( |
leString * |
_this, |
|
|
leString_InvalidateCallback |
cb, |
|
|
void * |
userData |
|
) |
| |
|
virtual |
Set string invalidate event.
Sets the string invalidate event to cb using _this with userData.
leString_InvalidateCallback cb;
leResult res = _this->
fn->setInvalidateCallback(_this, cb, userData);
- Parameters
-
_this | is the string to modify |
cb | is the callback func |
is | the user data pointer to pass to the callback |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ setPreInvalidateCallback()
virtual leResult setPreInvalidateCallback |
( |
leString * |
_this, |
|
|
leString_InvalidateCallback |
, |
|
|
void * |
userData |
|
) |
| |
|
virtual |
Set string invalidate event.
Sets the string invalidate event to cb using _this with userData.
leString_InvalidateCallback cb;
leResult res = _this->
fn->setPreInvalidateCallback(_this, cb, userData);
- Parameters
-
_this | is the string to modify |
cb | is the callback func |
is | the user data pointer to pass to the callback |
- Returns
- LE_SUCCESS if set, otherwise LE_FAILURE.
◆ toChar()
virtual uint32_t toChar |
( |
const leString * |
_this, |
|
|
leChar * |
buf, |
|
|
uint32_t |
size |
|
) |
| |
|
virtual |
Convert string to a C-style string.
Converts the string to buf for up to size characters using _this.
uint32_t size;
uint32_t nbr = str->
fn->toChar(_this, buf, size);
- Parameters
-
_this | is the string to convert. |
buf | is the new string. |
size | is the number of chars to convert. |
- Returns
- the number of leChar written to the buffer.
virtual leResult getCharIndexAtPoint(const leString *_this, const lePoint *pt, uint32_t *idx)
Get character index at point.
virtual leResult setFromString(leString *_this, const struct leString *src)
Set string value from another string.
virtual virtual leResult getRect(const leString *_this, leRect *rect)
Get rectangle of the rendered string in pixels.
leResult
This enum represents function call results.
Definition: legato_common.h:134
virtual leResult setInvalidateCallback(leString *_this, leString_InvalidateCallback cb, void *userData)
Set string invalidate event.
This struct represents a rectangle.
Definition: legato_common.h:405
virtual leResult getLineIndices(const leString *_this, uint32_t line, uint32_t *start, uint32_t *end)
Get indices of a string line.
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:206
uint32_t getLineCount(const leString *_this)
Get number of lines in the string.
virtual void preinvalidate(leString *_this)
Raise pre-invalidate event.
virtual void invalidate(leString *_this)
Invalidate.
virtual leResult _draw(const leString *_this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a)
Draw.
This struct represents a font object.
Definition: legato_font.h:136
virtual leResult getCharRect(const leString *_this, uint32_t idx, leRect *rect)
Get rendered rectangle of a string codepoint.
This struct represents a string.
Definition: legato_string.h:108
virtual leResult setFromChar(leString *_this, const leChar *buf, uint32_t size)
Set string value from a leChar buffer.
virtual leChar charAt(const leString *_this, uint32_t idx)
Get codepoint at the given index.
virtual leResult setPreInvalidateCallback(leString *_this, leString_InvalidateCallback, void *userData)
Set string invalidate event.
leBool
This enum represents booleans.
Definition: legato_common.h:157
virtual uint32_t length(const leString *_this)
Get length of the string.
virtual leResult setFont(leString *_this, const leFont *font)
Set font.
virtual leResult insert(leString *_this, const struct leString *val, uint32_t idx)
Insert string at a given index.
LIB_EXPORT void leString_Delete(leString *str)
Delete string.
virtual int32_t compare(const leString *_this, const struct leString *tgt)
Compare string to another string.
virtual leResult getLineRect(const leString *_this, uint32_t line, leRect *rect)
Get rectangle of a string line.
uint16_t leChar
This typedef represents Legato character.
Definition: legato_common.h:424
virtual uint32_t toChar(const leString *_this, leChar *buf, uint32_t size)
Convert string to a C-style string.
virtual leBool isEmpty(const leString *_this)
Determine if string is empty.
virtual leResult append(leString *_this, const struct leString *val)
Append string.
virtual void clear(leString *_this)
Clear string.
const leStringVTable * fn
Definition: legato_string.h:109
virtual void destructor(leString *_this)
Destruct string.
virtual leResult setFromCStr(leString *_this, const char *cstr)
Set string value from a C string buffer.
This structure represents a integer Cartesian point.
Definition: legato_common.h:357