libxml2
Loading...
Searching...
No Matches
dict.h File Reference

string dictionary More...

Typedefs

typedef struct _xmlDict xmlDict
 Dictionary (pool for interned strings)

Functions

int xmlInitializeDict (void)
xmlDictxmlDictCreate (void)
 Create a new dictionary.
size_t xmlDictSetLimit (xmlDict *dict, size_t limit)
 Set a size limit for the dictionary Added in 2.9.0.
size_t xmlDictGetUsage (xmlDict *dict)
 Get how much memory is used by a dictionary for strings Added in 2.9.0.
xmlDictxmlDictCreateSub (xmlDict *sub)
 Create a new dictionary, inheriting strings from the read-only dictionary sub.
int xmlDictReference (xmlDict *dict)
 Increment the reference counter of a dictionary.
void xmlDictFree (xmlDict *dict)
 Free the hash dict and its contents.
const xmlCharxmlDictLookup (xmlDict *dict, const xmlChar *name, int len)
 Lookup a string and add it to the dictionary if it wasn't found.
const xmlCharxmlDictExists (xmlDict *dict, const xmlChar *name, int len)
 Check if a string exists in the dictionary.
const xmlCharxmlDictQLookup (xmlDict *dict, const xmlChar *prefix, const xmlChar *name)
 Lookup the QName prefix:name and add it to the dictionary if it wasn't found.
int xmlDictOwns (xmlDict *dict, const xmlChar *str)
 check if a string is owned by the dictionary
int xmlDictSize (xmlDict *dict)
 Query the number of elements installed in the hash dict.
void xmlDictCleanup (void)

Detailed Description

string dictionary

dictionary of reusable strings, just used to avoid allocation and freeing operations.

Author
Daniel Veillard

Function Documentation

◆ xmlDictCleanup()

void xmlDictCleanup ( void )
Deprecated
This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

◆ xmlDictCreate()

xmlDict * xmlDictCreate ( void )

Create a new dictionary.

Returns
the newly created dictionary, or NULL if an error occurred.

◆ xmlDictCreateSub()

xmlDict * xmlDictCreateSub ( xmlDict * sub)

Create a new dictionary, inheriting strings from the read-only dictionary sub.

On lookup, strings are first searched in the new dictionary, then in sub, and if not found are created in the new dictionary.

Parameters
suban existing dictionary
Returns
the newly created dictionary, or NULL if an error occurred.

◆ xmlDictExists()

const xmlChar * xmlDictExists ( xmlDict * dict,
const xmlChar * name,
int len )

Check if a string exists in the dictionary.

Parameters
dictthe dictionary
namethe name of the userdata
lenthe length of the name, if -1 it is recomputed
Returns
the internal copy of the name or NULL if not found.

◆ xmlDictFree()

void xmlDictFree ( xmlDict * dict)

Free the hash dict and its contents.

The userdata is deallocated with f if provided.

Parameters
dictthe dictionary

◆ xmlDictGetUsage()

size_t xmlDictGetUsage ( xmlDict * dict)

Get how much memory is used by a dictionary for strings Added in 2.9.0.

Parameters
dictthe dictionary
Returns
the amount of strings allocated

◆ xmlDictLookup()

const xmlChar * xmlDictLookup ( xmlDict * dict,
const xmlChar * name,
int len )

Lookup a string and add it to the dictionary if it wasn't found.

Parameters
dictdictionary
namestring key
lenlength of the key, if -1 it is recomputed
Returns
the interned copy of the string or NULL if a memory allocation failed.

◆ xmlDictOwns()

int xmlDictOwns ( xmlDict * dict,
const xmlChar * str )

check if a string is owned by the dictionary

Parameters
dictthe dictionary
strthe string
Returns
1 if true, 0 if false and -1 in case of error -1 in case of error

◆ xmlDictQLookup()

const xmlChar * xmlDictQLookup ( xmlDict * dict,
const xmlChar * prefix,
const xmlChar * name )

Lookup the QName prefix:name and add it to the dictionary if it wasn't found.

Parameters
dictthe dictionary
prefixthe prefix
namethe name
Returns
the interned copy of the string or NULL if a memory allocation failed.

◆ xmlDictReference()

int xmlDictReference ( xmlDict * dict)

Increment the reference counter of a dictionary.

Parameters
dictthe dictionary
Returns
0 in case of success and -1 in case of error

◆ xmlDictSetLimit()

size_t xmlDictSetLimit ( xmlDict * dict,
size_t limit )

Set a size limit for the dictionary Added in 2.9.0.

Parameters
dictthe dictionary
limitthe limit in bytes
Returns
the previous limit of the dictionary or 0

◆ xmlDictSize()

int xmlDictSize ( xmlDict * dict)

Query the number of elements installed in the hash dict.

Parameters
dictthe dictionary
Returns
the number of elements in the dictionary or -1 in case of error

◆ xmlInitializeDict()

int xmlInitializeDict ( void )
Deprecated
Alias for xmlInitParser.
Returns
0.