1.\" $NetBSD: prop_dictionary_util.3,v 1.2 2007/08/16 16:31:00 thorpej Exp $ 2.\" 3.\" Copyright (c) 2006 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Jason R. Thorpe. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd October 25, 2006 38.Dt PROP_DICTIONARY_UTIL 3 39.Os 40.Sh NAME 41.Nm prop_dictionary_util , 42.Nm prop_dictionary_get_bool , 43.Nm prop_dictionary_set_bool , 44.Nm prop_dictionary_get_int8 , 45.Nm prop_dictionary_get_uint8 , 46.Nm prop_dictionary_set_int8 , 47.Nm prop_dictionary_set_uint8 , 48.Nm prop_dictionary_get_int16 , 49.Nm prop_dictionary_get_uint16 , 50.Nm prop_dictionary_set_int16 , 51.Nm prop_dictionary_set_uint16 , 52.Nm prop_dictionary_get_int32 , 53.Nm prop_dictionary_get_uint32 , 54.Nm prop_dictionary_set_int32 , 55.Nm prop_dictionary_set_uint32 , 56.Nm prop_dictionary_get_int64 , 57.Nm prop_dictionary_get_uint64 , 58.Nm prop_dictionary_set_int64 , 59.Nm prop_dictionary_set_uint64 , 60.Nm prop_dictionary_get_cstring , 61.Nm prop_dictionary_set_cstring , 62.Nm prop_dictionary_get_cstring_nocopy , 63.Nm prop_dictionary_set_cstring_nocopy 64.Sh LIBRARY 65.Lb libprop 66.Sh SYNOPSIS 67.In prop/proplib.h 68.\" 69.Ft bool 70.Fn prop_dictionary_get_bool "prop_dictionary_t dict" "cosnt char *key" \ 71 "bool *valp" 72.Ft bool 73.Fn prop_dictionary_set_bool "prop_dictionary_t dict" "const char *key" \ 74 "bool val" 75.\" 76.Ft bool 77.Fn prop_dictionary_get_int8 "prop_dictionary_t dict" "const char *key" \ 78 "int8_t *valp" 79.Ft bool 80.Fn prop_dictionary_get_uint8 "prop_dictionary_t dict" "const char *key" \ 81 "uint8_t *valp" 82.Ft bool 83.Fn prop_dictionary_set_int8 "prop_dictionary_t dict" "const char *key" \ 84 "int8_t val" 85.Ft bool 86.Fn prop_dictionary_set_uint8 "prop_dictionary_t dict" "const char *key" \ 87 "uint8_t val" 88.\" 89.Ft bool 90.Fn prop_dictionary_get_int16 "prop_dictionary_t dict" "const char *key" \ 91 "int16_t *valp" 92.Ft bool 93.Fn prop_dictionary_get_uint16 "prop_dictionary_t dict" "const char *key" \ 94 "uint16_t *valp" 95.Ft bool 96.Fn prop_dictionary_set_int16 "prop_dictionary_t dict" "const char *key" \ 97 "int16_t val" 98.Ft bool 99.Fn prop_dictionary_set_uint16 "prop_dictionary_t dict" "const char *key" \ 100 "uint16_t val" 101.\" 102.Ft bool 103.Fn prop_dictionary_get_int32 "prop_dictionary_t dict" "const char *key" \ 104 "int32_t *valp" 105.Ft bool 106.Fn prop_dictionary_get_uint32 "prop_dictionary_t dict" "const char *key" \ 107 "uint32_t *valp" 108.Ft bool 109.Fn prop_dictionary_set_int32 "prop_dictionary_t dict" "const char *key" \ 110 "int32_t val" 111.Ft bool 112.Fn prop_dictionary_set_uint32 "prop_dictionary_t dict" "const char *key" \ 113 "uint32_t val" 114.\" 115.Ft bool 116.Fn prop_dictionary_get_int64 "prop_dictionary_t dict" "const char *key" \ 117 "int64_t *valp" 118.Ft bool 119.Fn prop_dictionary_get_uint64 "prop_dictionary_t dict" "const char *key" \ 120 "uint64_t *valp" 121.Ft bool 122.Fn prop_dictionary_set_int64 "prop_dictionary_t dict" "const char *key" \ 123 "int64_t val" 124.Ft bool 125.Fn prop_dictionary_set_uint64 "prop_dictionary_t dict" "const char *key" \ 126 "uint64_t val" 127.\" 128.Ft bool 129.Fn prop_dictionary_get_cstring "prop_dictionary_t dict" "const char *key" \ 130 "char **strp" 131.Ft bool 132.Fn prop_dictionary_set_cstring "prop_dictionary_t dict" "const char *key" \ 133 "const char *str" 134.\" 135.Ft bool 136.Fn prop_dictionary_get_cstring_nocopy "prop_dictionary_t dict" \ 137 "const char *key" "const char **strp" 138.Ft bool 139.Fn prop_dictionary_set_cstring_nocopy "prop_dictionary_t dict" \ 140 "const char *key" "const char *strp" 141.Sh DESCRIPTION 142The 143.Nm prop_dictionary_util 144family of functions are provided to make getting and setting values in 145dictionaries more convenient in some applications. 146.Pp 147The getters check the type of the returned object and, in some cases, also 148ensure that the returned value is within the range implied by the getter's 149value type. 150.Pp 151The setters handle object creation and release for the caller. 152.Pp 153The 154.Fn prop_dictionary_get_cstring 155function returns dynamically allocated memory. 156See 157.Xr prop_string 3 158for more information. 159.Pp 160The 161.Fn prop_dictionary_get_cstring_nocopy 162and 163.Fn prop_dictionary_set_cstring_nocopy 164functions do not copy the string that is set or returned. 165See 166.Xr prop_string 3 167for more information. 168.Sh RETURN VALUES 169The 170.Nm prop_dictionary_util 171getter functions return 172.Dv true 173if the object exists in the dictionary and the value is in-range, or 174.Dv false 175otherwise. 176.Pp 177The 178.Nm prop_dictionary_util 179setter functions return 180.Dv true 181if creating the object and storing it in the dictionary is successful, or 182.Dv false 183otherwise. 184.Sh SEE ALSO 185.Xr prop_bool 3 , 186.Xr prop_dictionary 3 , 187.Xr prop_number 3 , 188.Xr proplib 3 189.Sh HISTORY 190The 191.Nm proplib 192property container object library first appeared in 193.Nx 4.0 . 194