Main Page | Modules | Data Structures | Directories | File List | Data Fields

String


Defines

#define u_string_sprintf(s,)   u_string_do_printf(s, 1, __VA_ARGS__ )
 Set the string from sprintf-style arguments.
#define u_string_aprintf(s,)   u_string_do_printf(s, 0, __VA_ARGS__ )
 Append a printf-style format string to the given string.
#define u_string_ncat(s, buf, len)   u_string_append(s, buf, len)
 Append at most len characterss to a string.
#define u_string_cat(s, buf)   u_string_append(s, buf, strlen(buf))
 Append a char* to a string.

Functions

int u_string_trim (u_string_t *s)
 Remove leading and trailing blanks.
int u_string_set_length (u_string_t *s, size_t len)
 Set the length of a string (shortening it).
size_t u_string_len (u_string_t *s)
 Return the string length.
const char * u_string_c (u_string_t *s)
 Return the string value.
int u_string_copy (u_string_t *dst, u_string_t *src)
 Copy the value of a string to another.
int u_string_clear (u_string_t *s)
 Clear a string.
int u_string_create (const char *buf, size_t len, u_string_t **ps)
 Create a new string.
int u_string_free (u_string_t *s)
 Free a string.
int u_string_set (u_string_t *s, const char *buf, size_t len)
 Set the value of a string.
int u_string_reserve (u_string_t *s, size_t size)
 Enlarge the underlying memory block of the given buffer.
int u_string_do_printf (u_string_t *s, int clear, const char *fmt,...)
int u_string_append (u_string_t *s, const char *buf, size_t len)
 Append a char* to a string.

Define Documentation

#define u_string_aprintf  )     u_string_do_printf(s, 0, __VA_ARGS__ )
 

Append a printf-style format string to the given string.

Parameters:
s string object
fmt printf-style format
... variable list of arguments
Returns:
0 on success, not zero on failure

#define u_string_cat s,
buf   )     u_string_append(s, buf, strlen(buf))
 

Append a char* value to the given string.

Parameters:
s string object
buf the value that will be appended to s
Returns:
0 on success, not zero on failure

#define u_string_ncat s,
buf,
len   )     u_string_append(s, buf, len)
 

Append a char* value to the given string.

Parameters:
s string object
buf the value that will be appended to s
len length of buf
Returns:
0 on success, not zero on failure

#define u_string_sprintf  )     u_string_do_printf(s, 1, __VA_ARGS__ )
 

Set a string from the sprintf-style arguments

Parameters:
s string object
fmt printf-style format
... variable list of arguments
Returns:
0 on success, not zero on failure


Function Documentation

int u_string_append u_string_t *  s,
const char *  buf,
size_t  len
 

Append a char* value to the given string.

Parameters:
s string object
buf the value that will be appended to s
len length of buf
Returns:
0 on success, not zero on failure

Definition at line 307 of file str.c.

References u_string_reserve().

Referenced by u_hmap_dbg(), u_hmap_pcy_dbg(), u_string_copy(), u_string_create(), and u_string_set().

const char* u_string_c u_string_t *  s  )  [inline]
 

Return the const char* value of the given string object. Such const char* value cannot be modified, realloc'd or free'd.

Parameters:
s string object
Returns:
the string value or NULL if the string is empty

Definition at line 101 of file str.c.

Referenced by u_hmap_dbg(), and u_hmap_pcy_dbg().

int u_string_clear u_string_t *  s  ) 
 

Totally erase the content of the given string.

Parameters:
s string object
Returns:
0 on success, not zero on failure

Definition at line 131 of file str.c.

Referenced by u_hmap_dbg(), u_hmap_pcy_dbg(), u_string_copy(), u_string_do_printf(), and u_string_set().

int u_string_copy u_string_t *  dst,
u_string_t *  src
[inline]
 

Copy src string to dst string.

Parameters:
dst destination string
src source string
Returns:
0 on success, not zero on failure

Definition at line 116 of file str.c.

References u_string_append(), and u_string_clear().

int u_string_create const char *  buf,
size_t  len,
u_string_t **  ps
 

Create a new string object and save its pointer to *ps.

If buf is not NULL (and len > 0) the string will be initialized with the content of buf.

Parameters:
buf initial string value
len length of buf
ps on success will get the new string object
Returns:
0 on success, not zero on failure

Definition at line 157 of file str.c.

References u_string_append(), and u_zalloc().

Referenced by u_hmap_dbg(), and u_hmap_pcy_dbg().

int u_string_free u_string_t *  s  ) 
 

Release all resources and free the given string object.

Parameters:
s string object
Returns:
0 on success, not zero on failure

Definition at line 186 of file str.c.

Referenced by u_hmap_dbg(), and u_hmap_pcy_dbg().

size_t u_string_len u_string_t *  s  )  [inline]
 

Return the length of the given string.

Parameters:
s string object
Returns:
the string length

Definition at line 86 of file str.c.

Referenced by u_hmap_dbg().

int u_string_reserve u_string_t *  s,
size_t  size
 

Enlarge the buffer data block to (at least) size bytes.

Parameters:
s string object
size requested size
Returns:
0 on success, not zero on failure

Definition at line 225 of file str.c.

References u_realloc().

Referenced by u_string_append(), and u_string_do_printf().

int u_string_set u_string_t *  s,
const char *  buf,
size_t  len
 

Set the value of s to buf.

Parameters:
s string object
buf the value that will be copied to s
len length of buf
Returns:
0 on success, not zero on failure

Definition at line 209 of file str.c.

References u_string_append(), and u_string_clear().

int u_string_set_length u_string_t *  s,
size_t  len
 

Parameters:
s string object
len on success s will be len chars long
Returns:
0 on success, not zero on failure

Definition at line 62 of file str.c.

int u_string_trim u_string_t *  s  ) 
 

Remove leading and trailing blanks from the given string

Parameters:
s string object
Returns:
0 on success, not zero on failure

Definition at line 41 of file str.c.

References u_trim().


←Products
© 2005-2007 - KoanLogic S.r.l. - All rights reserved