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

Object Scanning Functions
[Simple Objects C API]


Detailed Description

Functions for scanning values from structured objects.

A simple object instance can be scanned using the sobj_scanf() or sobj_vscanf() 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.

Conversion Escapes

The following conversion escape sequences are recognized:
Sequence Argument type Description
%b bool * An object of type bool.
%i int * An object of type int. The object is converted to a C integer.
%li long * An object of type int. The object is converted to a C integer of type long.
%lli long long * An object of type int. The object is converted to a C integer of type long long.
%f, %g, %e float * An object of type float. The object is converted to a C integer of type float.
%lf, %lg, %le double * An object of type float. The object is converted to a C integer of type double.
%*s size_t, char * An object of type string. The object is converted using the sobj_to_string() function. The size_t argument specifies the size of the buffer receiving the string.
%s char ** An object of type string. The object is converted using the sobj_to_string() function. The resulting string is allocated from the heap an assigned to the pointer received as an argument. The caller is responsible for freeing the storage by calling sobj_free() on the returned string.
%O struct sobj ** An arbitrary object. A borrowed reference to the object is assigned to the pointer received as an argument.

Conversion String Syntax

A conversion string is one of the following:

An array conversion matches a simple object of type array. An array conversion is a comma and/or whitespace separated list of field conversion escapes, enclosed in brackets. A field conversion escape has the form:
field-specifier = conversion-escape

A field specifier is one of the following:


Functions

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

int sobj_scanf struct sobj sobj,
struct sobj_env env,
const char *  format,
  ...
 

Scan an object according to a format string.

The function analyzes the specified format string and scans the specified object accordingly. Subobjects matching a conversion specifier are assigned to the conversion arguments passed through the variable arguments. The format string syntax is defined above.

Parameters:
sobj The object to be scanned.
env The environment. This may be a null-pointer.
format The conversion format string.
... The variable arguments as specified in the conversion format string.
Returns:
The function returns the number of objects converted. The function returns 0 if all conversions fail.
Note:
All variable arguments are read from the stack according to the conversion specifier scanconv, even if some of the the conversions fails.

int sobj_scanff struct sobj sobj,
struct sobj_env env,
const char *  format,
  ...
 

Scan an object according to a format string.

This is a variant of the sobj_scanf() function. The specified format string is run through sprintf() first. Conversion escapes have to be double-escaped (i.e. %% instead of %.

Parameters:
sobj The object to be scanned.
env The environment. This may be a null-pointer.
format The format string defining the conversion format string.
... Variable arguments as specified in the format string and in the resulting conversion format string. The sprintf() arguments are expected first.
Returns:
The function returns the number of objects converted. The function returns 0 if all conversions fail.
Note:
All variable arguments are read from the stack according to the conversion specifier scanconv, even if some of the the conversions fails.

int sobj_vscanf struct sobj sobj,
struct sobj_env env,
const char *  format,
va_list  ap
 

Scan an object according to a format string.

The function analyzes the specified format string and scans the specified object accordingly. Subobjects matching a conversion specifier are assigned to the conversion arguments passed through the variable arguments. The format string syntax is defined above.

This is the va_list variant of the sobj_scanf() function.

Parameters:
sobj The object to be scanned.
env The environment. This may be a null-pointer.
format The conversion format string.
ap Pointer to the variable arguments as specified in the conversion format string.
Returns:
The function returns the number of objects converted. The function returns 0 if all conversions fail.
Note:
All variable arguments are read from the stack according to the conversion specifier scanconv, even if some of the the conversions fails.

int sobj_vscanff struct sobj sobj,
struct sobj_env env,
const char *  format,
va_list  ap
 

Scan an object according to a format string.

This is a variant of the sobj_scanf() function. The specified format string is run through sprintf() first. Conversion escapes have to be double-escaped (i.e. %% instead of %.

This is the va_list variant of the sobj_scanff() function.

Parameters:
sobj The object to be scanned.
env The environment. This may be a null-pointer.
format The format string defining the conversion format string.
ap Pointer to the variable arguments as specified in the format string and the resulting conversion format string. The sprintf() arguments are expected first.
Returns:
The function returns the number of objects converted. The function returns 0 if all conversions fail.
Note:
All variable arguments are read from the stack according to the conversion specifier scanconv, even if some of the the conversions fails.


Generated on Sat Jul 23 16:07:33 2005 for sobject by  doxygen 1.3.9.1