MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_string.h File Reference

Fixed string functions and definitions. More...

Include dependency graph for legato_string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  leStringVTable
 
struct  leString
 This struct represents a string. More...
 

Macros

#define LE_STRING_VTABLE(THIS_TYPE)
 
#define THIS_TYPE   struct leWidget
 

Typedefs

typedef void(* leString_InvalidateCallback) (const struct leString *str, void *userData)
 
typedef struct leStringVTable leStringVTable
 
typedef struct leString leString
 This struct represents a string. More...
 

Functions

void leString_Delete (leString *str)
 Delete string. More...
 
virtual void destructor (leString *_this)
 Destruct string. More...
 
virtual leFontgetFont (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...
 

Detailed Description

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

Macro Definition Documentation

◆ LE_STRING_VTABLE

#define LE_STRING_VTABLE (   THIS_TYPE)
Value:
void (*destructor)(THIS_TYPE* _this); \
leFont* (*getFont)(const THIS_TYPE* _this); \
leResult (*setFont)(THIS_TYPE* _this, const leFont* font); \
leResult (*setFromString)(THIS_TYPE* _this, const struct leString* src); \
leResult (*setFromChar)(THIS_TYPE* _this, const leChar* buf, uint32_t size); \
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); \
int32_t (*compare)(const THIS_TYPE* _this, const struct leString* tgt); \
leResult (*append)(THIS_TYPE* _this, const struct leString* val); \
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 (*getRect)(const THIS_TYPE* _this, leRect* rect); \
uint32_t (*getLineCount)(const THIS_TYPE* _this); \
leResult (*getLineRect)(const THIS_TYPE* _this, uint32_t line, leRect* rect); \
leResult (*getLineIndices)(const THIS_TYPE* _this, uint32_t line, uint32_t* start, uint32_t* end); \
leResult (*getCharRect)(const THIS_TYPE* _this, uint32_t idx, leRect* rect); \
leResult (*getCharIndexAtPoint)(const THIS_TYPE* _this, const lePoint* pt, uint32_t* idx); \
leResult (*_draw)(const THIS_TYPE* _this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a); \
void (*preinvalidate)(THIS_TYPE* _this); \
void (*invalidate)(THIS_TYPE* _this); \
leResult (*setPreInvalidateCallback)(THIS_TYPE* _this, leString_InvalidateCallback, void* userData); \
leResult (*setInvalidateCallback)(THIS_TYPE* _this, leString_InvalidateCallback, void* userData); \
virtual uint32_t length(const leString *_this)
Get length of the string.
virtual int32_t compare(const leString *_this, const struct leString *tgt)
Compare string to another string.
virtual leResult insert(leString *_this, const struct leString *val, uint32_t idx)
Insert string at a given index.
virtual leBool isEmpty(const leString *_this)
Determine if string is empty.
This struct represents a string.
Definition: legato_string.h:107
virtual leResult getCharRect(const leString *_this, uint32_t idx, leRect *rect)
Get rendered rectangle of a string codepoint.
virtual leResult setFont(leString *_this, const leFont *font)
Set font.
virtual leResult append(leString *_this, const struct leString *val)
Append string.
This struct represents a font object.
Definition: legato_font.h:156
virtual uint32_t toChar(const leString *_this, leChar *buf, uint32_t size)
Convert string to a C-style string.
virtual void preinvalidate(leString *_this)
Raise pre-invalidate event.
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.
This struct represents a rectangle.
Definition: legato_common.h:394
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:195
virtual void invalidate(leString *_this)
Invalidate.
virtual leResult getLineRect(const leString *_this, uint32_t line, leRect *rect)
Get rectangle of a string line.
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:346
virtual void clear(leString *_this)
Clear string.
virtual leResult setInvalidateCallback(leString *_this, leString_InvalidateCallback cb, void *userData)
Set string invalidate event.
virtual leResult getCharIndexAtPoint(const leString *_this, const lePoint *pt, uint32_t *idx)
Get character index at point.
uint16_t leChar
This typedef represents Legato character.
Definition: legato_common.h:414
virtual leResult setPreInvalidateCallback(leString *_this, leString_InvalidateCallback, void *userData)
Set string invalidate event.
virtual leResult _draw(const leString *_this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a)
Draw.
virtual leResult getLineIndices(const leString *_this, uint32_t line, uint32_t *start, uint32_t *end)
Get indices of a string line.
virtual leChar charAt(const leString *_this, uint32_t idx)
Get codepoint at the given index.
virtual void destructor(leString *_this)
Destruct string.
virtual leResult setFromChar(leString *_this, const leChar *buf, uint32_t size)
Set string value from a leChar buffer.
uint32_t getLineCount(const leString *_this)
Get number of lines in the string.

