Genivia - Miscellaneous functions

|  | Home | Documentation | Miscellaneous functions updated Mon Apr 22 2024 by Robert van Engelen |

- Main Page
- Modules
- Classes
- Files

Functions
Miscellaneous functions

This module defines other useful functions. More...

## Functions
void | soap_begin (struct soap *soap)
| Reset context. More...
const char * | soap_rand_uuid (struct soap *soap, const char *prefix)
| Returns a randomized unique UUID string. More...
int | soap_tag_cmp (const char *string, const char *pattern)
| Compare string to a pattern. More...
int | soap_match_tag (struct soap *soap, const char *tag1, const char *tag2)
| Match an XML tag name. More...

## Detailed Description

This module defines other useful functions.

## Function Documentation

void soap_begin | ( | struct soap * | soap | ) |

Reset context.

This function resets the context to start serialization with the `serialize` functions. Alternatively, `soap_begin_send` can be used before calling the `serialize` functions, but this is sometimes not possible so this function can be used instead.

Example:

struct soap *soap = soap_new1(SOAP_XML_GRAPH);
... // further initializations
struct ns__someElement elt;
... // populate elt
soap_begin(soap); // reset context before calling serialize functions
soap_serialize_ns__someElement(soap, &elt); // analyze pointers for multi-ref serialization

See also
  `soap_begin_send`.

Parameters

  soap | `soap` context

int soap_match_tag | ( | struct soap * | soap,
|  | const char * | tag1,
|  | const char * | tag2
| ) |  |

Match an XML tag name.

This function returns `SOAP_OK` when the two specified XML tag names match. The first tag name is a qualified or unqualified parsed tag name when the parser is pulling XML tags. The second tag name is an unqualified or namespace-normalized qualified tag name or pattern to match. A namespace-normalized qualified tag name uses a prefix defined in the `namespaces` table. A pattern consists of two types of wildcard meta-characters: `*` matches any text of any length and `-` matches any single character. Returns `SOAP_OK` when the tags are matching or `SOAP_TAG_MISMATCH` when the tags are non-matching.

Warning
  This function should only be used while the XML parser is actively parsing input, for example in the `soap::fignore` callback.

Returns
  `SOAP_OK` (match) or `SOAP_TAG_MISMATCH` (no match)

Parameters

  soap | `soap` context
  tag1 | parsed (un)qualified tag name string to match
  tag2 | (namespace-normalized qualified) tag name string or pattern to match

const char* soap_rand_uuid | ( | struct soap * | soap,
|  | const char * | prefix
| ) |  |

Returns a randomized unique UUID string.

This function returns a randomized unique UUID string stored in a temporary buffer. The UUID string starts with the specified prefix if non-NULL.

Example:

struct soap *soap = soap_new();
const char *uuid = soap_strdup(soap, soap_rand_uuid(soap, NULL));
...

Returns
  randomized UUID string stored in a temporary buffer

Parameters

  soap | `soap` context
  prefix | prefix string or NULL

int soap_tag_cmp | ( | const char * | string,
|  | const char * | pattern
| ) |  |

Compare string to a pattern.

This function returns zero when the specified string matches the given pattern, nonzero otherwise. A pattern consists of two types of wildcard meta-characters: `*` matches any text of any length and `-` matches any single character. This function is commonly used to match XML tags and XML namespace URIs, such as the URI pattern in the third column of the `namespaces` table.

Returns
  zero (match) or nonzero (no match)

Parameters

  string | string to match
  pattern | pattern to match