querybuf.h File Reference

Implementation of an efficient string buffer for composing database queries. More...

#include <dballe/core/error.h>

Go to the source code of this file.

Typedefs

typedef struct _dba_querybuf * dba_querybuf
 Efficient string buffer for composing database queries.

Functions

dba_err dba_querybuf_create (int maxsize, dba_querybuf *buf)
 Create a query buffer.
void dba_querybuf_delete (dba_querybuf buf)
 Delete a dba_querybuf.
void dba_querybuf_reset (dba_querybuf buf)
 Reset the querybuf to contain the empty string.
const char * dba_querybuf_get (dba_querybuf buf)
 Get the string created so far.
int dba_querybuf_size (dba_querybuf buf)
 Get the size of the string created so far.
dba_err dba_querybuf_start_list (dba_querybuf buf, const char *sep)
 Begin a list of items separated by the given separator.
dba_err dba_querybuf_append (dba_querybuf buf, const char *str)
 Append a string to the querybuf.
dba_err dba_querybuf_appendf (dba_querybuf buf, const char *fmt,...)
 Append a formatted string to the querybuf.
dba_err dba_querybuf_append_list (dba_querybuf buf, const char *str)
 Append a string to the querybuf, as part of a list.


Detailed Description

Implementation of an efficient string buffer for composing database queries.


Function Documentation

dba_err dba_querybuf_append ( dba_querybuf  buf,
const char *  str 
)

Append a string to the querybuf.

Parameters:
buf The buffer to operate on
str The string to append
Returns:
The error indicator for the function (See error.h)

References dba_error_consistency.

dba_err dba_querybuf_append_list ( dba_querybuf  buf,
const char *  str 
)

Append a string to the querybuf, as part of a list.

This function will prepend str with the current list separator, unless it is the first item added to the list.

Parameters:
buf The buffer to operate on
str The string to append
Returns:
The error indicator for the function (See error.h)

References DBA_RUN_OR_RETURN.

dba_err dba_querybuf_appendf ( dba_querybuf  buf,
const char *  fmt,
  ... 
)

Append a formatted string to the querybuf.

Parameters:
buf The buffer to operate on
fmt The string to append, which will be formatted in printf style
Returns:
The error indicator for the function (See error.h)

References dba_error_consistency.

dba_err dba_querybuf_create ( int  maxsize,
dba_querybuf buf 
)

Create a query buffer.

Parameters:
maxsize The maximum size of the query string. Since dba_querybuf does not do dynamic resize of the buffer, it needs the maximum size specified upfront
Return values:
buf The query buffer
Returns:
The error indicator for the function (See error.h)

References dba_error_consistency.

void dba_querybuf_delete ( dba_querybuf  buf  ) 

Delete a dba_querybuf.

Parameters:
buf The querybuf to delete

const char* dba_querybuf_get ( dba_querybuf  buf  ) 

Get the string created so far.

Parameters:
buf The buffer to operate on
Returns:
A pointer to the string created so far with the querybuf

void dba_querybuf_reset ( dba_querybuf  buf  ) 

Reset the querybuf to contain the empty string.

Parameters:
buf The buffer to operate on

int dba_querybuf_size ( dba_querybuf  buf  ) 

Get the size of the string created so far.

Parameters:
buf The buffer to operate on
Returns:
The length of the string created so far with the querybuf, not including the trailing null character

dba_err dba_querybuf_start_list ( dba_querybuf  buf,
const char *  sep 
)

Begin a list of items separated by the given separator.

Items are added using dba_querybuf_append_list().

Parameters:
buf The buffer to operate on
sep The separator to add between every list item
Returns:
The error indicator for the function (See error.h)


Generated on Wed Mar 11 09:52:07 2009 for libdballe by  doxygen 1.5.8