MPLABĀ® Harmony Graphics Suite
legato_dynamicstring.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
28 #ifndef LEGATO_DYNAMICSTRING_H
29 #define LEGATO_DYNAMICSTRING_H
30 
32 
33 /* internal use only */
37 struct leDynamicString;
38 
39 #define LE_DYNAMICSTRING_VTABLE(THIS_TYPE) \
40  LE_STRING_VTABLE(THIS_TYPE) \
41  \
42  uint32_t (*getCapacity)(THIS_TYPE* str); \
43  leResult (*setCapacity)(THIS_TYPE* str, uint32_t cap); \
44 
45 typedef struct leDynamicStringVTable
46 {
47  LE_DYNAMICSTRING_VTABLE(struct leDynamicString)
48 } leDynamicStringVTable;
53 // *****************************************************************************
59 typedef struct leDynamicString
60 {
62  const leDynamicStringVTable* fn;
64  uint16_t capacity;
65  uint16_t length;
66  const leFont* font;
68 
69 // *****************************************************************************
83 
84 // *****************************************************************************
97 LIB_EXPORT void leDynamicString_Constructor(leDynamicString* str);
98 
99 
100 #ifdef _DOXYGEN_
101 #define THIS_TYPE struct leWidget
102 
103 // *****************************************************************************
114 virtual uint32_t getCapacity(leDynamicString* _this);
115 
116 // *****************************************************************************
130  uint32_t cap);
131 
132 #undef THIS_TYPE
133 #endif
134 
135 #endif /* LEGATO_DYNAMICSTRING_H */
leDynamicString::capacity
uint16_t capacity
Definition: legato_dynamicstring.h:64
getCharIndexAtPoint
virtual leResult getCharIndexAtPoint(const leString *_this, const lePoint *pt, uint32_t *idx)
Get character index at point.
setFromString
virtual leResult setFromString(leString *_this, const struct leString *src)
Set string value from another string.
getCapacity
virtual uint32_t getCapacity(leDynamicString *_this)
Get capacity of the dynamic string.
remove
virtual leResult remove(leString *_this, uint32_t idx, uint32_t count)
Remove substring.
leDynamicString::fn
const leDynamicStringVTable * fn
Definition: legato_dynamicstring.h:62
leDynamicString
This struct represents a dynamic string.
Definition: legato_dynamicstring.h:60
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leRect
This struct represents a rectangle.
Definition: legato_common.h:405
getLineIndices
virtual leResult getLineIndices(const leString *_this, uint32_t line, uint32_t *start, uint32_t *end)
Get indices of a string line.
leDynamicString::length
uint16_t length
Definition: legato_dynamicstring.h:65
legato_memory.h
Memory functions and definitions.
leHAlignment
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:206
getLineCount
uint32_t getLineCount(const leString *_this)
Get number of lines in the string.
preinvalidate
virtual void preinvalidate(leString *_this)
Raise pre-invalidate event.
leFont
This struct represents a font object.
Definition: legato_font.h:136
leStringVTable
Definition: legato_string.h:98
leString
This struct represents a string.
Definition: legato_string.h:108
setFromChar
virtual leResult setFromChar(leString *_this, const leChar *buf, uint32_t size)
Set string value from a leChar buffer.
charAt
virtual leChar charAt(const leString *_this, uint32_t idx)
Get codepoint at the given index.
setPreInvalidateCallback
virtual leResult setPreInvalidateCallback(leString *_this, leString_InvalidateCallback, void *userData)
Set string invalidate event.
leBool
leBool
This enum represents booleans.
Definition: legato_common.h:157
leDynamicString::data
leChar * data
Definition: legato_dynamicstring.h:63
setCapacity
virtual leResult setCapacity(leDynamicString *_this, uint32_t cap)
Set capacity of the dynamic string.
length
virtual uint32_t length(const leString *_this)
Get length of the string.
setFont
virtual leResult setFont(leString *_this, const leFont *font)
Set font.
insert
virtual leResult insert(leString *_this, const struct leString *val, uint32_t idx)
Insert string at a given index.
leDynamicString_Constructor
LIB_EXPORT void leDynamicString_Constructor(leDynamicString *str)
Consructs a dynamic string.
Definition: legato_dynamicstring.c:41
leDynamicString::base
leString base
Definition: legato_dynamicstring.h:61
legato_string.h
Fixed string functions and definitions.
legato_dynamicstring.h
Dynamic string functions and definitions.
compare
virtual int32_t compare(const leString *_this, const struct leString *tgt)
Compare string to another string.
leDynamicString_New
LIB_EXPORT leDynamicString * leDynamicString_New()
Create a new dynamic string.
Definition: legato_dynamicstring.c:56
leChar
uint16_t leChar
This typedef represents Legato character.
Definition: legato_common.h:424
toChar
virtual uint32_t toChar(const leString *_this, leChar *buf, uint32_t size)
Convert string to a C-style string.
getFont
virtual leFont * getFont(const leString *_this)
Get font.
isEmpty
virtual leBool isEmpty(const leString *_this)
Determine if string is empty.
append
virtual leResult append(leString *_this, const struct leString *val)
Append string.
clear
virtual void clear(leString *_this)
Clear string.
leString::fn
const leStringVTable * fn
Definition: legato_string.h:109
destructor
virtual void destructor(leString *_this)
Destruct string.
leDynamicString
struct leDynamicString leDynamicString
This struct represents a dynamic string.
setFromCStr
virtual leResult setFromCStr(leString *_this, const char *cstr)
Set string value from a C string buffer.
lePoint
This structure represents a integer Cartesian point.
Definition: legato_common.h:357
leDynamicString::font
const leFont * font
Definition: legato_dynamicstring.h:66