Typedef Documentation

◆ leString

typedef struct leString leString

This struct represents a string.

Generic string definition

Function Documentation

◆ _draw()

virtual leResult _draw ( const leString _this,
int32_t  x,
int32_t  y,
leHAlignment  align,
leColor  clr,
uint32_t  a 
)
virtual

Draw.

Draws string at location x and y with the specified align clr a.

leString* _this;
uint32_t idx;
lePoint* pt;
leResult res = str->fn->_draw(_this, x, y, align, clr, a);
Parameters
stris the string to examine.
Returns
leResult.

◆ append()

virtual leResult append ( leString _this,
const struct leString val 
)
virtual

Append string.

Appends a string val using _this.

leString* _this;
leString* val;
leResult res = str->fn->append(_this, val);
Parameters
_thisis the string to append to.
valis the string to append with.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ charAt()

virtual leChar charAt ( const leString _this,
uint32_t  idx 
)
virtual

Get codepoint at the given index.

Gets the codepoint at index using _this.

leString* str;
uint32_t idx;
leChar chr = str->fn->charAt(str, idx);
Parameters
stris the string to query.
idxis the location within the str.
Returns
the leChar contained at the index or -1.

◆ clear()

virtual void clear ( leString _this)
virtual

Clear string.

Clears the contents of string using _this.

leString* _this;
leString* val;
str->fn->clear(_this);
Parameters
_thisis the string to append to.
Returns
void.

◆ compare()

virtual int32_t compare ( const leString _this,
const struct leString tgt 
)
virtual

Compare string to another string.

Compares the string to tgt.

leString* _this;
const struct leString* tgt;
int32_t res = str->fn->compare(str, tgt);
Parameters
stris the string to compare against.
tgtis 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.

leString* _this;
str->fn->destructor(str);
Parameters
_thisis the string to destruct.
Returns
void.

◆ getCharIndexAtPoint()

virtual leResult getCharIndexAtPoint ( const leString _this,
const lePoint pt,
uint32_t *  idx 
)
virtual

Get character index at point.

Gets a character idx at pt.

leString* _this;
uint32_t idx;
lePoint* pt;
leResult res = str->fn->getCharIndexAtPoint(_this, pt, idx);
Parameters
stris the string to examine.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ getCharRect()

virtual leResult getCharRect ( const leString _this,
uint32_t  idx,
leRect rect 
)
virtual

Get rendered rectangle of a string codepoint.

Gets the rendered rect of a char at index.

leString* _this;
uint32_t idx;
leRect* rect;
leResult res = str->fn->getCharRect(_this, idx, rect);
Parameters
stris the string to examine.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ getFont()

virtual leFont* getFont ( const leString _this)
virtual

Get font.

Gets font using _this.

leString* _this;
str->fn->getFont(_this);
Parameters
_thisis 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.

leString* _this;
uint32_t count = str->fn->getLineCount(_this);
Parameters
_thisis 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.

leString* _this;
uint32_t* start;
uint32_t* end;
leResult res = str->fn->getLineIndices(_this, line, start, end);
Parameters
_thisis the string to examine.
linethe line to query
startthe starting offset of the line in the string
endthe ending offset of the line in the string
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ getLineRect()

virtual leResult getLineRect ( const leString _this,
uint32_t  line,
leRect rect 
)
virtual

Get rectangle of a string line.

Gets the rect of _this at line.

uint32_t line;
leRect* rect;
leResult res = str->fn->getLineCount(_this, line, rect);
Parameters
_thisis the string to examine.
line
rect
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ getRect()

