1.\" $NetBSD: prop_dictionary_util.3,v 1.10 2020/06/06 21:25:59 thorpej Exp $ 2.\" 3.\" Copyright (c) 2006, 2020 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 June 2, 2020 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_schar , 39.Nm prop_dictionary_get_uchar , 40.Nm prop_dictionary_set_schar , 41.Nm prop_dictionary_set_uchar , 42.Nm prop_dictionary_get_short , 43.Nm prop_dictionary_get_ushort , 44.Nm prop_dictionary_set_short , 45.Nm prop_dictionary_set_ushort , 46.Nm prop_dictionary_get_int , 47.Nm prop_dictionary_get_uint , 48.Nm prop_dictionary_set_int , 49.Nm prop_dictionary_set_uint , 50.Nm prop_dictionary_get_long , 51.Nm prop_dictionary_get_ulong , 52.Nm prop_dictionary_set_long , 53.Nm prop_dictionary_set_ulong , 54.Nm prop_dictionary_get_longlong , 55.Nm prop_dictionary_get_ulonglong , 56.Nm prop_dictionary_set_longlong , 57.Nm prop_dictionary_set_ulonglong , 58.Nm prop_dictionary_get_intptr , 59.Nm prop_dictionary_get_uintptr , 60.Nm prop_dictionary_set_intptr , 61.Nm prop_dictionary_set_uintptr , 62.Nm prop_dictionary_get_int8 , 63.Nm prop_dictionary_get_uint8 , 64.Nm prop_dictionary_set_int8 , 65.Nm prop_dictionary_set_uint8 , 66.Nm prop_dictionary_get_int16 , 67.Nm prop_dictionary_get_uint16 , 68.Nm prop_dictionary_set_int16 , 69.Nm prop_dictionary_set_uint16 , 70.Nm prop_dictionary_get_int32 , 71.Nm prop_dictionary_get_uint32 , 72.Nm prop_dictionary_set_int32 , 73.Nm prop_dictionary_set_uint32 , 74.Nm prop_dictionary_get_int64 , 75.Nm prop_dictionary_get_uint64 , 76.Nm prop_dictionary_set_int64 , 77.Nm prop_dictionary_set_uint64 , 78.Nm prop_dictionary_get_data , 79.Nm prop_dictionary_set_data , 80.Nm prop_dictionary_set_data_nocopy , 81.Nm prop_dictionary_get_string , 82.Nm prop_dictionary_set_string , 83.Nm prop_dictionary_set_string_nocopy , 84.Nm prop_dictionary_set_and_rel 85.Nd dictionary property collection object utility functions 86.Sh LIBRARY 87.Lb libprop 88.Sh SYNOPSIS 89.In prop/proplib.h 90.\" 91.Ft bool 92.Fn prop_dictionary_get_dict "prop_dictionary_t dict" "const char *key" \ 93 "prop_dictionary_t *dictp" 94.Ft bool 95.Fn prop_dictionary_get_bool "prop_dictionary_t dict" "const char *key" \ 96 "bool *valp" 97.Ft bool 98.Fn prop_dictionary_set_bool "prop_dictionary_t dict" "const char *key" \ 99 "bool val" 100.\" 101.Ft bool 102.Fn prop_dictionary_get_schar "prop_dictionary_t dict" "const char *key" \ 103 "signed char *valp" 104.Ft bool 105.Fn prop_dictionary_get_uchar "prop_dictionary_t dict" "const char *key" \ 106 "unsigned char *valp" 107.Ft bool 108.Fn prop_dictionary_set_schar "prop_dictionary_t dict" "const char *key" \ 109 "signed char val" 110.Ft bool 111.Fn prop_dictionary_set_uchar "prop_dictionary_t dict" "const char *key" \ 112 "unsigned char val" 113.\" 114.Ft bool 115.Fn prop_dictionary_get_short "prop_dictionary_t dict" "const char *key" \ 116 "short *valp" 117.Ft bool 118.Fn prop_dictionary_get_ushort "prop_dictionary_t dict" "const char *key" \ 119 "unsigned short *valp" 120.Ft bool 121.Fn prop_dictionary_set_short "prop_dictionary_t dict" "const char *key" \ 122 "short val" 123.Ft bool 124.Fn prop_dictionary_set_ushort "prop_dictionary_t dict" "const char *key" \ 125 "unsigned short val" 126.\" 127.Ft bool 128.Fn prop_dictionary_get_int "prop_dictionary_t dict" "const char *key" \ 129 "int *valp" 130.Ft bool 131.Fn prop_dictionary_get_uint "prop_dictionary_t dict" "const char *key" \ 132 "unsigned int *valp" 133.Ft bool 134.Fn prop_dictionary_set_int "prop_dictionary_t dict" "const char *key" \ 135 "int val" 136.Ft bool 137.Fn prop_dictionary_set_uint "prop_dictionary_t dict" "const char *key" \ 138 "unsigned int val" 139.\" 140.Ft bool 141.Fn prop_dictionary_get_long "prop_dictionary_t dict" "const char *key" \ 142 "long *valp" 143.Ft bool 144.Fn prop_dictionary_get_ulong "prop_dictionary_t dict" "const char *key" \ 145 "unsigned long *valp" 146.Ft bool 147.Fn prop_dictionary_set_long "prop_dictionary_t dict" "const char *key" \ 148 "long val" 149.Ft bool 150.Fn prop_dictionary_set_ulong "prop_dictionary_t dict" "const char *key" \ 151 "unsigned long val" 152.\" 153.Ft bool 154.Fn prop_dictionary_get_longlong "prop_dictionary_t dict" "const char *key" \ 155 "long long *valp" 156.Ft bool 157.Fn prop_dictionary_get_ulonglong "prop_dictionary_t dict" "const char *key" \ 158 "unsigned long long *valp" 159.Ft bool 160.Fn prop_dictionary_set_longlong "prop_dictionary_t dict" "const char *key" \ 161 "long long val" 162.Ft bool 163.Fn prop_dictionary_set_ulonglong "prop_dictionary_t dict" "const char *key" \ 164 "unsigned long long val" 165.\" 166.Ft bool 167.Fn prop_dictionary_get_intptr "prop_dictionary_t dict" "const char *key" \ 168 "intptr_t *valp" 169.Ft bool 170.Fn prop_dictionary_get_uintptr "prop_dictionary_t dict" "const char *key" \ 171 "uintptr_t *valp" 172.Ft bool 173.Fn prop_dictionary_set_intptr "prop_dictionary_t dict" "const char *key" \ 174 "intptr_t val" 175.Ft bool 176.Fn prop_dictionary_set_uintptr "prop_dictionary_t dict" "const char *key" \ 177 "uintptr_t val" 178.\" 179.Ft bool 180.Fn prop_dictionary_get_int8 "prop_dictionary_t dict" "const char *key" \ 181 "int8_t *valp" 182.Ft bool 183.Fn prop_dictionary_get_uint8 "prop_dictionary_t dict" "const char *key" \ 184 "uint8_t *valp" 185.Ft bool 186.Fn prop_dictionary_set_int8 "prop_dictionary_t dict" "const char *key" \ 187 "int8_t val" 188.Ft bool 189.Fn prop_dictionary_set_uint8 "prop_dictionary_t dict" "const char *key" \ 190 "uint8_t val" 191.\" 192.Ft bool 193.Fn prop_dictionary_get_int16 "prop_dictionary_t dict" "const char *key" \ 194 "int16_t *valp" 195.Ft bool 196.Fn prop_dictionary_get_uint16 "prop_dictionary_t dict" "const char *key" \ 197 "uint16_t *valp" 198.Ft bool 199.Fn prop_dictionary_set_int16 "prop_dictionary_t dict" "const char *key" \ 200 "int16_t val" 201.Ft bool 202.Fn prop_dictionary_set_uint16 "prop_dictionary_t dict" "const char *key" \ 203 "uint16_t val" 204.\" 205.Ft bool 206.Fn prop_dictionary_get_int32 "prop_dictionary_t dict" "const char *key" \ 207 "int32_t *valp" 208.Ft bool 209.Fn prop_dictionary_get_uint32 "prop_dictionary_t dict" "const char *key" \ 210 "uint32_t *valp" 211.Ft bool 212.Fn prop_dictionary_set_int32 "prop_dictionary_t dict" "const char *key" \ 213 "int32_t val" 214.Ft bool 215.Fn prop_dictionary_set_uint32 "prop_dictionary_t dict" "const char *key" \ 216 "uint32_t val" 217.\" 218.Ft bool 219.Fn prop_dictionary_get_int64 "prop_dictionary_t dict" "const char *key" \ 220 "int64_t *valp" 221.Ft bool 222.Fn prop_dictionary_get_uint64 "prop_dictionary_t dict" "const char *key" \ 223 "uint64_t *valp" 224.Ft bool 225.Fn prop_dictionary_set_int64 "prop_dictionary_t dict" "const char *key" \ 226 "int64_t val" 227.Ft bool 228.Fn prop_dictionary_set_uint64 "prop_dictionary_t dict" "const char *key" \ 229 "uint64_t val" 230.\" 231.Ft bool 232.Fn prop_dictionary_get_cstring "prop_dictionary_t dict" "const char *key" \ 233 "char **strp" 234.Ft bool 235.Fn prop_dictionary_set_cstring "prop_dictionary_t dict" "const char *key" \ 236 "const char *str" 237.\" 238.Ft bool 239.Fn prop_dictionary_get_data "prop_dictionary_t dict" \ 240 "const char *key" "const void **datap" "size_t *sizep" 241.Ft bool 242.Fn prop_dictionary_set_data "prop_dictionary_t dict" \ 243 "const char *key" "const void *data" "size_t len" 244.Ft bool 245.Fn prop_dictionary_set_data_nocopy "prop_dictionary_t dict" \ 246 "const char *key" "const void *data" "size_t len" 247.\" 248.Ft bool 249.Fn prop_dictionary_get_string "prop_dictionary_t dict" \ 250 "const char *key" "const char **strp" 251.Ft bool 252.Fn prop_dictionary_set_string "prop_dictionary_t dict" \ 253 "const char *key" "const char *strp" 254.Ft bool 255.Fn prop_dictionary_set_string_nocopy "prop_dictionary_t dict" \ 256 "const char *key" "const char *strp" 257.\" 258.Ft bool 259.Fn prop_dictionary_set_and_rel "prop_dictionary_t dict" \ 260 "const char *key" "prop_object_t obj" 261.Sh DESCRIPTION 262The 263.Nm 264family of functions are provided to make getting and setting values in 265dictionaries more convenient in some applications. 266.Pp 267The getters check the type of the returned object and, in some cases, also 268ensure that the returned value is within the range implied by the getter's 269value type. 270.Pp 271The setters handle object creation and release for the caller. 272.Pp 273If the 274.Fa sizep 275argument to 276.Fn prop_dictionary_get_data 277is not 278.Dv NULL , 279then it will be set to the size of the returned data. 280.Pp 281The 282.Fn prop_dictionary_get_data 283and 284.Fn prop_dictionary_set_data_nocopy 285functions do not copy the data that is set or returned. 286See 287.Xr prop_data 3 288for more information. 289.Pp 290The 291.Fn prop_dictionary_get_string 292and 293.Fn prop_dictionary_set_string_nocopy 294functions do not copy the string that is set or returned. 295See 296.Xr prop_string 3 297for more information. 298.Pp 299The 300.Fn prop_dictionary_set_and_rel 301function adds the object to the dictionary and releases it. 302The object is always released, even if adding it to the dictionary fails. 303.Sh RETURN VALUES 304The 305.Nm 306getter functions return 307.Dv true 308if the object exists in the dictionary and the value is in-range, or 309.Dv false 310otherwise. 311.Pp 312The 313.Nm 314setter functions return 315.Dv true 316if creating the object and storing it in the dictionary is successful, or 317.Dv false 318otherwise. 319.Sh SEE ALSO 320.Xr prop_bool 3 , 321.Xr prop_data 3 , 322.Xr prop_dictionary 3 , 323.Xr prop_number 3 , 324.Xr prop_string 3 , 325.Xr proplib 3 326.Sh HISTORY 327The 328.Xr proplib 3 329property container object library first appeared in 330.Nx 4.0 . 331