Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sobj_scanf.c File Reference


Detailed Description

Functions for analyzing a simple object.

A simple object instance can be scanned using the sobj_scanf() function. The scan function scans the instance according to a format string. The format string is an immitation of the simple object text serialization syntax. Values to be retrieved are represented by format escapes similar to the escapes passed to the standard C library scanf() function. See module Object Scanning functions for details.

#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <unistd.h>
#include "sobject_p.h"

Include dependency graph for sobj_scanf.c:

Include dependency graph

Data Structures

struct  sobj_scanconv_field
 Structure representing a field specifier. More...
struct  sobj_scanconv_array
 Structure representing an array conversion specifier. More...
struct  sobj_scanconv
 Structure representing a conversion escape. More...

Functions

sobj_scanconv_arraynew_sobj_scanconv_array (void)
 Create a new array conversion specifier.
void delete_sobj_scanconv_array (struct sobj_scanconv_array *)
 Delete an array conversion specifier.
sobj_scanconv_fieldsobj_scanconv_array_append (struct sobj_scanconv_array *)
 Append a field to an array conversion.
void sobj_scanconv_array_append_index (struct sobj_scanconv_array *, int, bool)
 Append an index field to an array conversion.
void sobj_scanconv_array_append_key (struct sobj_scanconv_array *, struct sobj *)
 Append a key field to an array conversion.
void sobj_scanconv_array_set_conv (struct sobj_scanconv_array *, struct sobj_scanconv *)
 Set the conversion specifier object.
sobj_scanconvnew_sobj_scanconv (bool)
 Create a new conversion specifier object.
void delete_sobj_scanconv (struct sobj_scanconv *)
 Delete a conversion specifier.
sobj_scanconvsobj_scanf_parse_format (const char **, struct sobj_env *)
 Parse a conversion specifier format string.
int sobj_scanconv_vscanf (struct sobj *, struct sobj_env *, const struct sobj_scanconv *, va_list *)
 Internal function performing the object scan.
int sobj_scanf (struct sobj *sobj, struct sobj_env *env, const char *format,...)
 Scan an object according to a format string.
int sobj_vscanf (struct sobj *sobj, struct sobj_env *env, const char *format, va_list ap)
 Scan an object according to a format string.
int sobj_scanff (struct sobj *sobj, struct sobj_env *env, const char *format,...)
 Scan an object according to a format string.
int sobj_vscanff (struct sobj *sobj, struct sobj_env *env, const char *format, va_list ap)
 Scan an object according to a format string.

Function Documentation

void delete_sobj_scanconv struct sobj_scanconv scanconv  )  [static]
 

Delete a conversion specifier.

Parameters:
scanconv The conversion specifier to be deleted.

void delete_sobj_scanconv_array struct sobj_scanconv_array scanconv_array  )  [static]
 

Delete an array conversion specifier.

Parameters:
scanconv_array The array conversion specifier to be deleted.

struct sobj_scanconv * new_sobj_scanconv bool  array  )  [static]
 

Create a new conversion specifier object.

Parameters:
array Flag indicating if the conversion specifier represents an array conversion.
Returns:
The new (initialized) conversion specifier object.

struct sobj_scanconv_array * new_sobj_scanconv_array void   )  [static]
 

Create a new array conversion specifier.

Returns:
A new (empty) array conversion specifier.

struct sobj_scanconv_field * sobj_scanconv_array_append struct sobj_scanconv_array scanconv_array  )  [static]
 

Append a field to an array conversion.

Parameters:
scanconv_array The array conversion specifier.
Returns:
A pointer to the new field appended to the array conversion. The field is initialized to all zeros.

void sobj_scanconv_array_append_index struct sobj_scanconv_array scanconv_array,
int  index,
bool  key_ref
[static]
 

Append an index field to an array conversion.

Parameters:
scanconv_array The array conversion specifier.
index The index of the index field. This must be positive or zero.
key_ref Flag indicating if field references the element key.

void sobj_scanconv_array_append_key struct sobj_scanconv_array scanconv_array,
struct sobj key
[static]
 

Append a key field to an array conversion.

Parameters:
scanconv_array The array conversion specifier.
key The key of the key specifier.

void sobj_scanconv_array_set_conv struct sobj_scanconv_array scanconv_array,
struct sobj_scanconv scanconv
[static]
 

Set the conversion specifier object.

The function sets the conversion specifier object of a field specifier. The conversion specifier is set for the last field specifier appended to the array conversion specifier. It is a fatal runtime error if the list of fields is empty or if the conversion specifier of the last field has already been set.

Parameters:
scanconv_array The array conversion specifier.
scanconv The conversion specifier to be set for the last field of the array conversion specifier.

int sobj_scanconv_vscanf struct sobj sobj,
struct sobj_env env,
const struct sobj_scanconv scanconv,
va_list *  ap
[static]
 

Internal function performing the object scan.

Parameters:
sobj The object to be scanned. This may be a null-pointer (causing the conversion to fail).
env The environment. This may be a null-pointer.
scanconv The conversion specifier object.
ap Pointer to a variable argument list pointer.
Returns:
The function returns the number of objects converted. The function returns 0 if all conversions fail (e.g. if sobj is a null-pointer).
Note:
The variable arguments referenced by *ap are read from the stack according to the conversion specifier scanconv, even if the conversion fails.

struct sobj_scanconv * sobj_scanf_parse_format const char **  format,
struct sobj_env env
[static]
 

Parse a conversion specifier format string.

Parameters:
format Pointer to a pointer to the format string. On success, *format is set to the first character following the last parsed character (this may be the terminating null-character). On failure, the value of *format will be undefined.
env The environment. This may be a null-pointer.
Returns:
On success, a conversion specifier object representing the parsed conversion format string will be returned. On failure, a null-pointer is returned.


Generated on Sat Jul 23 16:05:31 2005 for sobject by  doxygen 1.3.9.1