strobj.h File Reference

String Object Type. More...

Go to the source code of this file.

Classes

struct  PmString_s

Defines

#define USE_STRING_CACHE   1
#define string_loadFromImg(ms, paddr, r_pstring)   string_create((ms), (paddr), (int16_t)-1, (int16_t)1, (r_pstring))
#define string_new(paddr, r_pstring)   string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), 0, (int16_t)1, (r_pstring))
#define string_newWithLen(paddr, len, r_pstring)
#define string_replicate(paddr, n, r_pstring)   string_create(MEMSPACE_RAM, (paddr), (uint8_t)0, (n), (r_pstring))

Typedefs

typedef struct PmString_s PmString_t
typedef struct PmString_spPmString_t

Functions

PmReturn_t string_create (PmMemSpace_t memspace, uint8_t const **paddr, int16_t len, int16_t n, pPmObj_t *r_pstring)
PmReturn_t string_newFromChar (uint8_t const c, pPmObj_t *r_pstring)
int8_t string_compare (pPmString_t, pPmString_t)
PmReturn_t string_cacheInit (void)
PmReturn_t string_getCache (pPmString_t **r_ppstrcache)
PmReturn_t string_concat (pPmString_t pstr1, pPmString_t pstr2, pPmObj_t *r_pstring)


Detailed Description

String Object Type.

String object type header.


Define Documentation

#define string_loadFromImg ( ms,
paddr,
r_pstring   )     string_create((ms), (paddr), (int16_t)-1, (int16_t)1, (r_pstring))

Load string from image

Parameters:
ms memoryspace paddr points to
paddr address in memoryspace of source string

#define string_new ( paddr,
r_pstring   )     string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), 0, (int16_t)1, (r_pstring))

Creates String object from character array in RAM

Parameters:
paddr pointer to address of source string
r_pstring Return arg; addr of ptr to string

#define string_newWithLen ( paddr,
len,
r_pstring   ) 

Value:

string_create(MEMSPACE_RAM, (uint8_t const **)(paddr), (len), (int16_t)1, \
                  (r_pstring))
Creates String object from character array in RAM which may contain embedded null characters.

Parameters:
paddr pointer to address of source string
len length of source string
r_pstring Return arg; addr of ptr to string

#define string_replicate ( paddr,
n,
r_pstring   )     string_create(MEMSPACE_RAM, (paddr), (uint8_t)0, (n), (r_pstring))

Creates String object by replicating an existing C string, n times

Parameters:
paddr pointer to address of source string
n number of times to replicate the source string
r_pstring Return arg; addr of ptr to string

#define USE_STRING_CACHE   1

Set to nonzero to enable string cache. DO NOT REMOVE THE DEFINITION.


Typedef Documentation

typedef struct PmString_s PmString_t

String obj

Null terminated array of chars.


Function Documentation

PmReturn_t string_cacheInit ( void   ) 

Clears the string cache if one exists. Called by heap_init()

Returns:
Return status

int8_t string_compare ( pPmString_t  ,
pPmString_t   
)

Compares two String objects for equality.

Parameters:
pstr1 Ptr to first string
pstr2 Ptr to second string
Returns:
C_SAME if the strings are equivalent, C_DIFFER otherwise

PmReturn_t string_concat ( pPmString_t  pstr1,
pPmString_t  pstr2,
pPmObj_t r_pstring 
)

Returns a new string object that is the concatenation of the two given strings.

Parameters:
pstr1 First source string
pstr2 Second source string
r_pstring Return arg; ptr to new string object
Returns:
Return status

PmReturn_t string_create ( PmMemSpace_t  memspace,
uint8_t const **  paddr,
int16_t  len,
int16_t  n,
pPmObj_t r_pstring 
)

Creates a new String obj. If len is less than zero, load from a String image. If len is zero, copy from a C string (which has a null terminator) If len is positive, copy as many chars as given in the len argument A string image has the following structure: -type: int8 - OBJ_TYPE_STRING -length: uint16 - number of bytes in the string -val: uint8[] - array of chars with null term

Returns by reference a ptr to String obj.

Obtain space for String from the heap. Copy string from memspace. Leave contents of paddr pointing one byte past end of str.

THE PROGRAMMER SHOULD NOT CALL THIS FUNCTION DIRECTLY. Instead, use one of the two macros string_loadFromImg() or string_new().

Parameters:
memspace memory space where *paddr points
paddr ptr to ptr to null term character array or image.
len length of the C character array (use -1 for string images, 0 for C strings)
Return arg; ptr to String obj
Returns:
Return status

PmReturn_t string_getCache ( pPmString_t **  r_ppstrcache  ) 

Returns a pointer to the base of the string cache

PmReturn_t string_newFromChar ( uint8_t const   c,
pPmObj_t r_pstring 
)

Creates a new String object from a single character.

Parameters:
c the character to become the string
r_psting Return arg; ptr to String obj
Returns:
Return status


Generated on Wed Feb 24 13:37:03 2010 for Python-on-a-chip by  doxygen 1.5.9