15.3 Quarks

Most uses of the resource manager involve defining names, classes, and representation types as string constants. However, always referring to strings in the resource manager can be slow, because it is so heavily used in some toolkits. To solve this problem, a shorthand for a string is used in place of the string in many of the resource manager functions. Simple comparisons can be performed rather than string comparisons. The shorthand name for a string is called a quark and is the type XrmQuark . On some occasions, you may want to allocate a quark that has no string equivalent.

A quark is to a string what an atom is to a string in the server, but its use is entirely local to your application.

To allocate a new quark, use XrmUniqueQuark().

Each name, class, and representation type is typedef'd as an XrmQuark.

typedef int XrmQuark, *XrmQuarkList;
typedef XrmQuark XrmName;
typedef XrmQuark XrmClass;
typedef XrmQuark XrmRepresentation;
#define NULLQUARK ((XrmQuark) 0)

Lists are represented as null-terminated arrays of quarks. The size of the array must be large enough for the number of components used.

typedef XrmQuarkList XrmNameList;
typedef XrmQuarkList XrmClassList;

To convert a string to a quark, use XrmStringToQuark() or XrmPermStringToQuark().

To convert a quark to a string, use XrmQuarkToString().

To convert a string with one or more components to a quark list, use XrmStringToQuarkList().

A binding list is a list of type XrmBindingList and indicates if components of name or class lists are bound tightly or loosely (that is, if wildcarding of intermediate components is specified).

typedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;

XrmBindTightly indicates that a period separates the components, and XrmBindLoosely indicates that an asterisk separates the components.

To convert a string with one or more components to a binding list and a quark list, use XrmStringToBindingQuarkList().

Next: Creating and Storing Databases

Christophe Tronche, ch@tronche.com