DL Logo

ASCab Definitions

MAX_ASCAB_KEY

Header: ASExtraExpT.h:181

Description

Cabinet keys are NULL-terminated C strings. This constant declares the maximum length of one component of that string.

The characters in the key string must all be low ASCII alphanumeric characters, such as '0'- '9', 'a'- 'z', 'A'- 'Z'.

You can burrow through multiple levels of a cabinet heirarchy by passing in a string of individual key names separated by colons.

For example, ASCabGetInt(cab, "Hello:World",-1); is equivalent to ASCabGetInt(ASCabGetCab(cab, "Hello"), "World",-1);.

Similarly, ASCabPutInt(theCab, "Hello:World", 33); will create an integer key named "World" inside the "Hello" cabinet inside theCab, creating the "Hello" key and cabinet if necessary.

Syntax

#define MAX_ASCAB_KEY 1024

ASCab Typedefs

ASCab

Header: ASExpT.h:1388

Description

ASCab objects ( cabinets) can be used to store arbitrary key/value pairs. The keys are always NULL-terminated strings containing only low ASCII alphanumeric characters and spaces (ASCII character 32). Key names cannot begin or end with a space.

Every time you place a non-scalar value inside a cabinet, you are handing that value to the ASCab implementation to manage. Putting a value in a cabinet is always a handoff operation. For example, if you create an ASText object and add it as a value in an ASCab, the ASText object is no longer managed by you; it is managed by the ASCab. The ASCab will destroy the ASText object when its associated key is removed or the key's value is overwritten. Pointer values are a special case discussed in more detail below.

The routine naming convention is as follows:

Name

Description
Get
Get routines return a value. These objects are owned by the ASCab and should not be destroyed by the caller of Get.
GetCopy
GetCopy routines make a copy of the data; the GetCopy client owns the resulting information and can modify it at will; it is also responsible for destroying it.
Detach
Detach routines work the same way as Get routines, but the key is removed from the ASCab without destroying the associated value that is passed back to the client of Detach. The client is responsible for destroying the returned object.

Normally, pointers are treated the same way as scalars; the ASCab passes the pointer value back and forth but does not manage the data to which it points. This all changes if the pointer has an associated destroyProc. If the destroyProc is set, the ASCab will reference count the pointer to track how many times the pointer is referenced from any ASCab. For example, the reference count will be bumped up whenever the pointer is copied via ASCabCopy() or added to another ASCab via ASCabPutPointer(), and will destroy the data associated with the pointer when the reference count goes to 0. The data is destroyed by calling the destroyProc. Detaching a pointer removes one reference to the pointer without ever destroying the information to which it points. ASCabDetachPointer() returns a separate value indicating whether the pointer can safely be destroyed by the client or is still referred to by other key/value pairs inside any ASCab objects (for example, whether the reference count went to zero when the pointer was detached from the ASCab).

Any of the ASCab API's can take a compound name: a string consisting of multiple keys separated by the colon (:) character. For example, "Grandparent:Parent:Child:Key" can be such a compound name. The implementation will burrow down through such a compound string until it reaches the most deeply nested cabinet. Also, any of the Put routines can take a NULL key name. If the key name is NULL, the routine creates a new numeric key name. If the cabinet is empty, the first generated key name will be "0" and subsequent names will increase in ascending order. This is useful when treating an ASCab as a bag of unnamed items, or when adding an ordered list of items to an empty ASCab.

Syntax

typedef struct _t_ASCabinet *ASCab;

Returned From

Used By

ASCabMungeAction

Header: ASExtraExpT.h:303

Description

A value that determines the actions to be taken when ASCabMunge() is called. keyCab is the ASCab that provides the keys determining how theCab is to be changed. During an ASCabMunge() operation, the key cab will not be altered.

For value options see ASMungeOptions.

Syntax

typedef ASEnum16 ASCabMungeAction;

Used By

ASCabValueType

Header: ASExtraExpT.h:161

Description

A constant that specifies the various types of values in ASCab objects. ASCab objects can be used to store arbitrary key/value pairs. The keys are always NULL-terminated strings containing only low ASCII alphanumeric characters.

Related Methods

Syntax

typedef ASEnum16 ASCabValueType;

Returned From

Used By

Used In

ASConstCab

Header: ASExpT.h:1389

Syntax

typedef const struct _t_ASCabinet *ASConstCab;

Used By

ASCab Callback Signatures

ASCabEnumProc

