strobj.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __STRING_H__
00017 #define __STRING_H__
00018
00019
00029 #define USE_STRING_CACHE 1
00030
00031
00040 #define string_loadFromImg(ms, paddr, r_pstring) \
00041 string_create((ms), (paddr), (int16_t)-1, (int16_t)1, (r_pstring))
00042
00049 #define string_new(paddr, r_pstring) \
00050 string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), 0, (int16_t)1, (r_pstring))
00051
00060 #define string_newWithLen(paddr, len, r_pstring) \
00061 string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), (len), (int16_t)1, \
00062 (r_pstring))
00063
00071 #define string_replicate(paddr, n, r_pstring) \
00072 string_create(MEMSPACE_RAM, (paddr), (uint8_t)0, (n), (r_pstring))
00073
00074
00075
00076
00077
00083 typedef struct PmString_s
00084 {
00086 PmObjDesc_t od;
00087
00089 uint16_t length;
00090
00091 #if USE_STRING_CACHE
00092
00093 struct PmString_s *next;
00094 #endif
00095
00102 uint8_t val[1];
00103 } PmString_t,
00104 *pPmString_t;
00105
00106
00107
00108
00109
00110
00139 PmReturn_t string_create(PmMemSpace_t memspace, uint8_t const **paddr,
00140 int16_t len, int16_t n, pPmObj_t *r_pstring);
00141
00149 PmReturn_t string_newFromChar(uint8_t const c, pPmObj_t *r_pstring);
00150
00158 int8_t string_compare(pPmString_t pstr1, pPmString_t pstr2);
00159
00160 #ifdef HAVE_PRINT
00161
00170 PmReturn_t string_print(pPmObj_t pstr, uint8_t is_escaped);
00171 #endif
00172
00179 PmReturn_t string_cacheInit(void);
00180
00181
00183 PmReturn_t string_getCache(pPmString_t **r_ppstrcache);
00184
00194 PmReturn_t
00195 string_concat(pPmString_t pstr1, pPmString_t pstr2, pPmObj_t *r_pstring);
00196
00197 #ifdef HAVE_STRING_FORMAT
00198
00207 PmReturn_t string_format(pPmString_t pstr, pPmObj_t parg, pPmObj_t *r_pstring);
00208
00217 PmReturn_t string_printFormattedBytes(uint8_t *pb,
00218 uint8_t is_escaped,
00219 uint16_t n);
00220 #endif
00221
00222 #endif