.\" Copyright (c) 2002-2007 Hypertriton, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd December 29, 2002 .Dt AG_PROP 3 .Os .ds vT Agar API Reference .ds oS Agar 1.0 .Sh NAME .Nm AG_Prop .Nd generic agar object properties .Sh SYNOPSIS .Bd -literal #include .Ed .Sh DESCRIPTION The .Xr AG_Object 3 class provides a set of general-purpose properties (key=value pairs). Values are specified using the .Xr AG_Variable 3 interface. The .Nm interface allows properties to be assigned and read. .Pp By default, properties are made persistent by the .Ft AG_Object archiving process. .Pp NOTE: As of Agar 1.3.4, this interface is now .Em deprecated . Developers should use the new .Xr AG_Variable 3 , interface instead. .Sh READING PROPERTIES .nr nS 1 .Ft "AG_Prop *" .Fn AG_GetProp "AG_Object *obj" "const char *key" "enum ag_prop_type type" "void *dst" .Pp .Ft "int" .Fn AG_PropDefined "AG_Object *obj" "const char *key" .Pp .Ft "AG_Prop *" .Fn AG_CopyProp "const AG_Prop *prop" .Pp .Ft void .Fn AG_LockProps "AG_Object *obj" .Pp .Ft void .Fn AG_UnlockProps "AG_Object *obj" .Pp .Ft int .Fn AG_GetBool "AG_Object *obj" "const char *key" .Pp .Ft "Uint" .Fn AG_GetUint "AG_Object *obj" "const char *key" .Pp .Ft int .Fn AG_GetInt "AG_Object *obj" "const char *key" .Pp .Ft Uint8 .Fn AG_GetUint8 "AG_Object *obj" "const char *key" .Pp .Ft Sint8 .Fn AG_GetSint8 "AG_Object *obj" "const char *key" .Pp .Ft Uint16 .Fn AG_GetUint16 "AG_Object *obj" "const char *key" .Pp .Ft Sint16 .Fn AG_GetSint16 "AG_Object *obj" "const char *key" .Pp .Ft Uint32 .Fn AG_GetUint32 "AG_Object *obj" "const char *key" .Pp .Ft Sint32 .Fn AG_GetSint32 "AG_Object *obj" "const char *key" .Pp .Ft float .Fn AG_GetFloat "AG_Object *obj" "const char *key" .Pp .Ft double .Fn AG_GetDouble "AG_Object *obj" "const char *key" .Pp .Ft size_t .Fn AG_GetString "AG_Object *obj" "const char *key" "char *dst" "size_t dst_size" .Pp .Ft "char *" .Fn AG_GetStringDup "AG_Object *obj" "const char *key" .Pp .Ft "void *" .Fn AG_GetPointer "AG_Object *obj" "const char *key" .Pp .nr nS 0 The .Fn AG_GetProp function searches for a property of type .Fa type named .Fa key and writes its value to .Fa dst , which should point to a variable of the specific data type associated with the property. .Fa AG_Prop returns a pointer to the related .Nm structure, or NULL if no property matches .Fa key . .Pp The .Fn AG_PropDefined routine returns 1 if a property .Fa key exists. .Pp The .Fn AG_CopyProp function returns a copy of .Fa prop . .Pp The .Fn AG_LockProps and .Fn AG_UnlockProps functions acquire/release the recursive mutex which is associated with an object's properties. .Pp The .Fn AG_(Type) functions all look for a property named .Fa key and return the associated value, raising a fatal condition if there is no match. .Pp The .Fn AG_GetString routine copies up to .Fa dst_size - 1 characters from the value of a string property to .Fa dst , NUL-terminating the result. .Pp .Fn AG_GetStringDup returns a copy of the string. .Sh WRITING PROPERTIES .nr nS 1 .Ft "AG_Prop *" .Fn AG_SetProp "AG_Object *obj" "const char *name" "enum ag_prop_type type" "..." .Pp .Ft "AG_Prop *" .Fn AG_SetBool "AG_Object *obj" "const char *key" "int value" .Pp .Ft "AG_Prop *" .Fn AG_SetUint "AG_Object *obj" "const char *key" "Uint value" .Pp .Ft "AG_Prop *" .Fn AG_SetInt "AG_Object *obj" "const char *key" "int value" .Pp .Ft "AG_Prop *" .Fn AG_SetUint8 "AG_Object *obj" "const char *key" "Uint8 value" .Pp .Ft "AG_Prop *" .Fn AG_SetSint8 "AG_Object *obj" "const char *key" "Sint8 value" .Pp .Ft "AG_Prop *" .Fn AG_SetUint16 "AG_Object *obj" "const char *key" "Uint16 value" .Pp .Ft "AG_Prop *" .Fn AG_SetSint16 "AG_Object *obj" "const char *key" "Sint16 value" .Pp .Ft "AG_Prop *" .Fn AG_SetUint32 "AG_Object *obj" "const char *key" "Uint32 value" .Pp .Ft "AG_Prop *" .Fn AG_SetSint32 "AG_Object *obj" "const char *key" "Sint32 value" .Pp .Ft "AG_Prop *" .Fn AG_SetFloat "AG_Object *obj" "const char *key" "float value" .Pp .Ft "AG_Prop *" .Fn AG_SetDouble "AG_Object *obj" "const char *key" "double value" .Pp .Ft "AG_Prop *" .Fn AG_SetString "AG_Object *obj" "const char *key" "const char *s" .Pp .Ft "AG_Prop *" .Fn AG_SetStringNODUP "AG_Object *obj" "const char *key" "const char *s" .Pp .Ft "AG_Prop *" .Fn AG_SetStringFixed "AG_Object *obj" "const char *key" "char *buf" "size_t bufSize" .Pp .Ft "AG_Prop *" .Fn AG_PrtString "AG_Object *obj" "const char *key" "const char *fmt" "..." .Pp .Ft "AG_Prop *" .Fn AG_SetPointer "AG_Object *obj" "const char *key" "void *ptr" .Pp .nr nS 0 The .Fn AG_SetProp function searches for a property of type .Fa type named .Fa key and sets its value to data read from the next arguments, which should be data of the specific data type associated with the property. If the .Fa key does not match an existing property, a new one is created. .Pp The .Fn AG_Set(Type) functions all look for a property named .Fa key and set its value to .Fa value , returning a pointer to the modified property. If the .Fa key does not match any existing property, a new one is created. .Sh SAVING/LOADING .nr nS 1 .Ft int .Fn AG_PropLoad "AG_Object *obj" "AG_DataSource *ds" .Pp .Ft int .Fn AG_PropSave "AG_Object *obj" "AG_DataSource *ds" .Pp .nr nS 0 The .Fn AG_PropLoad function loads an object's property table in machine-independent format from .Fa ds , and .Fn AG_PropSave saves an object's property table in machine-independent format to .Fa ds . Properties which are marked non-persistent (such as all properties of type .Dv AG_VARIABLE_POINTER ) are ignored by these functions. .Sh SEE ALSO .Xr AG_Intro 3 , .Xr AG_Object 3 , .Xr AG_DataSource 3 .Sh HISTORY The .Nm interface first appeared in Agar 1.0. Support for property-specific and object-specific read/write operations first appeared in Agar 1.1. The introduction of .Xr AG_Variable 3 in Agar 1.3.4 rendered the .Nm interface obsolete.