Header: ASExtraExpT.h:254

Description

Used when enumerating the values inside a cabinet.

Syntax

ASBool ASCabEnumProc(ASCab theCab, const char *theKey, ASCabValueType itsType, void *clientData);

Parameters

theCab
The cabinet being enumerated.
theKey
The key name of an entry in the cabinet.
itsType
The type of the value associated with theKey.
clientData
User-supplied data passed into ASCabEnum.

Returns

true to continue enumeration, false to halt enumeration.

Used By

ASCabPointerDestroyProc

Header: ASExtraExpT.h:314

Description

A deallocation callback that can be associated with a pointer in an ASCab. When the reference count of the pointer falls to zero, this callback is called to free the resources associated with the object the pointer references.

Syntax

void ASCabPointerDestroyProc(void *ptr);

Parameters

ptr
IN/OUT The value stored in an ASCab.

Returned From

Used By

ASConstCabEnumProc

Header: ASExtraExpT.h:270

Description

Used when enumerating the values inside a constant cabinet. The callback procedure must not add, delete, or modify items in theCab during the enumeration.

Syntax

ASBool ASConstCabEnumProc(ASConstCab theCab, const char *theKey, ASCabValueType itsType, void *clientData);

Parameters

theCab
The cabinet being enumerated.
theKey
The key name of an entry in the cabinet.
itsType
The type of the value associated with theKey.
clientData
User-supplied data passed into ASCabEnum.

Returns

true to continue enumeration, false to halt enumeration.

Used By

ASCab Structures

_t_ASCabEntryRec

Header: ASExtraExpT.h:207

Description

A data structure representing a cabinet entry. The first entry in each descriptor specifies the name of the key, the second field contains the type, and the following fields contain the values. The entry list must end with a descriptor containing NULL for the key name. It can be used as shown below to construct an ASCab:

ASCabEntryRec cabData[] = {{"key1", kASValueInteger, 1}, {"key2", kASValueInteger,-1}, {"key3", kASValueBool, false}, {NULL}};

ASCab CreateDefaultCab() { return ASCabFromEntryList (cabData); }

This example uses just three values for each record. However, more may be required, such as a double:

{"keyDouble", kASValueDouble, 0, NULL, double}

For a string, the following code could be used:

{"keyString", kASValueString, 0, (void *)string}

Syntax

struct _t_ASCabEntryRec {
const char *keyName;
The name of the key.
The supported ASCabValueTypes are:
Type
Description
A boolean value. intVal contains the value.
An integer value. intVal contains the value.
An atom. intVal contains the value.
A double value. doubleVal contains the value.
ptrVal points to a NULL-terminated C string.
ptrVal points to a NULL-terminated string containing script text, and intVal specifies the ASScript code for the text.
ptrVal points to the binary data, and intVal specifies the size of the data.
Creates an entry with a NULL value.

No other types are supported (specifically kASValueCabinet and kASValuePointer). You can build nested cabinets using the "key: key" syntax for the keyNames.

ASInt32 intVal;
See above.
const void *ptrVal;
See above.
double doubleVal;
See above.
} ASCabEntryRec;

Used By

ASCab Functions

ASCabCopy

Header: ASExtraProcs.h:1362

Description

For each key/value pair in srcCab a copy of the key/value pair will be placed into dstCab, possibly overwriting any identically named key/value pair in dstCab. If the value being copied is a pointer with an associated destroyProc, the pointer and its type string, but not the data it points to, will be copied and an internal reference count will be incremented.

Related Methods

Syntax

void ASCabCopy(ASConstCab srcCab, ASCab dstCab);

Parameters

srcCab
The source cabinet.
dstCab
The destination cabinet.

Exceptions

ASCabDestroy

Header: ASExtraProcs.h:687

Description

Destroys the cabinet and all its key/value pairs. This method raises an exception if the cabinet is the value for some key in another cabinet.

Syntax

void ASCabDestroy(ASCab theCab);

Parameters

theCab
The cabinet.

Exceptions

ASCabDestroyEmpties

Header: ASExtraProcs.h:1345

Description

Finds any empty cabinets in theCab, removes their corresponding keys, and destroys them.

Syntax

void ASCabDestroyEmpties(ASCab theCab, ASBool recurse);

Parameters

theCab
The cabinet.
recurse
true to recurse through all sub-cabinets inside theCab; false to limit enumeration to key/value pairs directly inside theCab.

Exceptions

ASCabDetachBinary

