MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_tablestring.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 
30 #ifndef LEGATO_TABLESTRING_H
31 #define LEGATO_TABLESTRING_H
32 
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define LE_STRING_NULLIDX -1
40 
41 /* internal use only */
46 struct leTableString;
47 
48 #define LE_TABLESTRING_VTABLE(THIS_TYPE) \
49  LE_STRING_VTABLE(THIS_TYPE) \
50  \
51  uint32_t (*getID)(const THIS_TYPE* _this); \
52  leResult (*setID)(THIS_TYPE* _this, uint32_t id); \
53  uint32_t (*sizeInBytes)(const THIS_TYPE* _this); \
54 
55 typedef struct leTableStringVTable
56 {
57  LE_TABLESTRING_VTABLE(struct leTableString)
58 } leTableStringVTable;
59 
64 // *****************************************************************************
65 /* Structure:
66  leTableString
67 
68  Summary:
69  String type that references an entry in a string table. Read only.
70 
71  Remarks:
72  None.
73 */
79 typedef struct leTableString
80 {
81  leString base;
82 
83  const leTableStringVTable* fn;
84 
85  int32_t index; // an index into a string table or LE_STRING_NULLIDX
87 
88 // *****************************************************************************
89 /* Function:
90  leTableString* leTableString_New(uint32_t idx)
91 
92  Summary:
93  Allocates memory and constructs a new table string
94 
95  Parameters:
96  idx - the table index to reference
97 
98  Returns:
99  leTableString* - pointer to the newly allocated string
100 
101  Remarks:
102  Caller is responsible for freeing the memory allocated by this function
103  using leString_Delete()
104 */
116 leTableString* leTableString_New(uint32_t idx);
117 
118 // *****************************************************************************
119 /* Function:
120  void leTableString_New(leTableString* str, uint32_t idx)
121 
122  Summary:
123  Constructs a new table string at the given pointer
124 
125  Parameters:
126  idx - the table index to reference
127 
128  Returns:
129 
130  Remarks:
131  It is assumed that the pointer provided is being managed by the caller. Use
132  leString_PDelete() to properly destruct this pointer.
133 */
158  uint32_t idx);
159 
160 
161 #ifdef _DOXYGEN_
162 #define THIS_TYPE struct leWidget
163 
164 // *****************************************************************************
175 virtual uint32_t getID(const leTableString* _this);
176 
177 
178 // *****************************************************************************
190 virtual leResult setID(leTableString* this,
191  uint32_t id);
192 
193 
194 // *****************************************************************************
205 virtual uint32_t sizeInBytes(const leTableString* this);
206 
207 
208 #undef THIS_TYPE
209 #endif
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 #endif /* LEGATO_TABLESTRING_H */
This struct represents a table string.
Definition: legato_tablestring.h:79
This struct represents a string.
Definition: legato_string.h:107
leResult
This enum represents function call results.
Definition: legato_common.h:123
struct leTableString leTableString
This struct represents a table string.
void leTableString_Constructor(leTableString *str, uint32_t idx)
Constructs a new table string.
Definition: legato_tablestring.c:43
virtual leResult setID(leTableString *this, uint32_t id)
Set string table ID.
virtual uint32_t sizeInBytes(const leTableString *this)
Get size of this string in bytes.
virtual uint32_t getID(const leTableString *_this)
Get id.
Fixed string functions and definitions.
leTableString * leTableString_New(uint32_t idx)
Constructs a new table string.
Definition: legato_tablestring.c:65