1.\" $NetBSD: prop_dictionary_util.3,v 1.8 2011/10/17 09:24:54 wiz 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.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd August 7, 2011 31.Dt PROP_DICTIONARY_UTIL 3 32.Os 33.Sh NAME 34.Nm prop_dictionary_util , 35.Nm prop_dictionary_get_dict , 36.Nm prop_dictionary_get_bool , 37.Nm prop_dictionary_set_bool , 38.Nm prop_dictionary_get_int8 , 39.Nm prop_dictionary_get_uint8 , 40.Nm prop_dictionary_set_int8 , 41.Nm prop_dictionary_set_uint8 , 42.Nm prop_dictionary_get_int16 , 43.Nm prop_dictionary_get_uint16 , 44.Nm prop_dictionary_set_int16 , 45.Nm prop_dictionary_set_uint16 , 46.Nm prop_dictionary_get_int32 , 47.Nm prop_dictionary_get_uint32 , 48.Nm prop_dictionary_set_int32 , 49.Nm prop_dictionary_set_uint32 , 50.Nm prop_dictionary_get_int64 , 51.Nm prop_dictionary_get_uint64 , 52.Nm prop_dictionary_set_int64 , 53.Nm prop_dictionary_set_uint64 , 54.Nm prop_dictionary_get_cstring , 55.Nm prop_dictionary_set_cstring , 56.Nm prop_dictionary_get_cstring_nocopy , 57.Nm prop_dictionary_set_cstring_nocopy , 58.Nm prop_dictionary_set_and_rel 59.Nd dictionary property collection object utility functions 60.Sh LIBRARY 61.Lb libprop 62.Sh SYNOPSIS 63.In prop/proplib.h 64.\" 65.Ft bool 66.Fn prop_dictionary_get_dict "prop_dictionary_t dict" "const char *key" \ 67 "prop_dictionary_t *dictp" 68.Ft bool 69.Fn prop_dictionary_get_bool "prop_dictionary_t dict" "const char *key" \ 70 "bool *valp" 71.Ft bool 72.Fn prop_dictionary_set_bool "prop_dictionary_t dict" "const char *key" \ 73 "bool val" 74.\" 75.Ft bool 76.Fn prop_dictionary_get_int8 "prop_dictionary_t dict" "const char *key" \ 77 "int8_t *valp" 78.Ft bool 79.Fn prop_dictionary_get_uint8 "prop_dictionary_t dict" "const char *key" \ 80 "uint8_t *valp" 81.Ft bool 82.Fn prop_dictionary_set_int8 "prop_dictionary_t dict" "const char *key" \ 83 "int8_t val" 84.Ft bool 85.Fn prop_dictionary_set_uint8 "prop_dictionary_t dict" "const char *key" \ 86 "uint8_t val" 87.\" 88.Ft bool 89.Fn prop_dictionary_get_int16 "prop_dictionary_t dict" "const char *key" \ 90 "int16_t *valp" 91.Ft bool 92.Fn prop_dictionary_get_uint16 "prop_dictionary_t dict" "const char *key" \ 93 "uint16_t *valp" 94.Ft bool 95.Fn prop_dictionary_set_int16 "prop_dictionary_t dict" "const char *key" \ 96 "int16_t val" 97.Ft bool 98.Fn prop_dictionary_set_uint16 "prop_dictionary_t dict" "const char *key" \ 99 "uint16_t val" 100.\" 101.Ft bool 102.Fn prop_dictionary_get_int32 "prop_dictionary_t dict" "const char *key" \ 103 "int32_t *valp" 104.Ft bool 105.Fn prop_dictionary_get_uint32 "prop_dictionary_t dict" "const char *key" \ 106 "uint32_t *valp" 107.Ft bool 108.Fn prop_dictionary_set_int32 "prop_dictionary_t dict" "const char *key" \ 109 "int32_t val" 110.Ft bool 111.Fn prop_dictionary_set_uint32 "prop_dictionary_t dict" "const char *key" \ 112 "uint32_t val" 113.\" 114.Ft bool 115.Fn prop_dictionary_get_int64 "prop_dictionary_t dict" "const char *key" \ 116 "int64_t *valp" 117.Ft bool 118.Fn prop_dictionary_get_uint64 "prop_dictionary_t dict" "const char *key" \ 119 "uint64_t *valp" 120.Ft bool 121.Fn prop_dictionary_set_int64 "prop_dictionary_t dict" "const char *key" \ 122 "int64_t val" 123.Ft bool 124.Fn prop_dictionary_set_uint64 "prop_dictionary_t dict" "const char *key" \ 125 "uint64_t val" 126.\" 127.Ft bool 128.Fn prop_dictionary_get_cstring "prop_dictionary_t dict" "const char *key" \ 129 "char **strp" 130.Ft bool 131.Fn prop_dictionary_set_cstring "prop_dictionary_t dict" "const char *key" \ 132 "const char *str" 133.\" 134.Ft bool 135.Fn prop_dictionary_get_cstring_nocopy "prop_dictionary_t dict" \ 136 "const char *key" "const char **strp" 137.Ft bool 138.Fn prop_dictionary_set_cstring_nocopy "prop_dictionary_t dict" \ 139 "const char *key" "const char *strp" 140.Ft bool 141.Fn prop_dictionary_set_and_rel "prop_dictionary_t dict" \ 142 "const char *key" "prop_object_t obj" 143.Sh DESCRIPTION 144The 145.Nm prop_dictionary_util 146family of functions are provided to make getting and setting values in 147dictionaries more convenient in some applications. 148.Pp 149The getters check the type of the returned object and, in some cases, also 150ensure that the returned value is within the range implied by the getter's 151value type. 152.Pp 153The setters handle object creation and release for the caller. 154.Pp 155The 156.Fn prop_dictionary_get_cstring 157function returns dynamically allocated memory. 158See 159.Xr prop_string 3 160for more information. 161.Pp 162The 163.Fn prop_dictionary_get_cstring_nocopy 164and 165.Fn prop_dictionary_set_cstring_nocopy 166functions do not copy the string that is set or returned. 167See 168.Xr prop_string 3 169for more information. 170.Pp 171The 172.Fn prop_dictionary_set_and_rel 173function adds the object to the dictionary and releases it. 174The object is also released on failure. 175.Sh RETURN VALUES 176The 177.Nm prop_dictionary_util 178getter functions return 179.Dv true 180if the object exists in the dictionary and the value is in-range, or 181.Dv false 182otherwise. 183.Pp 184The 185.Nm prop_dictionary_util 186setter functions return 187.Dv true 188if creating the object and storing it in the dictionary is successful, or 189.Dv false 190otherwise. 191.Sh SEE ALSO 192.Xr prop_bool 3 , 193.Xr prop_dictionary 3 , 194.Xr prop_number 3 , 195.Xr proplib 3 196.Sh HISTORY 197The 198.Nm proplib 199property container object library first appeared in 200.Nx 4.0 . 201