Header: ASExtraProcs.h:1293

Description

Retrieves the binary object stored under theKey in theCab and removes the key from theCab.

The client assumes ownership of the object and is responsible for deallocating any resources associated with it.

Syntax

void *ASCabDetachBinary(ASCab theCab, const char *theKey, ASTArraySize *numBytes);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
numBytes
IN/OUT (Filled by the method, may be NULL) If it is not NULL, it contains the size (in bytes) of the object retrieved.

Returns

A pointer to the binary object. It will be NULL if theKey is not present in theCab or if the value stored under theKey is not of type kASTypeBinary.

Exceptions

ASCabDetachCab

Header: ASExtraProcs.h:1102

Description

Retrieves the ASCab stored under theKey in theCab and removes the key from theCab.

The client assumes ownership of the ASCab returned and is responsible for destroying it.

Related Methods

ASCabGetCab ASCabPutCab

Syntax

ASCab ASCabDetachCab(ASCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The cabinet. Will be NULL if theKey is not present in theCab, or if the value stored under theKey is not of type kASValueCabinet.

Exceptions

ASCabDetachPathName

Header: ASExtraProcs.h:1487

Description

Retrieves the ASPathName stored under theKey in theCab and removes the key from theCab.

Both fileSys and pathName will be NULL if theKey was not found, there was no valid ASPathName stored under the key, or if the ASPathName does not point to an existing file.

It is the client's responsibility to release the memory associated with the ASPathName using ASFileSysReleasePath().

Syntax

void ASCabDetachPathName(ASCab theCab, const char *keyName, ASFileSys *fileSys, ASPathName *pathName);

Parameters

theCab
IN/OUT The cabinet.
keyName
IN/OUT The key name.
fileSys
IN/OUT (Filled by the method) The ASFileSys that pathName was opened through.
pathName
IN/OUT (Filled by the method) The path name.

Exceptions

Any
exceptions raised by ASFileSysPathFromDIPath.

ASCabDetachPointerRaw

Header: ASExtraProcs.h:998

Description

Retrieves the pointer stored under theKey in theCab and removes the key from theCab. If noRefs is set to true, the client assumes ownership of the data referenced by the pointer and is responsible for deallocating any resources associated with it.

Syntax

void *ASCabDetachPointerRaw(ASCab theCab, const char *theKey, const char *expectedType, ASBool *noRefs);

Parameters

theCab
The cabinet.
theKey
The key name.
expectedType
The data type referenced by the pointer. Since ASCabGetPointer() is actually a macro, you should pass the type as a literal name, not a string. For example, use PDDoc instead of "PDDoc". Pointers are always typed, in that they always have associated with them a string indicating the type to which they point.
noRefs
(Filled by the method, may be NULL) If non- NULL, a value of true indicates that there are no other ASCab objects that reference this pointer, and a value of false indicates that some ASCab object still contains a copy of the pointer.

Returns

The pointer value stored under theKey. It will be NULL if theKey is not present in theCab, the value stored under theKey is not of type kASValuePointer, or the type of the pointer does not match expectedType.

Exceptions

ASCabDetachString

Header: ASExtraProcs.h:1158

Description

Retrieves the string stored under theKey in theCab and removes the key from theCab.

The client assumes ownership of the string and is responsible for deallocating any resources associated with it.

Syntax

char *ASCabDetachString(ASCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The string stored under theKey. Will be NULL if theKey is not present in theCab, or if the value stored under theKey is not of type kASValueString.

Exceptions

ASCabDetachText

Header: ASExtraProcs.h:1212

Description

Retrieves the ASText object stored under theKey in theCab and removes the key from theCab.

The client assumes ownership of the ASText object and is responsible for deallocating it using ASTextDestroy().

Related Methods

ASCabGetText ASCabPutText

Syntax

ASText ASCabDetachText(ASCab theCab, const char *theKey);

Parameters

theCab
The cabinet.
theKey
The key name.

Returns

The ASText object stored under theKey. It will be NULL if theKey is not present in theCab, or if the value stored under theKey is not of type kASValueText.

Exceptions

ASCabDup

Header: ASExtraProcs.h:1374

Description

Creates a new ASCab and populates it with copies of the key/value pairs in srcCab. It is equivalent to ASCabCopy( srcCab, ASCabNew ()).

Related Methods

Syntax

ASCab ASCabDup(ASConstCab srcCab);

Parameters

srcCab
The source cabinet.

Returns

The newly created ASCab.

Exceptions

ASCabEnum

Header: ASExtraProcs.h:745

Description

Enumerates all the keys in the cabinet.

Keys consisting solely of digits are enumerated first, in numeric order (assuming they are not padded with zeros at the front, which will confuse matters). Non-numeric keys are then enumerated in strcmp order.

It is safe to add, delete, and modify items in theCab during the enumeration. Items that are added during the enumeration will not be enumerated. Modified items that have been enumerated already will not be enumerated again. Deleted items that have not yet been enumerated will not be enumerated.

Note: This will RERAISE any exceptions thrown by enumProc.

Related Methods

Syntax

void ASCabEnum(ASCab theCab, ASCabEnumProc enumProc, void *clientData);

Parameters

theCab
The cabinet.
enumProc
A user-supplied callback that is called for each entry found in theCab.
clientData
A pointer to user-supplied data to pass to enumProc each time it is called.

Exceptions

ASCabEqual

Header: ASExtraProcs.h:1408

Description

Compares two cabinets and verifies that they have a matching set of keys and that all key values are equal as reported by ASCabValueEqual().

Related Methods

Syntax

ASBool ASCabEqual(ASConstCab cab1, ASConstCab cab2);

Parameters

cab1
The first cabinet.
cab2
The second cabinet.

Returns

true if the cabinets are equal, false otherwise.

Exceptions

ASCabFromEntryList

Header: ASExtraProcs.h:677

Description

Builds a cabinet based on a constant array of ASCabDescriptor records (see ASCabEntryRec). The first entry in each descriptor specifies the name of the key; subsequent fields contain the value. The entry list must end with a descriptor containing NULL for the key name. See ASExtraExpT.h for more info.

Syntax

ASCab ASCabFromEntryList(const ASCabEntryRec *entryList);

Parameters

entryList
A constant array of ASCabDescriptor records (see ASCabEntryRec). Passing NULL generates an empty ASCab.

Returns

The newly created ASCab.

Exceptions

ASCabGetAtom

Header: ASExtraProcs.h:875

Description

Returns the ASAtom value stored under theKey in theCab.

Related Methods

Syntax

ASAtom ASCabGetAtom(ASConstCab theCab, const char *theKey, ASAtom defValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
defValue
IN/OUT The default value.

Returns

The ASAtom value stored under theKey if the key is found and the value stored under it is of type kASValueAtom; otherwise defValue is returned.

Exceptions

ASCabGetBinary

Header: ASExtraProcs.h:1249

Description

Returns the binary object stored under theKey in theCab.

Syntax

const void *ASCabGetBinary(ASConstCab theCab, const char *theKey, ASTArraySize *numBytes);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
numBytes
IN/OUT (Filled by the method, may be NULL) If it is not NULL, it contains the size (in bytes) of the object returned.

Returns

The binary object stored under theKey if the key is found and the value stored under it is of type kASValueBinary; otherwise NULL is returned. This object is owned by the ASCab and should not be destroyed by the caller.

Exceptions

ASCabGetBinaryCopy

Header: ASExtraProcs.h:1271

Description

Returns a copy of the binary object stored under theKey in theCab.

It is the client's responsibility to release the memory associated with the object using ASfree().

Syntax

void *ASCabGetBinaryCopy(ASConstCab theCab, const char *theKey, ASTArraySize *numBytes);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
numBytes
IN/OUT (Filled by the method, may be NULL) If it is not NULL, it contains the size of the object returned.

Returns

The binary object stored under theKey if the key is found and the value stored under it is of type kASValueBinary; otherwise NULL is returned.

Exceptions

ASCabGetBool

Header: ASExtraProcs.h:823

Description

Returns the ASBool value stored under theKey in theCab.

Related Methods

Syntax

ASBool ASCabGetBool(ASConstCab theCab, const char *theKey, ASBool defValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
defValue
IN/OUT The default value.

Returns

The ASBool value stored under theKey if the key is found and the value stored under it is of type kASValueBool; otherwise defValue is returned.

Exceptions

ASCabGetCab

Header: ASExtraProcs.h:1084

Description

Returns the ASCab stored under theKey in theCab.

Related Methods

ASCabDetachCab ASCabPutCab

Syntax

ASCab ASCabGetCab(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The ASCab stored under theKey if the key is found and the value stored under it is of type kASValueCabinet; otherwise NULL is returned. This object is owned by theCab and should not be destroyed by the client.

Exceptions

ASCabGetDouble

Header: ASExtraProcs.h:902

Description

Returns the double value stored under theKey in theCab. If the value stored under theKey is of type kASValueInteger, this value will be cast to a double and returned to the client.

Related Methods

Syntax

double ASCabGetDouble(ASConstCab theCab, const char *theKey, double defValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
defValue
IN/OUT The default value.

Returns

The double value stored under theKey if the key is found and the value stored under it is of type kASValueDouble or kASValueInteger; otherwise defValue is returned.

Exceptions

ASCabGetInt

Header: ASExtraProcs.h:849

Description

Returns the ASInt32 value stored under theKey in theCab.

Related Methods

Syntax

ASInt32 ASCabGetInt(ASConstCab theCab, const char *theKey, ASInt32 defValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
defValue
IN/OUT The default value.

Returns

The ASInt32 value stored under theKey if the key is found and the value stored under it is of type kASValueInteger; otherwise defValue is returned.

Exceptions

ASCabGetInt64

Header: ASExtraProcs.h:2383

Description

Returns the ASInt64 value stored under theKey in theCab.

Related Methods

Syntax

ASInt64 ASCabGetInt64(ASConstCab theCab, const char *theKey, ASInt64 defValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
defValue
IN/OUT The default value.

Returns

The ASInt64 value stored under theKey if the key is found and the value stored under it is of type kASValueInt64; otherwise defValue is returned.

Exceptions

ASCabGetPathNameCopy

Header: ASExtraProcs.h:1462

Description

Returns a copy of ASPathName stored under theKey in theCab.

It is the client's responsibility to release the ASPathName using ASFileSysReleasePath().

Both fileSys and pathName will be NULL if theKey was not found, there was no valid ASPathName stored under the key, or if pathName does not point to an existing file.

Syntax

void ASCabGetPathNameCopy(ASConstCab theCab, const char *keyName, ASFileSys *fileSys, ASPathName *pathName);

Parameters

theCab
IN/OUT The cabinet.
keyName
IN/OUT The key name.
fileSys
IN/OUT (Filled by the method) The ASFileSys that pathName was opened through.
pathName
IN/OUT (Filled by the method) The path name.

Exceptions

Any
exception raised by ASFileSysPathFromDIPath.

ASCabGetPointerDestroyProc

Header: ASExtraProcs.h:1036

Description

Obtains the resource deallocation callback associated with the pointer stored under theKey in theCab. When the reference count of the pointer falls to zero, the callback is called to free the resources associated with the object it references.

Syntax

ASCabPointerDestroyProc ASCabGetPointerDestroyProc(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The callback (if any) associated with the pointer if the key is found and the value stored under it is of type kASValuePointer; otherwise NULL is returned.

Exceptions

ASCabGetPointerRaw

Header: ASExtraProcs.h:971

Description

Returns the pointer value stored under theKey in theCab.

Syntax

void *ASCabGetPointerRaw(ASConstCab theCab, const char *theKey, const char *expectedType);

Parameters

theCab
The cabinet.
theKey
The key name.
expectedType
The data type referenced by the pointer. Since ASCabGetPointer() is actually a macro, you should pass the type as a literal name, not a string. For example, use PDDoc instead of "PDDoc". Pointers are always typed, in that they always have associated with them a string indicating the type to which they point.

Returns

The pointer value stored under theKey if the key is found, the value stored under theKey is of type kASValuePointer, and the type of the pointer matches expectedType; otherwise NULL is returned. The object referenced by this pointer is owned by theCab and should not be destroyed by the client.

Exceptions

ASCabGetPointerType

Header: ASExtraProcs.h:1049

Description

Returns a string representation of the data type referenced by the pointer stored under theKey in theCab.

Syntax

const char *ASCabGetPointerType(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The string if the key is found and the value stored under it is of type kASValuePointer; otherwise NULL is returned.

Exceptions

ASCabGetString

Header: ASExtraProcs.h:1120

Description

Returns the string stored under theKey in theCab.

Syntax

const char *ASCabGetString(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The string stored under theKey if the key is found and the value stored under it is of type kASValueString; otherwise NULL is returned. The object referenced by this pointer is owned by theCab and should not be destroyed by the client.

Exceptions

ASCabGetStringCopy

Header: ASExtraProcs.h:1139

Description

Returns a copy of the string stored under theKey in theCab.

It is the client's responsibility to release the memory allocated for the string using ASfree().

Syntax

char *ASCabGetStringCopy(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

A copy of the string stored under theKey if the key is found and the value stored under it is of type kASValueString; otherwise NULL is returned.

Exceptions

ASCabGetText

Header: ASExtraProcs.h:1194

Description

Returns the ASText object stored under theKey in theCab.

Syntax

ASText ASCabGetText(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The ASText object stored under theKey if the key is found and the value stored under it is of type kASValueText; otherwise NULL is returned. This object is owned by theCab and should not be destroyed by the client.

Exceptions

ASCabGetType

Header: ASExtraProcs.h:718

Description

Returns the type of value stored under theKey in theCab.

Syntax

ASCabValueType ASCabGetType(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

The type of value stored under theKey, or kASValueUnknown if the key is not found.

Exceptions

ASCabGetUns

Header: ASExtraProcs.h:1611

Description

Returns the ASUns32 value stored under theKey in theCab.

Related Methods

Syntax

ASUns32 ASCabGetUns(ASConstCab theCab, const char *theKey, ASUns32 defValue);

Parameters

theCab
The cabinet.
theKey
The key name.
defValue
The default value.

Returns

The ASUns32 value stored under theKey if the key is found and the value stored under it is of type kASValueUns; otherwise defValue is returned.

Exceptions

ASCabGetUns64

Header: ASExtraProcs.h:2409

Description

Returns the ASUns64 value stored under theKey in theCab.

Related Methods

Syntax

ASUns64 ASCabGetUns64(ASConstCab theCab, const char *theKey, ASUns64 defValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.
defValue
IN/OUT The default value.

Returns

The ASUns64 value stored under theKey if the key is found and the value stored under it is of type kASValueUns64; otherwise defValue is returned.

Exceptions

ASCabKnown

Header: ASExtraProcs.h:706

Description

Returns true if theKey is present in theCab.

Syntax

ASBool ASCabKnown(ASConstCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Returns

See above.

Exceptions

ASCabMakeEmpty

Header: ASExtraProcs.h:1333

Description

Removes all keys from theCab and destroys all values they point to.

Syntax

void ASCabMakeEmpty(ASCab theCab);

Parameters

theCab
IN/OUT The cabinet.

Exceptions

ASCabMunge

Header: ASExtraProcs.h:1420

Description

Munges the keys and the corresponding values in theCab based on the keys in keyCab and the munge action. Note that keyCab is never altered, but theCab is.

Syntax

void ASCabMunge(ASCab theCab, ASConstCab keyCab, ASCabMungeAction action);

Parameters

theCab
IN/OUT The cabinet to be modified.
keyCab
IN/OUT The cabinet used to modify theCab.
action
IN/OUT The type of action to be taken.

Exceptions

ASCabNew

Header: ASExtraProcs.h:662

Description

Creates a new, empty cabinet.

Syntax

ASCab ASCabNew(void);

Returns

The newly created cabinet.

Exceptions

ASCabNumEntries

Header: ASExtraProcs.h:696

Description

Returns the number of key/value pairs in theCab.

Syntax

ASTArraySize ASCabNumEntries(ASConstCab theCab);

Parameters

theCab
The cabinet.

Returns

See above.

Exceptions

ASCabPutAtom

Header: ASExtraProcs.h:886

Description

Stores an ASAtom value in theCab under theKey.

Related Methods

Syntax

void ASCabPutAtom(ASCab theCab, const char *theKey, ASAtom atomValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
atomValue
IN/OUT The value to be stored.

Exceptions

ASCabPutBinary

Header: ASExtraProcs.h:1312

Description

Stores a binary object in theCab under theKey. The ASCab assumes ownership of the binary object, so the client should not attempt to free the memory associated with it. The binary object must have been allocated using ASmalloc().

Syntax

void ASCabPutBinary(ASCab theCab, const char *theKey, void *theBlob, ASTArraySize blobSize);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
theBlob
IN/OUT (May be NULL) A pointer to the binary object to be stored. If it is NULL, the value (if any) stored under theKey in theCab is destroyed and theKey removed from theCab.
blobSize
IN/OUT The size of the binary object.

Exceptions

ASCabPutBool

Header: ASExtraProcs.h:834

Description

Stores an ASBool value in theCab under theKey.

Related Methods

Syntax

void ASCabPutBool(ASCab theCab, const char *theKey, ASBool theBool);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN (May be NULL) The key name.
theBool
IN The value to be stored. Non-zero values are stored as true.

Exceptions

ASCabPutCab

Header: ASExtraProcs.h:1069

Description

Stores an ASCab in theCab under theKey. If the cabinet is already a value for some other ASCab, ASCabPutCab() will raise an exception, since any cabinet can be contained by at most one other cabinet.

theCab assumes ownership of the cabinet, so the client must not destroy it.

Related Methods

ASCabDetachCab ASCabGetCab

Syntax

void ASCabPutCab(ASCab theCab, const char *keyName, ASCab putCab);

Parameters

theCab
IN/OUT The cabinet.
keyName
IN/OUT (May be NULL) The key name.
putCab
IN/OUT (May be NULL) The ASCab to be stored in theCab. If cabVal is NULL, then any value under theKey is destroyed and theKey is removed from theCab.

Exceptions

ASCabPutDouble

Header: ASExtraProcs.h:913

Description

Stores a double value in theCab under theKey.

Related Methods

Syntax

void ASCabPutDouble(ASCab theCab, const char *theKey, double floatValue);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
floatValue
IN/OUT The value to be stored.

Exceptions

ASCabPutInt

Header: ASExtraProcs.h:860

Description

Stores an ASInt32 value in theCab under theKey.

Related Methods

Syntax

void ASCabPutInt(ASCab theCab, const char *theKey, ASInt32 theInt);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
theInt
IN/OUT The value to be stored.

Exceptions

ASCabPutInt64

Header: ASExtraProcs.h:2394

Description

Stores an ASInt64 value in theCab under theKey.

Related Methods

Syntax

void ASCabPutInt64(ASCab theCab, const char *theKey, ASInt64 theInt);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
theInt
IN/OUT The value to be stored.

Exceptions

ASCabPutNull

Header: ASExtraProcs.h:1324

Description

Stores a value with a type of kASValueNull in theCab under theKey. NULL cabinet entries are used as placeholders or to removed other cabinet entries during an ASCabMunge operation.

Syntax

void ASCabPutNull(ASCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Exceptions

ASCabPutPathName

Header: ASExtraProcs.h:1439

Description

Stores an ASPathName in theCab under theKey.

theCab assumes ownership of the ASPathName, so the client need not call ASFileSysReleasePath().

Syntax

void ASCabPutPathName(ASCab theCab, const char *keyName, ASFileSys fileSys, ASPathName pathName);

Parameters

theCab
IN/OUT The cabinet.
keyName
IN/OUT (May be NULL) The key name.
fileSys
IN/OUT The ASFileSys from which the path was obtained.
pathName
IN/OUT (May be NULL) The ASPathName to be stored. If NULL, the value (if any) stored under theKey in theCab is destroyed and theKey is removed from theCab.

Exceptions

ASCabPutPointerRaw

Header: ASExtraProcs.h:1018

Description

Stores a pointer in theCab under theKey. See the ASCab description for more information.

Syntax

void ASCabPutPointerRaw(ASCab theCab, const char *theKey, const char *theType, void *thePtr, ASCabPointerDestroyProc destroy);

Parameters

theCab
The cabinet.
theKey
(May be NULL) The key name.
theType
The data type referenced by the pointer. Since ASCabGetPointer() is actually a macro, you should pass the type as a literal name, not a string. For example, use PDDoc instead of "PDDoc". Pointers are always typed, in that they always have associated with them a string indicating the type to which they point.
thePtr
The value to be stored.
destroy
(May be NULL) A user-supplied callback which is called when the reference count associated with thePtr is zero.

Exceptions

ASCabPutString

Header: ASExtraProcs.h:1178

Description

Stores a string in theCab under theKey. A string consists of some number of bytes followed by a single NULL (zero) byte. The string must have been allocated using ASmalloc().

theCab assumes ownership of the string, so the client should not attempt to free the memory associated with it.

Syntax

void ASCabPutString(ASCab theCab, const char *theKey, const char *theStr);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
theStr
IN/OUT (May be NULL) The string to be stored. If NULL, the value (if any) stored under theKey in theCab is destroyed and theKey is removed from theCab.

Exceptions

ASCabPutText

Header: ASExtraProcs.h:1229

Description

Stores an ASText object in theCab under theKey.

theCab assumes ownership of the object, so the client should not attempt to free the memory associated with it.

Syntax

void ASCabPutText(ASCab theCab, const char *theKey, ASText theText);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
theText
IN/OUT (May be NULL) The object to be stored. If its value is NULL, the value (if any) stored under theKey in theCab is destroyed and theKey is removed from theCab.

Exceptions

ASCabPutUns

Header: ASExtraProcs.h:1622

Description

Stores the ASUns32 value under theKey in theCab.

Related Methods

Syntax

void ASCabPutUns(ASCab theCab, const char *theKey, ASUns32 theUns);

Parameters

theCab
The cabinet.
theKey
The key name.
theUns
The value to be stored.

Exceptions

ASCabPutUns64

Header: ASExtraProcs.h:2420

Description

Stores an ASUns64 value in theCab under theKey.

Related Methods

Syntax

void ASCabPutUns64(ASCab theCab, const char *theKey, ASUns64 theInt);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT (May be NULL) The key name.
theInt
IN/OUT The value to be stored.

Exceptions

ASCabReadFromStream

Header: ASExtraProcs.h:1511

Description

Reads a previously written cabinet from a stream.

Related Methods

Syntax

ASCab ASCabReadFromStream(ASStm stm);

Parameters

stm
Must be a stream opened through ASFileStmRdOpen(), ASMemStmRdOpen(), or ASProcStmRdOpenEx().

Returns

The ASCab, or NULL if it could not be constructed.

ASCabRemove

Header: ASExtraProcs.h:808

Description

Removes theKey entry from theCab, destroying the associated value.

Syntax

void ASCabRemove(ASCab theCab, const char *theKey);

Parameters

theCab
IN/OUT The cabinet.
theKey
IN/OUT The key name.

Exceptions

ASCabRename

Header: ASExtraProcs.h:1530

Description

Renames a key within theCab while preserving the value associated with it. If there is already a key equal to newKeyName in theCab, its value will be destroyed and replaced with the value of oldKeyName.

Any attempt to move the item from one sub-cabinet to another will cause ASCabRename() to raise an exception. For example, ASCabRename(theCab, "SubCab1:Key1", "SubCab2:Key1") will raise an exception. If this routine raises an exception, theCab will be untouched.

Syntax

void ASCabRename(ASCab theCab, const char *oldKeyName, const char *newKeyName);

Parameters

theCab
The cabinet.
oldKeyName
The key name to be changed.
newKeyName
The new name.

Exceptions

ASCabValueEqual

Header: ASExtraProcs.h:1395

Description

Compares two cabinet values and returns true only if they are equal (meaning that they have the same type and value). Cabinets are compared using ASCabEqual(). ASText values are compared by using ASTextCmp() and testing for a return value of 0 (zero). Strings and binary values must have the same lengths and byte-for-byte contents. Booleans, atoms, doubles, and integers must have equal values. Pointer values must point to the same location in memory but may have different destroyProcs and type strings.

Related Methods

Syntax

ASBool ASCabValueEqual(ASConstCab cab1, const char *keyName1, ASConstCab cab2, const char *keyName2);

Parameters

cab1
IN/OUT The first cabinet.
keyName1
IN/OUT The key name.
cab2
IN/OUT The second cabinet.
keyName2
IN/OUT The key name.

Returns

See above.

Exceptions

ASCabWriteToStream

Header: ASExtraProcs.h:1501

Description

Writes theCab out to a stream. The caller retains ownership of the cabinet. The stream will not be closed or flushed.

Related Methods

Syntax

void ASCabWriteToStream(ASConstCab theCab, ASStm theStm);

Parameters

theCab
IN/OUT The cabinet.
theStm
IN/OUT Must be a stream opened through ASFileStmWrOpen() or ASProcStmWrOpen().

Exceptions

ASConstCabEnum

Header: ASExtraProcs.h:2341

Description

Enumerates all the keys in the constant cabinet.

Keys consisting solely of digits are enumerated first, in numeric order (assuming they are not padded with zeros at the front, which will confuse matters). Non-numeric keys are then enumerated in strcmp order.

The callback procedure must not add, delete, or modify items in theCab during the enumeration.

It will RERAISE any exceptions thrown by enumProc.

Related Methods

Syntax

void ASConstCabEnum(ASConstCab theCab, ASConstCabEnumProc enumProc, void *clientData);

Parameters

theCab
The cabinet.
enumProc
User-supplied callback that is called for each entry found in theCab. This callback cannot modify the ASConstCab object.
clientData
A pointer to user-supplied data to pass to enumProc each time it is called.

Exceptions