virtual virtual leResult getRect ( const leString _this,
leRect rect 
)
virtual

Get rectangle of the rendered string in pixels.

Gets the rectangle of the rendered string to pixels rect using _this.

leString* str;
leRect* rect;
leResult res = str->fn->getRect(str, rect);
Parameters
stris the string to examine.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ insert()

virtual leResult insert ( leString _this,
const struct leString val,
uint32_t  idx 
)
virtual

Insert string at a given index.

Inserts a string val at idx using _this.

leString* _this;
leString* val;
uint32_t idx;
leResult res = str->fn->append(_this, val, idx);
Parameters
stris the string to append to.
valis the string to append with.
idxis 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.

leString* _this;
str->fn->setPreInvalidateCallback(_this, func, userData);
Parameters
stris the string to examine.
funcis of type leString_InvalidateCallback.
userDatais arguments to receive.
Returns
leResult.

◆ isEmpty()

virtual leBool isEmpty ( const leString _this)
virtual

Determine if string is empty.

Checks if string is empty using _this.

leString* _this;
leBool empty = str->fn->isEmpty(_this);
Parameters
_thisis 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.

leString* _this;
uint32_t idx;
uint32_t length = str->fn->charAt(_this, idx);
Parameters
_thisis the string to query.
idxis the location within the str.
Returns
length of the string.

◆ leString_Delete()

void leString_Delete ( leString str)

Delete string.

Deletes str. Frees the memory that was allocated using the la{TYPE}String_New type allocator functions. This function is used to delete all string-type objects that were allocated with their class-specific new functions.

See also
leString_New().
Parameters
stris the string to delete.
Returns
void.

◆ preinvalidate()

virtual void preinvalidate ( leString _this)
virtual

Raise pre-invalidate event.

Raises a pre-invalidate event for _this.

leString* _this;
str->fn->preinvalidate(_this);
Parameters
stris the string to examine.
Returns
leResult.

◆ remove()

virtual leResult remove ( leString _this,
uint32_t  idx,
uint32_t  count 
)
virtual

Remove substring.

Removes a substring at idx for up to count characters using _this.

leString* _this;
leString* idx;
uint32_t count;
leResult res = str->fn->remove(_this, idx, count);
Parameters
_thisis the string to append to.
idxis the string to append with.
countis the number of chars
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ setFont()

virtual leResult setFont ( leString _this,
const leFont font 
)
virtual

Set font.

Sets the font using _this to font.

leString* _this;
leResult res = _this->fn->setFont(font);
Parameters
fontis the font to set.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ setFromChar()

virtual leResult setFromChar ( leString _this,
const leChar buf,
uint32_t  size 
)
virtual

Set string value from a leChar buffer.

Sets the string value from buf using the first size bytes.

leString* _this;
leChar* buf;
uint32_t size;
leResult res = str->fn->setFromString(str, buf, size);
Parameters
bufis the string to set.
sizeis the number of chars to set.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ setFromCStr()

virtual leResult setFromCStr ( leString _this,
const char *  cstr 
)
virtual

Set string value from a C string buffer.

Sets the string value from cstr.

leString* _this;
const char* cstr;
leResult res = str->fn->setFromString(_this, cstr);
Parameters
cstris the string to set.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ setFromString()

virtual leResult setFromString ( leString _this,
const struct leString src 
)
virtual

Set string value from another string.

Sets the string value from src.

leString* _this;
struct leString* src;
leResult res =_this->fn->setFromString(_this, src);
Parameters
srcis the string to set.
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* _this;
leString_InvalidateCallback cb;
leResult res = _this->fn->setInvalidateCallback(_this, cb, userData);
Parameters
_thisis the string to modify
cbis the callback func
isthe 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* _this;
leString_InvalidateCallback cb;
leResult res = _this->fn->setPreInvalidateCallback(_this, cb, userData);
Parameters
_thisis the string to modify
cbis the callback func
isthe 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.

const leString* _this;
leChar* buf;
uint32_t size;
uint32_t nbr = str->fn->toChar(_this, buf, size);
Parameters
_thisis the string to convert.
bufis the new string.
sizeis the number of chars to convert.
Returns
the number of leChar written to the buffer.