1*2e9d4914SAndroid Build Coastguard Worker\input texinfo.tex @c -*-texinfo-*- 2*2e9d4914SAndroid Build Coastguard Worker@c 3*2e9d4914SAndroid Build Coastguard Worker@c %**start of header 4*2e9d4914SAndroid Build Coastguard Worker 5*2e9d4914SAndroid Build Coastguard Worker@c All text is ignored before the setfilename. 6*2e9d4914SAndroid Build Coastguard Worker@setfilename libconfig.info 7*2e9d4914SAndroid Build Coastguard Worker@settitle libconfig 8*2e9d4914SAndroid Build Coastguard Worker 9*2e9d4914SAndroid Build Coastguard Worker@set edition 1.7.3 10*2e9d4914SAndroid Build Coastguard Worker@set update-date 20 Jun 2021 11*2e9d4914SAndroid Build Coastguard Worker@set subtitle-text A Library For Processing Structured Configuration Files 12*2e9d4914SAndroid Build Coastguard Worker@set author-text Mark A.@: Lindner 13*2e9d4914SAndroid Build Coastguard Worker 14*2e9d4914SAndroid Build Coastguard Worker@comment %**end of header 15*2e9d4914SAndroid Build Coastguard Worker 16*2e9d4914SAndroid Build Coastguard Worker@firstparagraphindent insert 17*2e9d4914SAndroid Build Coastguard Worker 18*2e9d4914SAndroid Build Coastguard Worker@dircategory Software libraries 19*2e9d4914SAndroid Build Coastguard Worker@direntry 20*2e9d4914SAndroid Build Coastguard Worker* libconfig: (libconfig). A Library For Processing Structured Configuration Files 21*2e9d4914SAndroid Build Coastguard Worker@end direntry 22*2e9d4914SAndroid Build Coastguard Worker 23*2e9d4914SAndroid Build Coastguard Worker 24*2e9d4914SAndroid Build Coastguard Worker@tex 25*2e9d4914SAndroid Build Coastguard Worker\global\emergencystretch = .3\hsize 26*2e9d4914SAndroid Build Coastguard Worker@end tex 27*2e9d4914SAndroid Build Coastguard Worker 28*2e9d4914SAndroid Build Coastguard Worker@setchapternewpage odd 29*2e9d4914SAndroid Build Coastguard Worker 30*2e9d4914SAndroid Build Coastguard Worker@titlepage 31*2e9d4914SAndroid Build Coastguard Worker 32*2e9d4914SAndroid Build Coastguard Worker@title libconfig 33*2e9d4914SAndroid Build Coastguard Worker@subtitle @value{subtitle-text} 34*2e9d4914SAndroid Build Coastguard Worker@subtitle Version @value{edition} 35*2e9d4914SAndroid Build Coastguard Worker@subtitle @value{update-date} 36*2e9d4914SAndroid Build Coastguard Worker 37*2e9d4914SAndroid Build Coastguard Worker@author @value{author-text} 38*2e9d4914SAndroid Build Coastguard Worker 39*2e9d4914SAndroid Build Coastguard Worker@page 40*2e9d4914SAndroid Build Coastguard Worker@vskip 0pt plus 1filll 41*2e9d4914SAndroid Build Coastguard WorkerCopyright @copyright{} 2004-2021 Mark A Lindner 42*2e9d4914SAndroid Build Coastguard Worker 43*2e9d4914SAndroid Build Coastguard WorkerPermission is granted to make and distribute verbatim copies of 44*2e9d4914SAndroid Build Coastguard Workerthis manual provided the copyright notice and this permission notice 45*2e9d4914SAndroid Build Coastguard Workerare preserved on all copies. 46*2e9d4914SAndroid Build Coastguard Worker 47*2e9d4914SAndroid Build Coastguard WorkerPermission is granted to copy and distribute modified versions of this 48*2e9d4914SAndroid Build Coastguard Workermanual under the conditions for verbatim copying, provided that the entire 49*2e9d4914SAndroid Build Coastguard Workerresulting derived work is distributed under the terms of a permission 50*2e9d4914SAndroid Build Coastguard Workernotice identical to this one. 51*2e9d4914SAndroid Build Coastguard Worker 52*2e9d4914SAndroid Build Coastguard Worker@end titlepage 53*2e9d4914SAndroid Build Coastguard Worker 54*2e9d4914SAndroid Build Coastguard Worker@c Give the HTML output a title page that somewhat resembles the printed one 55*2e9d4914SAndroid Build Coastguard Worker@ifhtml 56*2e9d4914SAndroid Build Coastguard Worker@html 57*2e9d4914SAndroid Build Coastguard Worker<hr noshade size=6 color="black"> 58*2e9d4914SAndroid Build Coastguard Worker<div align=right>@value{subtitle-text}<br> 59*2e9d4914SAndroid Build Coastguard WorkerVersion @value{edition}<br> 60*2e9d4914SAndroid Build Coastguard Worker@value{update-date}</div> 61*2e9d4914SAndroid Build Coastguard Worker<br><br><br><br> 62*2e9d4914SAndroid Build Coastguard Worker<font size=+1>@value{author-text}</font> 63*2e9d4914SAndroid Build Coastguard Worker<hr size=3 noshade color="black"> 64*2e9d4914SAndroid Build Coastguard Worker<br><br> 65*2e9d4914SAndroid Build Coastguard Worker@end html 66*2e9d4914SAndroid Build Coastguard Worker@end ifhtml 67*2e9d4914SAndroid Build Coastguard Worker 68*2e9d4914SAndroid Build Coastguard Worker@contents 69*2e9d4914SAndroid Build Coastguard Worker 70*2e9d4914SAndroid Build Coastguard Worker@ifnottex 71*2e9d4914SAndroid Build Coastguard Worker@node Top 72*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 73*2e9d4914SAndroid Build Coastguard Worker@top libconfig 74*2e9d4914SAndroid Build Coastguard Worker@end ifnottex 75*2e9d4914SAndroid Build Coastguard Worker 76*2e9d4914SAndroid Build Coastguard Worker@menu 77*2e9d4914SAndroid Build Coastguard Worker* Introduction:: 78*2e9d4914SAndroid Build Coastguard Worker* Configuration Files:: 79*2e9d4914SAndroid Build Coastguard Worker* The C API:: 80*2e9d4914SAndroid Build Coastguard Worker* The C++ API:: 81*2e9d4914SAndroid Build Coastguard Worker* Example Programs:: 82*2e9d4914SAndroid Build Coastguard Worker* Other Bindings and Implementations:: 83*2e9d4914SAndroid Build Coastguard Worker* License:: 84*2e9d4914SAndroid Build Coastguard Worker* Configuration File Grammar:: 85*2e9d4914SAndroid Build Coastguard Worker* Function Index:: 86*2e9d4914SAndroid Build Coastguard Worker* Type Index:: 87*2e9d4914SAndroid Build Coastguard Worker* Concept Index:: 88*2e9d4914SAndroid Build Coastguard Worker@end menu 89*2e9d4914SAndroid Build Coastguard Worker 90*2e9d4914SAndroid Build Coastguard Worker@node Introduction, Configuration Files, Top, Top 91*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 92*2e9d4914SAndroid Build Coastguard Worker@menu 93*2e9d4914SAndroid Build Coastguard Worker* Why Another Configuration File Library?:: 94*2e9d4914SAndroid Build Coastguard Worker* Using the Library from a C Program:: 95*2e9d4914SAndroid Build Coastguard Worker* Using the Library from a C++ Program:: 96*2e9d4914SAndroid Build Coastguard Worker* Multithreading Issues:: 97*2e9d4914SAndroid Build Coastguard Worker* Internationalization Issues:: 98*2e9d4914SAndroid Build Coastguard Worker* Compiling Using pkg-config:: 99*2e9d4914SAndroid Build Coastguard Worker* Version Test Macros:: 100*2e9d4914SAndroid Build Coastguard Worker@end menu 101*2e9d4914SAndroid Build Coastguard Worker@chapter Introduction 102*2e9d4914SAndroid Build Coastguard Worker 103*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} is a library for reading, manipulating, and writing 104*2e9d4914SAndroid Build Coastguard Workerstructured configuration files. The library features a fully 105*2e9d4914SAndroid Build Coastguard Workerreentrant parser and includes bindings for both the C and C++ 106*2e9d4914SAndroid Build Coastguard Workerprogramming languages. 107*2e9d4914SAndroid Build Coastguard Worker 108*2e9d4914SAndroid Build Coastguard WorkerThe library runs on modern POSIX-compilant systems, such as Linux, 109*2e9d4914SAndroid Build Coastguard WorkerSolaris, and Mac OS X (Darwin), as well as on Microsoft Windows 110*2e9d4914SAndroid Build Coastguard Worker2000/XP and later (with either Microsoft Visual Studio 2005 or later, 111*2e9d4914SAndroid Build Coastguard Workeror the GNU toolchain via the MinGW environment). 112*2e9d4914SAndroid Build Coastguard Worker 113*2e9d4914SAndroid Build Coastguard Worker@node Why Another Configuration File Library?, Using the Library from a C Program, , Introduction 114*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 115*2e9d4914SAndroid Build Coastguard Worker@section Why Another Configuration File Library? 116*2e9d4914SAndroid Build Coastguard Worker 117*2e9d4914SAndroid Build Coastguard WorkerThere are several open-source configuration file libraries available 118*2e9d4914SAndroid Build Coastguard Workeras of this writing. This library was written because each of those 119*2e9d4914SAndroid Build Coastguard Workerlibraries falls short in one or more ways. The main features of 120*2e9d4914SAndroid Build Coastguard Worker@i{libconfig} that set it apart from the other libraries are: 121*2e9d4914SAndroid Build Coastguard Worker 122*2e9d4914SAndroid Build Coastguard Worker@itemize @bullet 123*2e9d4914SAndroid Build Coastguard Worker 124*2e9d4914SAndroid Build Coastguard Worker@item A fully reentrant parser. Independent configurations can be parsed in concurrent threads at the same time. 125*2e9d4914SAndroid Build Coastguard Worker 126*2e9d4914SAndroid Build Coastguard Worker@item Both C @i{and} C++ bindings, as well as hooks to allow for the creation of wrappers in other languages. 127*2e9d4914SAndroid Build Coastguard Worker 128*2e9d4914SAndroid Build Coastguard Worker@item A simple, structured configuration file format that is more 129*2e9d4914SAndroid Build Coastguard Workerreadable and compact than XML and more flexible than the obsolete but 130*2e9d4914SAndroid Build Coastguard Workerprevalent Windows ``INI'' file format. 131*2e9d4914SAndroid Build Coastguard Worker 132*2e9d4914SAndroid Build Coastguard Worker@item A low-footprint implementation (just 37K for the C library and 76K for 133*2e9d4914SAndroid Build Coastguard Workerthe C++ library) that is suitable for memory-constrained systems. 134*2e9d4914SAndroid Build Coastguard Worker 135*2e9d4914SAndroid Build Coastguard Worker@item Proper documentation. 136*2e9d4914SAndroid Build Coastguard Worker 137*2e9d4914SAndroid Build Coastguard Worker@end itemize 138*2e9d4914SAndroid Build Coastguard Worker 139*2e9d4914SAndroid Build Coastguard Worker@node Using the Library from a C Program, Using the Library from a C++ Program, Why Another Configuration File Library?, Introduction 140*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 141*2e9d4914SAndroid Build Coastguard Worker@section Using the Library from a C Program 142*2e9d4914SAndroid Build Coastguard Worker 143*2e9d4914SAndroid Build Coastguard WorkerTo use the library from C code, include the following preprocessor 144*2e9d4914SAndroid Build Coastguard Workerdirective in your source files: 145*2e9d4914SAndroid Build Coastguard Worker 146*2e9d4914SAndroid Build Coastguard Worker@sp 1 147*2e9d4914SAndroid Build Coastguard Worker@smallexample 148*2e9d4914SAndroid Build Coastguard Worker#include <libconfig.h> 149*2e9d4914SAndroid Build Coastguard Worker@end smallexample 150*2e9d4914SAndroid Build Coastguard Worker@sp 1 151*2e9d4914SAndroid Build Coastguard Worker 152*2e9d4914SAndroid Build Coastguard WorkerTo link with the library, specify @samp{-lconfig} as an argument to the 153*2e9d4914SAndroid Build Coastguard Workerlinker. 154*2e9d4914SAndroid Build Coastguard Worker 155*2e9d4914SAndroid Build Coastguard Worker@node Using the Library from a C++ Program, Multithreading Issues, Using the Library from a C Program, Introduction 156*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 157*2e9d4914SAndroid Build Coastguard Worker@section Using the Library from a C++ Program 158*2e9d4914SAndroid Build Coastguard Worker 159*2e9d4914SAndroid Build Coastguard WorkerTo use the library from C++, include the following preprocessor 160*2e9d4914SAndroid Build Coastguard Workerdirective in your source files: 161*2e9d4914SAndroid Build Coastguard Worker 162*2e9d4914SAndroid Build Coastguard Worker@sp 1 163*2e9d4914SAndroid Build Coastguard Worker@smallexample 164*2e9d4914SAndroid Build Coastguard Worker#include <libconfig.h++> 165*2e9d4914SAndroid Build Coastguard Worker@end smallexample 166*2e9d4914SAndroid Build Coastguard Worker@sp 1 167*2e9d4914SAndroid Build Coastguard Worker 168*2e9d4914SAndroid Build Coastguard WorkerOr, alternatively: 169*2e9d4914SAndroid Build Coastguard Worker 170*2e9d4914SAndroid Build Coastguard Worker@sp 1 171*2e9d4914SAndroid Build Coastguard Worker@smallexample 172*2e9d4914SAndroid Build Coastguard Worker#include <libconfig.hh> 173*2e9d4914SAndroid Build Coastguard Worker@end smallexample 174*2e9d4914SAndroid Build Coastguard Worker@sp 1 175*2e9d4914SAndroid Build Coastguard Worker@page 176*2e9d4914SAndroid Build Coastguard WorkerThe C++ API classes are defined in the namespace @samp{libconfig}, hence the 177*2e9d4914SAndroid Build Coastguard Workerfollowing statement may optionally be used: 178*2e9d4914SAndroid Build Coastguard Worker 179*2e9d4914SAndroid Build Coastguard Worker@sp 1 180*2e9d4914SAndroid Build Coastguard Worker@smallexample 181*2e9d4914SAndroid Build Coastguard Workerusing namespace libconfig; 182*2e9d4914SAndroid Build Coastguard Worker@end smallexample 183*2e9d4914SAndroid Build Coastguard Worker@sp 1 184*2e9d4914SAndroid Build Coastguard Worker 185*2e9d4914SAndroid Build Coastguard WorkerTo link with the library, specify @samp{-lconfig++} as an argument to 186*2e9d4914SAndroid Build Coastguard Workerthe linker. 187*2e9d4914SAndroid Build Coastguard Worker 188*2e9d4914SAndroid Build Coastguard Worker@node Multithreading Issues, Internationalization Issues, Using the Library from a C++ Program, Introduction 189*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 190*2e9d4914SAndroid Build Coastguard Worker@section Multithreading Issues 191*2e9d4914SAndroid Build Coastguard Worker 192*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} is fully @dfn{reentrant}; the functions in the library 193*2e9d4914SAndroid Build Coastguard Workerdo not make use of global variables and do not maintain state between 194*2e9d4914SAndroid Build Coastguard Workersuccessive calls. Therefore two independent configurations may be safely 195*2e9d4914SAndroid Build Coastguard Workermanipulated concurrently by two distinct threads. 196*2e9d4914SAndroid Build Coastguard Worker 197*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} is not @dfn{thread-safe}. The library is not aware of 198*2e9d4914SAndroid Build Coastguard Workerthe presence of threads and knows nothing about the host system's 199*2e9d4914SAndroid Build Coastguard Workerthreading model. Therefore, if an instance of a configuration is to be 200*2e9d4914SAndroid Build Coastguard Workeraccessed from multiple threads, it must be suitably protected by 201*2e9d4914SAndroid Build Coastguard Workersynchronization mechanisms like read-write locks or mutexes; the 202*2e9d4914SAndroid Build Coastguard Workerstandard rules for safe multithreaded access to shared data must be 203*2e9d4914SAndroid Build Coastguard Workerobserved. 204*2e9d4914SAndroid Build Coastguard Worker 205*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} is not @dfn{async-safe}. Calls should not be made into 206*2e9d4914SAndroid Build Coastguard Workerthe library from signal handlers, because some of the C library 207*2e9d4914SAndroid Build Coastguard Workerroutines that it uses may not be async-safe. 208*2e9d4914SAndroid Build Coastguard Worker 209*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} is not guaranteed to be @dfn{cancel-safe}. Since it is 210*2e9d4914SAndroid Build Coastguard Workernot aware of the host system's threading model, the library does not 211*2e9d4914SAndroid Build Coastguard Workercontain any thread cancellation points. In most cases this will not be 212*2e9d4914SAndroid Build Coastguard Workeran issue for multithreaded programs. However, be aware that some of 213*2e9d4914SAndroid Build Coastguard Workerthe routines in the library (namely those that read/write 214*2e9d4914SAndroid Build Coastguard Workerconfigurations from/to files or streams) perform I/O using C library 215*2e9d4914SAndroid Build Coastguard Workerroutines which may potentially block; whether or not these C library 216*2e9d4914SAndroid Build Coastguard Workerroutines are cancel-safe depends on the host system. 217*2e9d4914SAndroid Build Coastguard Worker 218*2e9d4914SAndroid Build Coastguard Worker@node Internationalization Issues, Compiling Using pkg-config, Multithreading Issues, Introduction 219*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 220*2e9d4914SAndroid Build Coastguard Worker@section Internationalization Issues 221*2e9d4914SAndroid Build Coastguard Worker 222*2e9d4914SAndroid Build Coastguard Worker@cindex Unicode 223*2e9d4914SAndroid Build Coastguard Worker@cindex UTF-8 224*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} does not natively support Unicode configuration files, 225*2e9d4914SAndroid Build Coastguard Workerbut string values may contain Unicode text encoded in UTF-8; such 226*2e9d4914SAndroid Build Coastguard Workerstrings will be treated as ordinary 8-bit ASCII text by the 227*2e9d4914SAndroid Build Coastguard Workerlibrary. It is the responsibility of the calling program to perform 228*2e9d4914SAndroid Build Coastguard Workerthe necessary conversions to/from wide (@t{wchar_t}) strings using the 229*2e9d4914SAndroid Build Coastguard Workerwide string conversion functions such as @t{mbsrtowcs()} and 230*2e9d4914SAndroid Build Coastguard Worker@t{wcsrtombs()} or the @t{iconv()} function of the @i{libiconv} 231*2e9d4914SAndroid Build Coastguard Workerlibrary. 232*2e9d4914SAndroid Build Coastguard Worker 233*2e9d4914SAndroid Build Coastguard Worker@cindex locale 234*2e9d4914SAndroid Build Coastguard WorkerThe textual representation of a floating point value varies by 235*2e9d4914SAndroid Build Coastguard Workerlocale. However, the @i{libconfig} grammar specifies that 236*2e9d4914SAndroid Build Coastguard Workerfloating point values are represented using a period (`.') as the 237*2e9d4914SAndroid Build Coastguard Workerradix symbol; this is consistent with the grammar of most programming 238*2e9d4914SAndroid Build Coastguard Workerlanguages. When a configuration is read in or written out, 239*2e9d4914SAndroid Build Coastguard Worker@i{libconfig} temporarily changes the @t{LC_NUMERIC} category of the 240*2e9d4914SAndroid Build Coastguard Workerlocale of the calling thread to the ``C'' locale to ensure consistent 241*2e9d4914SAndroid Build Coastguard Workerhandling of floating point values regardless of the locale(s) in use 242*2e9d4914SAndroid Build Coastguard Workerby the calling program. 243*2e9d4914SAndroid Build Coastguard Worker 244*2e9d4914SAndroid Build Coastguard WorkerNote that the MinGW environment does not (as of this writing) provide 245*2e9d4914SAndroid Build Coastguard Workerfunctions for changing the locale of the calling thread. Therefore, 246*2e9d4914SAndroid Build Coastguard Workerwhen using @i{libconfig} in that environment, the calling program is 247*2e9d4914SAndroid Build Coastguard Workerresponsible for changing the @t{LC_NUMERIC} category of the locale to 248*2e9d4914SAndroid Build Coastguard Workerthe "C" locale before reading or writing a configuration. 249*2e9d4914SAndroid Build Coastguard Worker 250*2e9d4914SAndroid Build Coastguard Worker@node Compiling Using pkg-config, Version Test Macros, Internationalization Issues, Introduction 251*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 252*2e9d4914SAndroid Build Coastguard Worker@section Compiling Using pkg-config 253*2e9d4914SAndroid Build Coastguard Worker 254*2e9d4914SAndroid Build Coastguard Worker@cindex pkg-config 255*2e9d4914SAndroid Build Coastguard WorkerOn UNIX systems you can use the @i{pkg-config} utility (version 0.20 256*2e9d4914SAndroid Build Coastguard Workeror later) to automatically select the appropriate compiler and linker 257*2e9d4914SAndroid Build Coastguard Workerswitches for @i{libconfig}. Ensure that the environment variable 258*2e9d4914SAndroid Build Coastguard Worker@code{PKG_CONFIG_PATH} contains the absolute path to the 259*2e9d4914SAndroid Build Coastguard Worker@file{lib/pkgconfig} subdirectory of the @i{libconfig} installation. Then, 260*2e9d4914SAndroid Build Coastguard Workeryou can compile and link C programs with @i{libconfig} as follows: 261*2e9d4914SAndroid Build Coastguard Worker 262*2e9d4914SAndroid Build Coastguard Worker@smallexample 263*2e9d4914SAndroid Build Coastguard Workergcc `pkg-config --cflags libconfig` myprogram.c -o myprogram \ 264*2e9d4914SAndroid Build Coastguard Worker `pkg-config --libs libconfig` 265*2e9d4914SAndroid Build Coastguard Worker@end smallexample 266*2e9d4914SAndroid Build Coastguard Worker@sp 1 267*2e9d4914SAndroid Build Coastguard Worker 268*2e9d4914SAndroid Build Coastguard WorkerAnd similarly, for C++ programs: 269*2e9d4914SAndroid Build Coastguard Worker 270*2e9d4914SAndroid Build Coastguard Worker@smallexample 271*2e9d4914SAndroid Build Coastguard Workerg++ `pkg-config --cflags libconfig++` myprogram.cpp -o myprogram \ 272*2e9d4914SAndroid Build Coastguard Worker `pkg-config --libs libconfig++` 273*2e9d4914SAndroid Build Coastguard Worker@end smallexample 274*2e9d4914SAndroid Build Coastguard Worker 275*2e9d4914SAndroid Build Coastguard Worker@sp 1 276*2e9d4914SAndroid Build Coastguard WorkerNote the backticks in the above examples. 277*2e9d4914SAndroid Build Coastguard Worker 278*2e9d4914SAndroid Build Coastguard WorkerWhen using @b{autoconf}, the @code{PKG_CHECK_MODULES} m4 macro may be used to check for the presence of a given version of @i{libconfig}, and set the appropriate Makefile variables automatically. For example: 279*2e9d4914SAndroid Build Coastguard Worker 280*2e9d4914SAndroid Build Coastguard Worker@smallexample 281*2e9d4914SAndroid Build Coastguard WorkerPKG_CHECK_MODULES([LIBCONFIGXX], [libconfig++ >= 1.4],, 282*2e9d4914SAndroid Build Coastguard Worker AC_MSG_ERROR([libconfig++ 1.4 or newer not found.]) 283*2e9d4914SAndroid Build Coastguard Worker) 284*2e9d4914SAndroid Build Coastguard Worker@end smallexample 285*2e9d4914SAndroid Build Coastguard Worker 286*2e9d4914SAndroid Build Coastguard WorkerIn the above example, if @i{libconfig++} version 1.4 or newer is found, 287*2e9d4914SAndroid Build Coastguard Workerthe Makefile variables @code{LIBCONFIGXX_LIBS} and @code{LIBCONFIGXX_CFLAGS} will be 288*2e9d4914SAndroid Build Coastguard Workerset to the appropriate compiler and linker flags for compiling with 289*2e9d4914SAndroid Build Coastguard Worker@i{libconfig}, and if it is not found, the configure script will abort 290*2e9d4914SAndroid Build Coastguard Workerwith an error to that effect. 291*2e9d4914SAndroid Build Coastguard Worker 292*2e9d4914SAndroid Build Coastguard Worker@node Version Test Macros, , Compiling Using pkg-config, Introduction 293*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 294*2e9d4914SAndroid Build Coastguard Worker@section Version Test Macros 295*2e9d4914SAndroid Build Coastguard Worker 296*2e9d4914SAndroid Build Coastguard WorkerThe @file{libconfig.h} header declares the following macros: 297*2e9d4914SAndroid Build Coastguard Worker 298*2e9d4914SAndroid Build Coastguard Worker@defmac LIBCONFIG_VER_MAJOR 299*2e9d4914SAndroid Build Coastguard Worker@defmacx LIBCONFIG_VER_MINOR 300*2e9d4914SAndroid Build Coastguard Worker@defmacx LIBCONFIG_VER_REVISION 301*2e9d4914SAndroid Build Coastguard Worker 302*2e9d4914SAndroid Build Coastguard WorkerThese macros represent the major version, minor version, and revision 303*2e9d4914SAndroid Build Coastguard Workerof the @i{libconfig} library. For example, in @i{libconfig} 1.4 these 304*2e9d4914SAndroid Build Coastguard Workerare defined as @samp{1}, @samp{4}, and @samp{0}, respectively. These 305*2e9d4914SAndroid Build Coastguard Workermacros can be used in preprocessor directives to determine which 306*2e9d4914SAndroid Build Coastguard Worker@i{libconfig} features and/or APIs are present. For example: 307*2e9d4914SAndroid Build Coastguard Worker 308*2e9d4914SAndroid Build Coastguard Worker@smallexample 309*2e9d4914SAndroid Build Coastguard Worker#if (((LIBCONFIG_VER_MAJOR == 1) && (LIBCONFIG_VER_MINOR >= 4)) \ 310*2e9d4914SAndroid Build Coastguard Worker || (LIBCONFIG_VER_MAJOR > 1)) 311*2e9d4914SAndroid Build Coastguard Worker /* use features present in libconfig 1.4 and later */ 312*2e9d4914SAndroid Build Coastguard Worker#endif 313*2e9d4914SAndroid Build Coastguard Worker@end smallexample 314*2e9d4914SAndroid Build Coastguard Worker 315*2e9d4914SAndroid Build Coastguard WorkerThese macros were introduced in @i{libconfig} 1.4. 316*2e9d4914SAndroid Build Coastguard Worker 317*2e9d4914SAndroid Build Coastguard Worker@end defmac 318*2e9d4914SAndroid Build Coastguard Worker 319*2e9d4914SAndroid Build Coastguard WorkerSimilarly, the @file{libconfig.h++} header declares the following macros: 320*2e9d4914SAndroid Build Coastguard Worker 321*2e9d4914SAndroid Build Coastguard Worker@defmac LIBCONFIGXX_VER_MAJOR 322*2e9d4914SAndroid Build Coastguard Worker@defmacx LIBCONFIGXX_VER_MINOR 323*2e9d4914SAndroid Build Coastguard Worker@defmacx LIBCONFIGXX_VER_REVISION 324*2e9d4914SAndroid Build Coastguard Worker 325*2e9d4914SAndroid Build Coastguard WorkerThese macros represent the major version, minor version, and revision 326*2e9d4914SAndroid Build Coastguard Workerof the @i{libconfig++} library. 327*2e9d4914SAndroid Build Coastguard Worker 328*2e9d4914SAndroid Build Coastguard Worker@end defmac 329*2e9d4914SAndroid Build Coastguard Worker 330*2e9d4914SAndroid Build Coastguard Worker@node Configuration Files, The C API, Introduction, Top 331*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 332*2e9d4914SAndroid Build Coastguard Worker@menu 333*2e9d4914SAndroid Build Coastguard Worker* Settings:: 334*2e9d4914SAndroid Build Coastguard Worker* Groups:: 335*2e9d4914SAndroid Build Coastguard Worker* Arrays:: 336*2e9d4914SAndroid Build Coastguard Worker* Lists:: 337*2e9d4914SAndroid Build Coastguard Worker* Integer Values:: 338*2e9d4914SAndroid Build Coastguard Worker* 64-bit Integer Values:: 339*2e9d4914SAndroid Build Coastguard Worker* Floating Point Values:: 340*2e9d4914SAndroid Build Coastguard Worker* Boolean Values:: 341*2e9d4914SAndroid Build Coastguard Worker* String Values:: 342*2e9d4914SAndroid Build Coastguard Worker* Comments:: 343*2e9d4914SAndroid Build Coastguard Worker* Include Directives:: 344*2e9d4914SAndroid Build Coastguard Worker@end menu 345*2e9d4914SAndroid Build Coastguard Worker@chapter Configuration Files 346*2e9d4914SAndroid Build Coastguard Worker 347*2e9d4914SAndroid Build Coastguard Worker@i{Libconfig} supports structured, hierarchical configurations. These 348*2e9d4914SAndroid Build Coastguard Workerconfigurations can be read from and written to files and manipulated 349*2e9d4914SAndroid Build Coastguard Workerin memory. 350*2e9d4914SAndroid Build Coastguard Worker 351*2e9d4914SAndroid Build Coastguard Worker@cindex setting 352*2e9d4914SAndroid Build Coastguard Worker@cindex value 353*2e9d4914SAndroid Build Coastguard Worker@cindex scalar value 354*2e9d4914SAndroid Build Coastguard Worker@cindex array 355*2e9d4914SAndroid Build Coastguard Worker@cindex group 356*2e9d4914SAndroid Build Coastguard Worker@cindex list 357*2e9d4914SAndroid Build Coastguard Worker@cindex configuration 358*2e9d4914SAndroid Build Coastguard WorkerA @dfn{configuration} consists of a group of @dfn{settings}, which 359*2e9d4914SAndroid Build Coastguard Workerassociate names with values. A @dfn{value} can be one of the 360*2e9d4914SAndroid Build Coastguard Workerfollowing: 361*2e9d4914SAndroid Build Coastguard Worker 362*2e9d4914SAndroid Build Coastguard Worker@itemize @bullet 363*2e9d4914SAndroid Build Coastguard Worker@item A @dfn{scalar value}: integer, 64-bit integer, floating-point number, boolean, 364*2e9d4914SAndroid Build Coastguard Workeror string 365*2e9d4914SAndroid Build Coastguard Worker@item An @dfn{array}, which is a sequence of scalar values, all of which must have the same type 366*2e9d4914SAndroid Build Coastguard Worker@item A @dfn{group}, which is a collection of settings 367*2e9d4914SAndroid Build Coastguard Worker@item A @dfn{list}, which is a sequence of values of any type, including other lists 368*2e9d4914SAndroid Build Coastguard Worker@end itemize 369*2e9d4914SAndroid Build Coastguard Worker 370*2e9d4914SAndroid Build Coastguard WorkerConsider the following configuration file for a hypothetical GUI 371*2e9d4914SAndroid Build Coastguard Workerapplication, which illustrates all of the elements of the configuration 372*2e9d4914SAndroid Build Coastguard Workerfile grammar. 373*2e9d4914SAndroid Build Coastguard Worker 374*2e9d4914SAndroid Build Coastguard Worker@sp 1 375*2e9d4914SAndroid Build Coastguard Worker@cartouche 376*2e9d4914SAndroid Build Coastguard Worker@smallexample 377*2e9d4914SAndroid Build Coastguard Worker# Example application configuration file 378*2e9d4914SAndroid Build Coastguard Worker 379*2e9d4914SAndroid Build Coastguard Workerversion = "1.0"; 380*2e9d4914SAndroid Build Coastguard Worker 381*2e9d4914SAndroid Build Coastguard Workerapplication: 382*2e9d4914SAndroid Build Coastguard Worker@{ 383*2e9d4914SAndroid Build Coastguard Worker window: 384*2e9d4914SAndroid Build Coastguard Worker @{ 385*2e9d4914SAndroid Build Coastguard Worker title = "My Application"; 386*2e9d4914SAndroid Build Coastguard Worker size = @{ w = 640; h = 480; @}; 387*2e9d4914SAndroid Build Coastguard Worker pos = @{ x = 350; y = 250; @}; 388*2e9d4914SAndroid Build Coastguard Worker @}; 389*2e9d4914SAndroid Build Coastguard Worker 390*2e9d4914SAndroid Build Coastguard Worker list = ( ( "abc", 123, true ), 1.234, ( /* an empty list */ ) ); 391*2e9d4914SAndroid Build Coastguard Worker 392*2e9d4914SAndroid Build Coastguard Worker books = ( @{ title = "Treasure Island"; 393*2e9d4914SAndroid Build Coastguard Worker author = "Robert Louis Stevenson"; 394*2e9d4914SAndroid Build Coastguard Worker price = 29.95; 395*2e9d4914SAndroid Build Coastguard Worker qty = 5; @}, 396*2e9d4914SAndroid Build Coastguard Worker @{ title = "Snow Crash"; 397*2e9d4914SAndroid Build Coastguard Worker author = "Neal Stephenson"; 398*2e9d4914SAndroid Build Coastguard Worker price = 9.99; 399*2e9d4914SAndroid Build Coastguard Worker qty = 8; @} ); 400*2e9d4914SAndroid Build Coastguard Worker 401*2e9d4914SAndroid Build Coastguard Worker misc: 402*2e9d4914SAndroid Build Coastguard Worker @{ 403*2e9d4914SAndroid Build Coastguard Worker pi = 3.141592654; 404*2e9d4914SAndroid Build Coastguard Worker bigint = 9223372036854775807L; 405*2e9d4914SAndroid Build Coastguard Worker columns = [ "Last Name", "First Name", "MI" ]; 406*2e9d4914SAndroid Build Coastguard Worker bitmask = 0x1FC3; // hex 407*2e9d4914SAndroid Build Coastguard Worker umask = 0027; // octal. Range limited to that of "int" 408*2e9d4914SAndroid Build Coastguard Worker @}; 409*2e9d4914SAndroid Build Coastguard Worker@}; 410*2e9d4914SAndroid Build Coastguard Worker@end smallexample 411*2e9d4914SAndroid Build Coastguard Worker@end cartouche 412*2e9d4914SAndroid Build Coastguard Worker@sp 1 413*2e9d4914SAndroid Build Coastguard Worker 414*2e9d4914SAndroid Build Coastguard Worker@cindex path 415*2e9d4914SAndroid Build Coastguard WorkerSettings can be uniquely identified within the configuration by a 416*2e9d4914SAndroid Build Coastguard Worker@dfn{path}. The path is a dot-separated sequence of names, beginning 417*2e9d4914SAndroid Build Coastguard Workerat a top-level group and ending at the setting itself. Each name in 418*2e9d4914SAndroid Build Coastguard Workerthe path is the name of a setting; if the setting has no name because 419*2e9d4914SAndroid Build Coastguard Workerit is an element in a list or array, an integer index in square 420*2e9d4914SAndroid Build Coastguard Workerbrackets can be used as the name. 421*2e9d4914SAndroid Build Coastguard Worker 422*2e9d4914SAndroid Build Coastguard WorkerFor example, in our hypothetical configuration file, the path to the 423*2e9d4914SAndroid Build Coastguard Worker@code{x} setting is @code{application.window.pos.x}; the path to the 424*2e9d4914SAndroid Build Coastguard Worker@code{version} setting is simply @code{version}; and the path to the 425*2e9d4914SAndroid Build Coastguard Worker@code{title} setting of the second book in the @code{books} list is 426*2e9d4914SAndroid Build Coastguard Worker@code{application.books.[1].title}. 427*2e9d4914SAndroid Build Coastguard Worker 428*2e9d4914SAndroid Build Coastguard WorkerThe datatype of a value is determined from the format of the value 429*2e9d4914SAndroid Build Coastguard Workeritself. If the value is enclosed in double quotes, it is treated as a 430*2e9d4914SAndroid Build Coastguard Workerstring. If it looks like an integer or floating point number, it is 431*2e9d4914SAndroid Build Coastguard Workertreated as such. If it is one of the values @code{TRUE}, @code{true}, 432*2e9d4914SAndroid Build Coastguard Worker@code{FALSE}, or @code{false} (or any other mixed-case version of 433*2e9d4914SAndroid Build Coastguard Workerthose tokens, e.g., @code{True} or @code{FaLsE}), it is treated as a 434*2e9d4914SAndroid Build Coastguard Workerboolean. If it consists of a comma-separated list of values enclosed 435*2e9d4914SAndroid Build Coastguard Workerin square brackets, it is treated as an array. And if it consists of a 436*2e9d4914SAndroid Build Coastguard Workercomma-separated list of values enclosed in parentheses, it is treated 437*2e9d4914SAndroid Build Coastguard Workeras a list. Any value which does not meet any of these criteria is 438*2e9d4914SAndroid Build Coastguard Workerconsidered invalid and results in a parse error. 439*2e9d4914SAndroid Build Coastguard Worker 440*2e9d4914SAndroid Build Coastguard WorkerAll names are case-sensitive. They may consist only of alphanumeric 441*2e9d4914SAndroid Build Coastguard Workercharacters, dashes (@samp{-}), underscores (@samp{_}), and asterisks 442*2e9d4914SAndroid Build Coastguard Worker(@samp{*}), and must begin with a letter or asterisk. No other 443*2e9d4914SAndroid Build Coastguard Workercharacters are allowed. 444*2e9d4914SAndroid Build Coastguard Worker 445*2e9d4914SAndroid Build Coastguard WorkerIn C and C++, integer, 64-bit integer, floating point, and string 446*2e9d4914SAndroid Build Coastguard Workervalues are mapped to the native types @code{int}, @code{long long}, 447*2e9d4914SAndroid Build Coastguard Worker@code{double}, and @code{const char *}, respectively. The boolean type 448*2e9d4914SAndroid Build Coastguard Workeris mapped to @code{int} in C and @code{bool} in C++. 449*2e9d4914SAndroid Build Coastguard Worker 450*2e9d4914SAndroid Build Coastguard WorkerThe following sections describe the elements of the configuration file 451*2e9d4914SAndroid Build Coastguard Workergrammar in additional detail. 452*2e9d4914SAndroid Build Coastguard Worker 453*2e9d4914SAndroid Build Coastguard Worker@node Settings, Groups, , Configuration Files 454*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 455*2e9d4914SAndroid Build Coastguard Worker@section Settings 456*2e9d4914SAndroid Build Coastguard Worker 457*2e9d4914SAndroid Build Coastguard WorkerA setting has the form: 458*2e9d4914SAndroid Build Coastguard Worker 459*2e9d4914SAndroid Build Coastguard Worker@i{name} @b{=} @i{value} @b{;} 460*2e9d4914SAndroid Build Coastguard Worker 461*2e9d4914SAndroid Build Coastguard Workeror: 462*2e9d4914SAndroid Build Coastguard Worker 463*2e9d4914SAndroid Build Coastguard Worker@i{name} @b{:} @i{value} @b{;} 464*2e9d4914SAndroid Build Coastguard Worker 465*2e9d4914SAndroid Build Coastguard WorkerThe trailing semicolon is optional. Whitespace is not significant. 466*2e9d4914SAndroid Build Coastguard Worker 467*2e9d4914SAndroid Build Coastguard WorkerThe value may be a scalar value, an array, a group, or a list. 468*2e9d4914SAndroid Build Coastguard Worker 469*2e9d4914SAndroid Build Coastguard Worker@node Groups, Arrays, Settings, Configuration Files 470*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 471*2e9d4914SAndroid Build Coastguard Worker@section Groups 472*2e9d4914SAndroid Build Coastguard Worker 473*2e9d4914SAndroid Build Coastguard WorkerA group has the form: 474*2e9d4914SAndroid Build Coastguard Worker 475*2e9d4914SAndroid Build Coastguard Worker@b{@{} 476*2e9d4914SAndroid Build Coastguard Worker @i{settings ...} 477*2e9d4914SAndroid Build Coastguard Worker@b{@}} 478*2e9d4914SAndroid Build Coastguard Worker 479*2e9d4914SAndroid Build Coastguard WorkerGroups can contain any number of settings, but each setting must have 480*2e9d4914SAndroid Build Coastguard Workera unique name within the group. 481*2e9d4914SAndroid Build Coastguard Worker 482*2e9d4914SAndroid Build Coastguard Worker@node Arrays, Lists, Groups, Configuration Files 483*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 484*2e9d4914SAndroid Build Coastguard Worker@section Arrays 485*2e9d4914SAndroid Build Coastguard Worker 486*2e9d4914SAndroid Build Coastguard WorkerAn array has the form: 487*2e9d4914SAndroid Build Coastguard Worker 488*2e9d4914SAndroid Build Coastguard Worker@b{[} @i{value}@b{,} @i{value ...} @b{]} 489*2e9d4914SAndroid Build Coastguard Worker 490*2e9d4914SAndroid Build Coastguard WorkerAn array may have zero or more elements, but the elements must all be 491*2e9d4914SAndroid Build Coastguard Workerscalar values of the same type. 492*2e9d4914SAndroid Build Coastguard Worker 493*2e9d4914SAndroid Build Coastguard WorkerThe last element in an array may be followed by a comma, which will be ignored. 494*2e9d4914SAndroid Build Coastguard Worker 495*2e9d4914SAndroid Build Coastguard Worker@node Lists, Integer Values, Arrays, Configuration Files 496*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 497*2e9d4914SAndroid Build Coastguard Worker@section Lists 498*2e9d4914SAndroid Build Coastguard Worker 499*2e9d4914SAndroid Build Coastguard WorkerA list has the form: 500*2e9d4914SAndroid Build Coastguard Worker 501*2e9d4914SAndroid Build Coastguard Worker@b{(} @i{value}@b{,} @i{value ...} @b{)} 502*2e9d4914SAndroid Build Coastguard Worker 503*2e9d4914SAndroid Build Coastguard WorkerA list may have zero or more elements, each of which can be a scalar 504*2e9d4914SAndroid Build Coastguard Workervalue, an array, a group, or another list. 505*2e9d4914SAndroid Build Coastguard Worker 506*2e9d4914SAndroid Build Coastguard WorkerThe last element in a list may be followed by a comma, which will be ignored. 507*2e9d4914SAndroid Build Coastguard Worker 508*2e9d4914SAndroid Build Coastguard Worker@node Integer Values, 64-bit Integer Values, Lists, Configuration Files 509*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 510*2e9d4914SAndroid Build Coastguard Worker@section Integer Values 511*2e9d4914SAndroid Build Coastguard Worker 512*2e9d4914SAndroid Build Coastguard WorkerIntegers can be represented in one of two ways: as a series of one or 513*2e9d4914SAndroid Build Coastguard Workermore decimal digits (@samp{0} - @samp{9}), with an optional leading 514*2e9d4914SAndroid Build Coastguard Workersign character (@samp{+} or @samp{-}); or as a hexadecimal value 515*2e9d4914SAndroid Build Coastguard Workerconsisting of the characters @samp{0x} followed by a series of one or 516*2e9d4914SAndroid Build Coastguard Workermore hexadecimal digits (@samp{0} - @samp{9}, @samp{A} - @samp{F}, 517*2e9d4914SAndroid Build Coastguard Worker@samp{a} - @samp{f}). Additionally, octal notation integers (that is, 518*2e9d4914SAndroid Build Coastguard Workerthose having a leading zero with non-zero value) are also allowed. 519*2e9d4914SAndroid Build Coastguard Worker 520*2e9d4914SAndroid Build Coastguard Worker@node 64-bit Integer Values, Floating Point Values, Integer Values, Configuration Files 521*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 522*2e9d4914SAndroid Build Coastguard Worker@section 64-bit Integer Values 523*2e9d4914SAndroid Build Coastguard Worker 524*2e9d4914SAndroid Build Coastguard WorkerLong long (64-bit) integers are represented identically to integers, 525*2e9d4914SAndroid Build Coastguard Workerexcept that an `L' character is appended to indicate a 64-bit 526*2e9d4914SAndroid Build Coastguard Workervalue. For example, @samp{0L} indicates a 64-bit integer value 0. As 527*2e9d4914SAndroid Build Coastguard Workerof version 1.5 of the library, the trailing `L' is optional; if the 528*2e9d4914SAndroid Build Coastguard Workerinteger value exceeds the range of a 32-bit integer, it will 529*2e9d4914SAndroid Build Coastguard Workerautomatically be interpreted as a 64-bit integer. 530*2e9d4914SAndroid Build Coastguard Worker 531*2e9d4914SAndroid Build Coastguard WorkerThe @i{integer} and @i{64-bit integer} setting types are interchangeable to the 532*2e9d4914SAndroid Build Coastguard Workerextent that a conversion between the corresponding native types would not 533*2e9d4914SAndroid Build Coastguard Workerresult in an overflow or underflow. For example, a @i{long long} value can be 534*2e9d4914SAndroid Build Coastguard Workerwritten to a setting that has an @i{integer} type, if that value is within the 535*2e9d4914SAndroid Build Coastguard Workerrange of an @i{int}. This rule applies to every API function or method that 536*2e9d4914SAndroid Build Coastguard Workerreads a value from or writes a value to a setting: if the type conversion would 537*2e9d4914SAndroid Build Coastguard Workernot result in an overflow or underflow, then the call will succeed, and 538*2e9d4914SAndroid Build Coastguard Workerotherwise it will fail. This behavior was not well-defined prior to version 1.7 539*2e9d4914SAndroid Build Coastguard Workerof the library. 540*2e9d4914SAndroid Build Coastguard Worker 541*2e9d4914SAndroid Build Coastguard Worker@node Floating Point Values, Boolean Values, 64-bit Integer Values, Configuration Files 542*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 543*2e9d4914SAndroid Build Coastguard Worker@section Floating Point Values 544*2e9d4914SAndroid Build Coastguard Worker 545*2e9d4914SAndroid Build Coastguard WorkerFloating point values consist of a series of one or more digits, one 546*2e9d4914SAndroid Build Coastguard Workerdecimal point, an optional leading sign character (@samp{+} or 547*2e9d4914SAndroid Build Coastguard Worker@samp{-}), and an optional exponent. An exponent consists of the 548*2e9d4914SAndroid Build Coastguard Workerletter @samp{E} or @samp{e}, an optional sign character, and a series 549*2e9d4914SAndroid Build Coastguard Workerof one or more digits. 550*2e9d4914SAndroid Build Coastguard Worker 551*2e9d4914SAndroid Build Coastguard Worker@node Boolean Values, String Values, Floating Point Values, Configuration Files 552*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 553*2e9d4914SAndroid Build Coastguard Worker@section Boolean Values 554*2e9d4914SAndroid Build Coastguard Worker 555*2e9d4914SAndroid Build Coastguard WorkerBoolean values may have one of the following values: @samp{true}, 556*2e9d4914SAndroid Build Coastguard Worker@samp{false}, or any mixed-case variation thereof. 557*2e9d4914SAndroid Build Coastguard Worker 558*2e9d4914SAndroid Build Coastguard Worker@node String Values, Comments, Boolean Values, Configuration Files 559*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 560*2e9d4914SAndroid Build Coastguard Worker@section String Values 561*2e9d4914SAndroid Build Coastguard Worker 562*2e9d4914SAndroid Build Coastguard Worker@cindex escape sequence 563*2e9d4914SAndroid Build Coastguard WorkerString values consist of arbitrary text delimited by double 564*2e9d4914SAndroid Build Coastguard Workerquotes. Literal double quotes can be escaped by preceding them with a 565*2e9d4914SAndroid Build Coastguard Workerbackslash: @samp{\"}. The escape sequences @samp{\\}, @samp{\f}, 566*2e9d4914SAndroid Build Coastguard Worker@samp{\n}, @samp{\r}, and @samp{\t} are also recognized, and have the 567*2e9d4914SAndroid Build Coastguard Workerusual meaning. 568*2e9d4914SAndroid Build Coastguard Worker 569*2e9d4914SAndroid Build Coastguard WorkerIn addition, the @samp{\x} escape sequence is supported; this sequence 570*2e9d4914SAndroid Build Coastguard Workermust be followed by @i{exactly two} hexadecimal digits, which represent an 571*2e9d4914SAndroid Build Coastguard Worker8-bit ASCII value. For example, @samp{\xFF} represents the character 572*2e9d4914SAndroid Build Coastguard Workerwith ASCII code 0xFF. 573*2e9d4914SAndroid Build Coastguard Worker 574*2e9d4914SAndroid Build Coastguard WorkerNo other escape sequences are currently supported. 575*2e9d4914SAndroid Build Coastguard Worker 576*2e9d4914SAndroid Build Coastguard WorkerAdjacent strings are automatically concatenated, as in C/C++ source 577*2e9d4914SAndroid Build Coastguard Workercode. This is useful for formatting very long strings as sequences of 578*2e9d4914SAndroid Build Coastguard Workershorter strings. For example, the following constructs are equivalent: 579*2e9d4914SAndroid Build Coastguard Worker 580*2e9d4914SAndroid Build Coastguard Worker@itemize @bullet 581*2e9d4914SAndroid Build Coastguard Worker@item 582*2e9d4914SAndroid Build Coastguard Worker@code{"The quick brown fox jumped over the lazy dog."} 583*2e9d4914SAndroid Build Coastguard Worker 584*2e9d4914SAndroid Build Coastguard Worker@item 585*2e9d4914SAndroid Build Coastguard Worker@code{"The quick brown fox"} @* 586*2e9d4914SAndroid Build Coastguard Worker@code{" jumped over the lazy dog."} 587*2e9d4914SAndroid Build Coastguard Worker 588*2e9d4914SAndroid Build Coastguard Worker@item 589*2e9d4914SAndroid Build Coastguard Worker@code{"The quick" /* comment */ " brown fox " // another comment} @* 590*2e9d4914SAndroid Build Coastguard Worker@code{"jumped over the lazy dog."} 591*2e9d4914SAndroid Build Coastguard Worker 592*2e9d4914SAndroid Build Coastguard Worker@end itemize 593*2e9d4914SAndroid Build Coastguard Worker@page 594*2e9d4914SAndroid Build Coastguard Worker@node Comments, Include Directives, String Values, Configuration Files 595*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 596*2e9d4914SAndroid Build Coastguard Worker@section Comments 597*2e9d4914SAndroid Build Coastguard Worker 598*2e9d4914SAndroid Build Coastguard Worker@cindex comment 599*2e9d4914SAndroid Build Coastguard WorkerThree types of comments are allowed within a configuration: 600*2e9d4914SAndroid Build Coastguard Worker 601*2e9d4914SAndroid Build Coastguard Worker@itemize @bullet 602*2e9d4914SAndroid Build Coastguard Worker 603*2e9d4914SAndroid Build Coastguard Worker@item Script-style comments. All text beginning with a @samp{#} character 604*2e9d4914SAndroid Build Coastguard Workerto the end of the line is ignored. 605*2e9d4914SAndroid Build Coastguard Worker 606*2e9d4914SAndroid Build Coastguard Worker@item C-style comments. All text, including line breaks, between a starting 607*2e9d4914SAndroid Build Coastguard Worker@samp{/*} sequence and an ending @samp{*/} sequence is ignored. 608*2e9d4914SAndroid Build Coastguard Worker 609*2e9d4914SAndroid Build Coastguard Worker@item C++-style comments. All text beginning with a @samp{//} sequence to the 610*2e9d4914SAndroid Build Coastguard Workerend of the line is ignored. 611*2e9d4914SAndroid Build Coastguard Worker 612*2e9d4914SAndroid Build Coastguard Worker@end itemize 613*2e9d4914SAndroid Build Coastguard Worker 614*2e9d4914SAndroid Build Coastguard WorkerAs expected, comment delimiters appearing within quoted strings are 615*2e9d4914SAndroid Build Coastguard Workertreated as literal text. 616*2e9d4914SAndroid Build Coastguard Worker 617*2e9d4914SAndroid Build Coastguard WorkerComments are ignored when the configuration is read in, so they are 618*2e9d4914SAndroid Build Coastguard Workernot treated as part of the configuration. Therefore if the 619*2e9d4914SAndroid Build Coastguard Workerconfiguration is written back out to a stream, any comments that were 620*2e9d4914SAndroid Build Coastguard Workerpresent in the original configuration will be lost. 621*2e9d4914SAndroid Build Coastguard Worker 622*2e9d4914SAndroid Build Coastguard Worker 623*2e9d4914SAndroid Build Coastguard Worker@node Include Directives, , Comments, Configuration Files 624*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 625*2e9d4914SAndroid Build Coastguard Worker@section Include Directives 626*2e9d4914SAndroid Build Coastguard Worker 627*2e9d4914SAndroid Build Coastguard Worker@cindex include directive 628*2e9d4914SAndroid Build Coastguard WorkerA configuration file may ``include'' the contents of other files 629*2e9d4914SAndroid Build Coastguard Workerusing an @i{include directive}. This directive has the effect of 630*2e9d4914SAndroid Build Coastguard Workerinlining the contents of the named file(s) at the point of inclusion. 631*2e9d4914SAndroid Build Coastguard Worker 632*2e9d4914SAndroid Build Coastguard WorkerAn include directive must appear on its own line in the input. It has 633*2e9d4914SAndroid Build Coastguard Workerthe form: 634*2e9d4914SAndroid Build Coastguard Worker 635*2e9d4914SAndroid Build Coastguard Worker@b{@@include "}@i{path}@b{"} 636*2e9d4914SAndroid Build Coastguard Worker 637*2e9d4914SAndroid Build Coastguard Worker@cindex include function 638*2e9d4914SAndroid Build Coastguard WorkerThe interpretation of @i{path} depends on the currently registered 639*2e9d4914SAndroid Build Coastguard Worker@i{include function}. The default include function prepends the include 640*2e9d4914SAndroid Build Coastguard Workerdirectory, if any, to @i{path}, and then interprets the result as a single, 641*2e9d4914SAndroid Build Coastguard Workerliteral file path. The application may supply its own include function which 642*2e9d4914SAndroid Build Coastguard Workerdoes variable substitution, wildcard expansion, or other transformations, 643*2e9d4914SAndroid Build Coastguard Workerreturning a list of zero or more paths to files whose contents should be inlined 644*2e9d4914SAndroid Build Coastguard Workerat the point of inclusion. 645*2e9d4914SAndroid Build Coastguard Worker 646*2e9d4914SAndroid Build Coastguard WorkerAny backslashes or double quotes in the path must be escaped as 647*2e9d4914SAndroid Build Coastguard Worker@samp{\\} and @samp{\"}, respectively. 648*2e9d4914SAndroid Build Coastguard Worker 649*2e9d4914SAndroid Build Coastguard WorkerFor example, consider the following two configuration files: 650*2e9d4914SAndroid Build Coastguard Worker 651*2e9d4914SAndroid Build Coastguard Worker@cartouche 652*2e9d4914SAndroid Build Coastguard Worker@smallexample 653*2e9d4914SAndroid Build Coastguard Worker# file: quote.cfg 654*2e9d4914SAndroid Build Coastguard Workerquote = "Criticism may not be agreeable, but it is necessary." 655*2e9d4914SAndroid Build Coastguard Worker " It fulfils the same function as pain in the human" 656*2e9d4914SAndroid Build Coastguard Worker " body. It calls attention to an unhealthy state of" 657*2e9d4914SAndroid Build Coastguard Worker " things.\n" 658*2e9d4914SAndroid Build Coastguard Worker "\t--Winston Churchill"; 659*2e9d4914SAndroid Build Coastguard Worker@end smallexample 660*2e9d4914SAndroid Build Coastguard Worker@end cartouche 661*2e9d4914SAndroid Build Coastguard Worker 662*2e9d4914SAndroid Build Coastguard Worker@cartouche 663*2e9d4914SAndroid Build Coastguard Worker@smallexample 664*2e9d4914SAndroid Build Coastguard Worker# file: test.cfg 665*2e9d4914SAndroid Build Coastguard Workerinfo: @{ 666*2e9d4914SAndroid Build Coastguard Worker name = "Winston Churchill"; 667*2e9d4914SAndroid Build Coastguard Worker @@include "quote.cfg" 668*2e9d4914SAndroid Build Coastguard Worker country = "UK"; 669*2e9d4914SAndroid Build Coastguard Worker@}; 670*2e9d4914SAndroid Build Coastguard Worker@end smallexample 671*2e9d4914SAndroid Build Coastguard Worker@end cartouche 672*2e9d4914SAndroid Build Coastguard Worker 673*2e9d4914SAndroid Build Coastguard WorkerThe resulting configuration will be equivalent to one in which the 674*2e9d4914SAndroid Build Coastguard Workercontents of the file @samp{quote.cfg} appeared at the point where the 675*2e9d4914SAndroid Build Coastguard Workerinclude directive is placed. 676*2e9d4914SAndroid Build Coastguard Worker 677*2e9d4914SAndroid Build Coastguard WorkerInclude files may be nested to a maximum of 10 levels; exceeding this 678*2e9d4914SAndroid Build Coastguard Workerlimit results in a parse error. 679*2e9d4914SAndroid Build Coastguard Worker 680*2e9d4914SAndroid Build Coastguard WorkerWhen the path argument to an @b{@@include} directive is a relative 681*2e9d4914SAndroid Build Coastguard Workerpath, then it will be interpreted as being relative to the include 682*2e9d4914SAndroid Build Coastguard Workerdirectory that has been been set by means of 683*2e9d4914SAndroid Build Coastguard Worker@code{config_set_include_dir()}. If no include directory has been set, 684*2e9d4914SAndroid Build Coastguard Workerthen it will be taken as being relative to the program's current 685*2e9d4914SAndroid Build Coastguard Workerworking directory. 686*2e9d4914SAndroid Build Coastguard Worker 687*2e9d4914SAndroid Build Coastguard WorkerLike comments, include directives are not part of the configuration 688*2e9d4914SAndroid Build Coastguard Workerfile syntax. They are processed before the configuration itself is 689*2e9d4914SAndroid Build Coastguard Workerparsed. Therefore, they are not preserved when the configuration is 690*2e9d4914SAndroid Build Coastguard Workerwritten back out to a stream. There is presently no support for 691*2e9d4914SAndroid Build Coastguard Workerprogrammatically inserting include directives into a configuration. 692*2e9d4914SAndroid Build Coastguard Worker 693*2e9d4914SAndroid Build Coastguard Worker@node The C API, The C++ API, Configuration Files, Top 694*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 695*2e9d4914SAndroid Build Coastguard Worker@chapter The C API 696*2e9d4914SAndroid Build Coastguard Worker 697*2e9d4914SAndroid Build Coastguard Worker@tindex config_t 698*2e9d4914SAndroid Build Coastguard Worker@tindex config_setting_t 699*2e9d4914SAndroid Build Coastguard WorkerThis chapter describes the C library API. The type @i{config_t} 700*2e9d4914SAndroid Build Coastguard Workerrepresents a configuration, and the type @i{config_setting_t} represents 701*2e9d4914SAndroid Build Coastguard Workera configuration setting. 702*2e9d4914SAndroid Build Coastguard Worker 703*2e9d4914SAndroid Build Coastguard WorkerThe boolean values @code{CONFIG_TRUE} and @code{CONFIG_FALSE} are 704*2e9d4914SAndroid Build Coastguard Workermacros defined as @code{(1)} and @code{(0)}, respectively. 705*2e9d4914SAndroid Build Coastguard Worker 706*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_init (@w{config_t * @var{config}}) 707*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_destroy (@w{config_t * @var{config}}) 708*2e9d4914SAndroid Build Coastguard Worker 709*2e9d4914SAndroid Build Coastguard WorkerThese functions initialize and destroy the configuration object @var{config}. 710*2e9d4914SAndroid Build Coastguard Worker 711*2e9d4914SAndroid Build Coastguard Worker@code{config_init()} initializes the @i{config_t} structure pointed to by 712*2e9d4914SAndroid Build Coastguard Worker@var{config} as a new, empty configuration. 713*2e9d4914SAndroid Build Coastguard Worker 714*2e9d4914SAndroid Build Coastguard Worker@code{config_destroy()} destroys the configuration @var{config}, 715*2e9d4914SAndroid Build Coastguard Workerdeallocating all memory associated with the configuration, but does not 716*2e9d4914SAndroid Build Coastguard Workerattempt to deallocate the @i{config_t} structure itself. 717*2e9d4914SAndroid Build Coastguard Worker 718*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 719*2e9d4914SAndroid Build Coastguard Worker 720*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_clear (@w{config_t * @var{config}}) 721*2e9d4914SAndroid Build Coastguard Worker 722*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 723*2e9d4914SAndroid Build Coastguard Worker 724*2e9d4914SAndroid Build Coastguard WorkerThis function clears the configuration @var{config}. All child settings of the 725*2e9d4914SAndroid Build Coastguard Workerroot setting are recursively destroyed. All other attributes of the configuration 726*2e9d4914SAndroid Build Coastguard Workerare left unchanged. 727*2e9d4914SAndroid Build Coastguard Worker 728*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 729*2e9d4914SAndroid Build Coastguard Worker 730*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_read (@w{config_t * @var{config}}, @w{FILE * @var{stream}}) 731*2e9d4914SAndroid Build Coastguard Worker 732*2e9d4914SAndroid Build Coastguard WorkerThis function reads and parses a configuration from the given 733*2e9d4914SAndroid Build Coastguard Worker@var{stream} into the configuration object @var{config}. It returns 734*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TRUE} on success, or @code{CONFIG_FALSE} on failure; the 735*2e9d4914SAndroid Build Coastguard Worker@code{config_error_text()}, @code{config_error_file()}, 736*2e9d4914SAndroid Build Coastguard Worker@code{config_error_line()}, and @code{config_error_type()} functions, 737*2e9d4914SAndroid Build Coastguard Workerdescribed below, can be used to obtain information about the error. 738*2e9d4914SAndroid Build Coastguard Worker 739*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 740*2e9d4914SAndroid Build Coastguard Worker 741*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_read_file (@w{config_t * @var{config}}, @w{const char * @var{filename}}) 742*2e9d4914SAndroid Build Coastguard Worker 743*2e9d4914SAndroid Build Coastguard WorkerThis function reads and parses a configuration from the file named 744*2e9d4914SAndroid Build Coastguard Worker@var{filename} into the configuration object @var{config}. It returns 745*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TRUE} on success, or @code{CONFIG_FALSE} on failure; the 746*2e9d4914SAndroid Build Coastguard Worker@code{config_error_text()} and @code{config_error_line()} functions, 747*2e9d4914SAndroid Build Coastguard Workerdescribed below, can be used to obtain information about the error. 748*2e9d4914SAndroid Build Coastguard Worker 749*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 750*2e9d4914SAndroid Build Coastguard Worker 751*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_read_string (@w{config_t * @var{config}}, @w{const char * @var{str}}) 752*2e9d4914SAndroid Build Coastguard Worker 753*2e9d4914SAndroid Build Coastguard WorkerThis function reads and parses a configuration from the string 754*2e9d4914SAndroid Build Coastguard Worker@var{str} into the configuration object @var{config}. It returns 755*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TRUE} on success, or @code{CONFIG_FALSE} on failure; the 756*2e9d4914SAndroid Build Coastguard Worker@code{config_error_text()} and @code{config_error_line()} functions, 757*2e9d4914SAndroid Build Coastguard Workerdescribed below, can be used to obtain information about the error. 758*2e9d4914SAndroid Build Coastguard Worker 759*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 760*2e9d4914SAndroid Build Coastguard Worker 761*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_write (@w{const config_t * @var{config}}, @w{FILE * @var{stream}}) 762*2e9d4914SAndroid Build Coastguard Worker 763*2e9d4914SAndroid Build Coastguard WorkerThis function writes the configuration @var{config} to the given 764*2e9d4914SAndroid Build Coastguard Worker@var{stream}. 765*2e9d4914SAndroid Build Coastguard Worker 766*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 767*2e9d4914SAndroid Build Coastguard Worker 768*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_write_file (@w{config_t * @var{config}}, @w{const char * @var{filename}}) 769*2e9d4914SAndroid Build Coastguard Worker 770*2e9d4914SAndroid Build Coastguard WorkerThis function writes the configuration @var{config} to the file named 771*2e9d4914SAndroid Build Coastguard Worker@var{filename}. It returns @code{CONFIG_TRUE} on success, or 772*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FALSE} on failure. 773*2e9d4914SAndroid Build Coastguard Worker 774*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 775*2e9d4914SAndroid Build Coastguard Worker 776*2e9d4914SAndroid Build Coastguard Worker@deftypefun {const char *} config_error_text (@w{const config_t * @var{config}}) 777*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {const char *} config_error_file (@w{const config_t * @var{config}}) 778*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_error_line (@w{const config_t * @var{config}}) 779*2e9d4914SAndroid Build Coastguard Worker 780*2e9d4914SAndroid Build Coastguard WorkerThese functions, which are implemented as macros, return the text, 781*2e9d4914SAndroid Build Coastguard Workerfilename, and line number of the parse error, if one occurred during a 782*2e9d4914SAndroid Build Coastguard Workercall to @code{config_read()}, @code{config_read_string()}, or 783*2e9d4914SAndroid Build Coastguard Worker@code{config_read_file()}. Storage for the strings returned by 784*2e9d4914SAndroid Build Coastguard Worker@code{config_error_text()} and @code{config_error_file()} are managed 785*2e9d4914SAndroid Build Coastguard Workerby the library and released automatically when the configuration is 786*2e9d4914SAndroid Build Coastguard Workerdestroyed; these strings must not be freed by the caller. If the error 787*2e9d4914SAndroid Build Coastguard Workeroccurred in text that was read from a string or stream, 788*2e9d4914SAndroid Build Coastguard Worker@code{config_error_file()} will return NULL. 789*2e9d4914SAndroid Build Coastguard Worker 790*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 791*2e9d4914SAndroid Build Coastguard Worker 792*2e9d4914SAndroid Build Coastguard Worker@deftypefun config_error_t config_error_type (@w{const config_t * @var{config}}) 793*2e9d4914SAndroid Build Coastguard Worker@tindex config_error_t 794*2e9d4914SAndroid Build Coastguard WorkerThis function, which is implemented as a macro, returns the type of 795*2e9d4914SAndroid Build Coastguard Workererror that occurred during the last call to one of the read or write 796*2e9d4914SAndroid Build Coastguard Workerfunctions. The @var{config_error_t} type is an enumeration with the 797*2e9d4914SAndroid Build Coastguard Workerfollowing values: @code{CONFIG_ERR_NONE}, @code{CONFIG_ERR_FILE_IO}, 798*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_ERR_PARSE}. These represent success, a file I/O error, 799*2e9d4914SAndroid Build Coastguard Workerand a parsing error, respectively. 800*2e9d4914SAndroid Build Coastguard Worker 801*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 802*2e9d4914SAndroid Build Coastguard Worker 803*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_set_include_dir (@w{config_t *@var{config}}, @w{const char *@var{include_dir}}) 804*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {const char *} config_get_include_dir (@w{const config_t *@var{config}}) 805*2e9d4914SAndroid Build Coastguard Worker 806*2e9d4914SAndroid Build Coastguard Worker@code{config_set_include_dir()} specifies the include directory, 807*2e9d4914SAndroid Build Coastguard Worker@var{include_dir}, relative to which the files specified in 808*2e9d4914SAndroid Build Coastguard Worker@samp{@@include} directives will be located for the configuration 809*2e9d4914SAndroid Build Coastguard Worker@var{config}. By default, there is no include directory, and all 810*2e9d4914SAndroid Build Coastguard Workerinclude files are expected to be relative to the current working 811*2e9d4914SAndroid Build Coastguard Workerdirectory. If @var{include_dir} is @code{NULL}, the default behavior 812*2e9d4914SAndroid Build Coastguard Workeris reinstated. 813*2e9d4914SAndroid Build Coastguard Worker 814*2e9d4914SAndroid Build Coastguard WorkerFor example, if the include directory is set to @file{/usr/local/etc}, 815*2e9d4914SAndroid Build Coastguard Workerthe include directive @samp{@@include "configs/extra.cfg"} would include the 816*2e9d4914SAndroid Build Coastguard Workerfile @file{/usr/local/etc/configs/extra.cfg}. 817*2e9d4914SAndroid Build Coastguard Worker 818*2e9d4914SAndroid Build Coastguard Worker@code{config_get_include_dir()} returns the current include directory for the 819*2e9d4914SAndroid Build Coastguard Workerconfiguration @var{config}, or @code{NULL} if none is set. 820*2e9d4914SAndroid Build Coastguard Worker 821*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 822*2e9d4914SAndroid Build Coastguard Worker 823*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_set_include_func (@w{config_include_fn_t @var{func}}) 824*2e9d4914SAndroid Build Coastguard Worker 825*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 826*2e9d4914SAndroid Build Coastguard Worker 827*2e9d4914SAndroid Build Coastguard WorkerSpecifies the include function @var{func} to use when processing 828*2e9d4914SAndroid Build Coastguard Workerinclude directives. If @var{func} is @code{NULL}, the default include function, 829*2e9d4914SAndroid Build Coastguard Worker@code{config_default_include_func()}, will be reinstated. 830*2e9d4914SAndroid Build Coastguard Worker 831*2e9d4914SAndroid Build Coastguard Worker@tindex config_include_fn_t 832*2e9d4914SAndroid Build Coastguard WorkerThe type @i{config_include_fn_t} is a type alias 833*2e9d4914SAndroid Build Coastguard Workerfor a function whose signature is: 834*2e9d4914SAndroid Build Coastguard Worker 835*2e9d4914SAndroid Build Coastguard Worker@deftypefun @w{const char **} func (@w{config_t *@var{config}}, @w{const char *@var{include_dir}}, @w{const char *@var{path}}, @w{const char **@var{error}}) 836*2e9d4914SAndroid Build Coastguard Worker 837*2e9d4914SAndroid Build Coastguard WorkerThe function receives the configuration @var{config}, the 838*2e9d4914SAndroid Build Coastguard Workerconfiguration's current include directory @var{include_dir}, the 839*2e9d4914SAndroid Build Coastguard Workerargument to the include directive @var{path}; and a pointer at which 840*2e9d4914SAndroid Build Coastguard Workerto return an error message @var{error}. 841*2e9d4914SAndroid Build Coastguard Worker 842*2e9d4914SAndroid Build Coastguard WorkerOn success, the function should return a @code{NULL}-terminated array 843*2e9d4914SAndroid Build Coastguard Workerof paths. Any relative paths must be relative to the program's current 844*2e9d4914SAndroid Build Coastguard Workerworking directory. The contents of these files will be inlined at the point 845*2e9d4914SAndroid Build Coastguard Workerof inclusion, in the order that the paths appear in the 846*2e9d4914SAndroid Build Coastguard Workerarray. Both the array and its elements should be heap allocated; the 847*2e9d4914SAndroid Build Coastguard Workerlibrary will take ownership of and eventually free the strings in the 848*2e9d4914SAndroid Build Coastguard Workerarray and the array itself. 849*2e9d4914SAndroid Build Coastguard Worker 850*2e9d4914SAndroid Build Coastguard WorkerOn failure, the function should return @code{NULL} and set @var{*error} to a 851*2e9d4914SAndroid Build Coastguard Workerstatic error string which should be used as the parse error for the 852*2e9d4914SAndroid Build Coastguard Workerconfiguration; the library does not take ownership of or free this string. 853*2e9d4914SAndroid Build Coastguard Worker 854*2e9d4914SAndroid Build Coastguard WorkerThe default include function, @code{config_default_include_func()}, 855*2e9d4914SAndroid Build Coastguard Workersimply returns a @code{NULL}-terminated array containing either a copy 856*2e9d4914SAndroid Build Coastguard Workerof @var{path} if it's an absolute path, or a concatenation of 857*2e9d4914SAndroid Build Coastguard Worker@var{include_dir} and @var{path} if it's a relative path. 858*2e9d4914SAndroid Build Coastguard Worker 859*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 860*2e9d4914SAndroid Build Coastguard Worker 861*2e9d4914SAndroid Build Coastguard WorkerApplication-supplied include functions can perform custom tasks like wildcard 862*2e9d4914SAndroid Build Coastguard Workerexpansion or variable substitution. For example, consider the include directive: 863*2e9d4914SAndroid Build Coastguard Worker 864*2e9d4914SAndroid Build Coastguard Worker@cartouche 865*2e9d4914SAndroid Build Coastguard Worker@smallexample 866*2e9d4914SAndroid Build Coastguard Worker@@include "configs/*.cfg" 867*2e9d4914SAndroid Build Coastguard Worker@end smallexample 868*2e9d4914SAndroid Build Coastguard Worker@end cartouche 869*2e9d4914SAndroid Build Coastguard Worker 870*2e9d4914SAndroid Build Coastguard WorkerThe include function would be invoked with the path @samp{configs/*.cfg} and 871*2e9d4914SAndroid Build Coastguard Workercould do wildcard expansion on that path, returning a list of paths to files 872*2e9d4914SAndroid Build Coastguard Workerwith the file extension @samp{.cfg} in the subdirectory @samp{configs}. Each of 873*2e9d4914SAndroid Build Coastguard Workerthese files would then be inlined at the location of the include directive. 874*2e9d4914SAndroid Build Coastguard Worker 875*2e9d4914SAndroid Build Coastguard WorkerTasks like wildcard expansion and variable substitution are non-trivial to 876*2e9d4914SAndroid Build Coastguard Workerimplement and typically require platform-specific code. In the interests of 877*2e9d4914SAndroid Build Coastguard Workerkeeping the library as compact and platform-independent as possible, 878*2e9d4914SAndroid Build Coastguard Workerimplementations of such include functions are not included. 879*2e9d4914SAndroid Build Coastguard Worker 880*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 881*2e9d4914SAndroid Build Coastguard Worker 882*2e9d4914SAndroid Build Coastguard Worker@deftypefun {unsigned short} config_get_float_precision(@w{config_t *@var{config}}) 883*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_set_float_precision(@w{config_t *@var{config}}, @w{unsigned short @var{digits}}) 884*2e9d4914SAndroid Build Coastguard Worker 885*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.6}} 886*2e9d4914SAndroid Build Coastguard Worker 887*2e9d4914SAndroid Build Coastguard WorkerThese functions get and set the number of decimal digits to output after the 888*2e9d4914SAndroid Build Coastguard Workerradix character when writing the configuration to a file or stream. 889*2e9d4914SAndroid Build Coastguard Worker 890*2e9d4914SAndroid Build Coastguard WorkerValid values for @var{digits} range from 0 (no decimals) to about 15 891*2e9d4914SAndroid Build Coastguard Worker(implementation defined). This parameter has no effect on parsing. 892*2e9d4914SAndroid Build Coastguard Worker 893*2e9d4914SAndroid Build Coastguard WorkerThe default float precision is 6. 894*2e9d4914SAndroid Build Coastguard Worker 895*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 896*2e9d4914SAndroid Build Coastguard Worker 897*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_get_options (@w{config_t *@var{config}}) 898*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_set_options (@w{config_t *@var{config}}, @w{int @var{options}}) 899*2e9d4914SAndroid Build Coastguard Worker 900*2e9d4914SAndroid Build Coastguard WorkerThese functions get and set the options for the configuration 901*2e9d4914SAndroid Build Coastguard Worker@var{config}. The options affect how configurations are read and 902*2e9d4914SAndroid Build Coastguard Workerwritten. The following options are defined: 903*2e9d4914SAndroid Build Coastguard Worker 904*2e9d4914SAndroid Build Coastguard Worker@table @code 905*2e9d4914SAndroid Build Coastguard Worker 906*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_AUTOCONVERT 907*2e9d4914SAndroid Build Coastguard WorkerTurning this option on enables number auto-conversion for 908*2e9d4914SAndroid Build Coastguard Workerthe configuration. When this feature is enabled, an attempt to retrieve a 909*2e9d4914SAndroid Build Coastguard Workerfloating point setting's value into an integer (or vice versa), or 910*2e9d4914SAndroid Build Coastguard Workerstore an integer to a floating point setting's value (or vice versa) 911*2e9d4914SAndroid Build Coastguard Workerwill cause the library to silently perform the necessary conversion 912*2e9d4914SAndroid Build Coastguard Worker(possibly leading to loss of data), rather than reporting failure. By 913*2e9d4914SAndroid Build Coastguard Workerdefault this option is turned off. 914*2e9d4914SAndroid Build Coastguard Worker 915*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_SEMICOLON_SEPARATORS 916*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether a semicolon (`;') is output after each setting 917*2e9d4914SAndroid Build Coastguard Workerwhen the configuration is written to a file or stream. (The semicolon 918*2e9d4914SAndroid Build Coastguard Workerseparators are optional in the configuration syntax.) By default this 919*2e9d4914SAndroid Build Coastguard Workeroption is turned on. 920*2e9d4914SAndroid Build Coastguard Worker 921*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_COLON_ASSIGNMENT_FOR_GROUPS 922*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether a colon (`:') is output between each 923*2e9d4914SAndroid Build Coastguard Workergroup setting's name and its value when the configuration is written to 924*2e9d4914SAndroid Build Coastguard Workera file or stream. If the option is turned off, an equals sign (`=') is 925*2e9d4914SAndroid Build Coastguard Workeroutput instead. (These tokens are interchangeable in the configuration 926*2e9d4914SAndroid Build Coastguard Workersyntax.) By default this option is turned on. 927*2e9d4914SAndroid Build Coastguard Worker 928*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_COLON_ASSIGNMENT_FOR_NON_GROUPS 929*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether a colon (`:') is output between each 930*2e9d4914SAndroid Build Coastguard Workernon-group setting's name and its value when the configuration is written 931*2e9d4914SAndroid Build Coastguard Workerto a file or stream. If the option is turned off, an equals sign (`=') 932*2e9d4914SAndroid Build Coastguard Workeris output instead. (These tokens are interchangeable in the configuration 933*2e9d4914SAndroid Build Coastguard Workersyntax.) By default this option is turned off. 934*2e9d4914SAndroid Build Coastguard Worker 935*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_OPEN_BRACE_ON_SEPARATE_LINE 936*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether an open brace (`@{') will be written on its own 937*2e9d4914SAndroid Build Coastguard Workerline when the configuration is written to a file or stream. If the option is 938*2e9d4914SAndroid Build Coastguard Workerturned off, the brace will be written at the end of the previous line. 939*2e9d4914SAndroid Build Coastguard WorkerBy default this option is turned on. 940*2e9d4914SAndroid Build Coastguard Worker 941*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_ALLOW_SCIENTIFIC_NOTATION 942*2e9d4914SAndroid Build Coastguard Worker(@b{Since @i{v1.7}}) 943*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether scientific notation may be used as appropriate 944*2e9d4914SAndroid Build Coastguard Workerwhen writing floating point values (corresponding to @code{printf()} 945*2e9d4914SAndroid Build Coastguard Worker@samp{%g} format) or should never be used (corresponding to @code{printf()} 946*2e9d4914SAndroid Build Coastguard Worker@samp{%f} format). By default this option is turned off. 947*2e9d4914SAndroid Build Coastguard Worker 948*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_FSYNC 949*2e9d4914SAndroid Build Coastguard Worker(@b{Since @i{v1.7.1}}) 950*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether the @code{config_write_file()} function performs 951*2e9d4914SAndroid Build Coastguard Workeran @i{fsync} operation after writing the configuration and before closing the 952*2e9d4914SAndroid Build Coastguard Workerfile. By default this option is turned off. 953*2e9d4914SAndroid Build Coastguard Worker 954*2e9d4914SAndroid Build Coastguard Worker@item CONFIG_OPTION_ALLOW_OVERRIDES 955*2e9d4914SAndroid Build Coastguard Worker(@b{Since @i{v1.7.3}}) 956*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether duplicate settings override previous settings 957*2e9d4914SAndroid Build Coastguard Workerwith the same name. If this option is turned off, duplicate settings are 958*2e9d4914SAndroid Build Coastguard Workerrejected. By default this option is turned off. 959*2e9d4914SAndroid Build Coastguard Worker 960*2e9d4914SAndroid Build Coastguard Worker@end table 961*2e9d4914SAndroid Build Coastguard Worker 962*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 963*2e9d4914SAndroid Build Coastguard Worker 964*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_get_option (@w{config_t *@var{config}}, @w{int @var{option}}) 965*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_set_option (@w{config_t *@var{config}}, @w{int @var{option}}, @w{int @var{flag}}) 966*2e9d4914SAndroid Build Coastguard Worker 967*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 968*2e9d4914SAndroid Build Coastguard Worker 969*2e9d4914SAndroid Build Coastguard WorkerThese functions get and set the given @var{option} of the configuration 970*2e9d4914SAndroid Build Coastguard Worker@var{config}. The option is enabled if @var{flag} is @code{CONFIG_TRUE} and 971*2e9d4914SAndroid Build Coastguard Workerdisabled if it is @code{CONFIG_FALSE}. 972*2e9d4914SAndroid Build Coastguard Worker 973*2e9d4914SAndroid Build Coastguard WorkerSee @code{config_set_options()} above for the list of available options. 974*2e9d4914SAndroid Build Coastguard Worker 975*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 976*2e9d4914SAndroid Build Coastguard Worker 977*2e9d4914SAndroid Build Coastguard Worker 978*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_get_auto_convert (@w{const config_t *@var{config}}) 979*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_set_auto_convert (@w{config_t *@var{config}}, @w{int @var{flag}}) 980*2e9d4914SAndroid Build Coastguard Worker 981*2e9d4914SAndroid Build Coastguard WorkerThese functions get and set the @code{CONFIG_OPTION_AUTO_CONVERT} 982*2e9d4914SAndroid Build Coastguard Workeroption. They are obsoleted by the @code{config_set_option()} and 983*2e9d4914SAndroid Build Coastguard Worker@code{config_get_option()} functions described above. 984*2e9d4914SAndroid Build Coastguard Worker 985*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 986*2e9d4914SAndroid Build Coastguard Worker 987*2e9d4914SAndroid Build Coastguard Worker@deftypefun short config_get_default_format (@w{config_t * @var{config}}) 988*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_set_default_format (@w{config_t * @var{config}}, @w{short @var{format}}) 989*2e9d4914SAndroid Build Coastguard Worker 990*2e9d4914SAndroid Build Coastguard WorkerThese functions, which are implemented as macros, get and set the 991*2e9d4914SAndroid Build Coastguard Workerdefault external format for settings in the configuration 992*2e9d4914SAndroid Build Coastguard Worker@var{config}. If a non-default format has not been set for a setting 993*2e9d4914SAndroid Build Coastguard Workerwith @code{config_setting_set_format()}, this configuration-wide 994*2e9d4914SAndroid Build Coastguard Workerdefault format will be used instead when that setting is written to a 995*2e9d4914SAndroid Build Coastguard Workerfile or stream. 996*2e9d4914SAndroid Build Coastguard Worker 997*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 998*2e9d4914SAndroid Build Coastguard Worker 999*2e9d4914SAndroid Build Coastguard Worker@deftypefun {unsigned short} config_get_tab_width (@w{const config_t * @var{config}}) 1000*2e9d4914SAndroid Build Coastguard Worker@deftypefunx void config_set_tab_width (@w{config_t * @var{config}}, @w{unsigned short @var{width}}) 1001*2e9d4914SAndroid Build Coastguard Worker 1002*2e9d4914SAndroid Build Coastguard WorkerThese functions, which are implemented as macros, get and set the tab 1003*2e9d4914SAndroid Build Coastguard Workerwidth for the configuration @var{config}. The tab width affects the 1004*2e9d4914SAndroid Build Coastguard Workerformatting of the configuration when it is written to a file or 1005*2e9d4914SAndroid Build Coastguard Workerstream: each level of nesting is indented by @var{width} spaces, or 1006*2e9d4914SAndroid Build Coastguard Workerby a single tab character if @var{width} is 0. The tab width has no 1007*2e9d4914SAndroid Build Coastguard Workereffect on parsing. 1008*2e9d4914SAndroid Build Coastguard Worker 1009*2e9d4914SAndroid Build Coastguard WorkerValid tab widths range from 0 to 15. The default tab width is 2. 1010*2e9d4914SAndroid Build Coastguard Worker 1011*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1012*2e9d4914SAndroid Build Coastguard Worker 1013*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_lookup_int (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{int * @var{value}}) 1014*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_lookup_int64 (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{long long * @var{value}}) 1015*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_lookup_float (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{double * @var{value}}) 1016*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_lookup_bool (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{int * @var{value}}) 1017*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_lookup_string (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{const char ** @var{value}}) 1018*2e9d4914SAndroid Build Coastguard Worker 1019*2e9d4914SAndroid Build Coastguard WorkerThese functions look up the value of the setting in the configuration 1020*2e9d4914SAndroid Build Coastguard Worker@var{config} specified by the path @var{path}. They store the value of 1021*2e9d4914SAndroid Build Coastguard Workerthe setting at @var{value} and return @code{CONFIG_TRUE} on 1022*2e9d4914SAndroid Build Coastguard Workersuccess. If the setting was not found or if the type of the value did 1023*2e9d4914SAndroid Build Coastguard Workernot match the type requested, they leave the data pointed to by 1024*2e9d4914SAndroid Build Coastguard Worker@var{value} unmodified and return @code{CONFIG_FALSE}. 1025*2e9d4914SAndroid Build Coastguard Worker 1026*2e9d4914SAndroid Build Coastguard WorkerStorage for the string returned by @code{config_lookup_string()} is 1027*2e9d4914SAndroid Build Coastguard Workermanaged by the library and released automatically when the setting is 1028*2e9d4914SAndroid Build Coastguard Workerdestroyed or when the setting's value is changed; the string must not 1029*2e9d4914SAndroid Build Coastguard Workerbe freed by the caller. 1030*2e9d4914SAndroid Build Coastguard Worker 1031*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1032*2e9d4914SAndroid Build Coastguard Worker 1033*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_lookup (@w{const config_t * @var{config}}, @w{const char * @var{path}}) 1034*2e9d4914SAndroid Build Coastguard Worker 1035*2e9d4914SAndroid Build Coastguard WorkerThis function locates the setting in the configuration @var{config} 1036*2e9d4914SAndroid Build Coastguard Workerspecified by the path @var{path}. It returns a pointer to the 1037*2e9d4914SAndroid Build Coastguard Worker@code{config_setting_t} structure on success, or @code{NULL} if the 1038*2e9d4914SAndroid Build Coastguard Workersetting was not found. 1039*2e9d4914SAndroid Build Coastguard Worker 1040*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1041*2e9d4914SAndroid Build Coastguard Worker 1042*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_setting_lookup (@w{const config_setting_t * @var{setting}}, @w{const char * @var{path}}) 1043*2e9d4914SAndroid Build Coastguard Worker 1044*2e9d4914SAndroid Build Coastguard WorkerThis function locates a setting by a path @var{path} relative to 1045*2e9d4914SAndroid Build Coastguard Workerthe setting @var{setting}. It returns a pointer to the 1046*2e9d4914SAndroid Build Coastguard Worker@code{config_setting_t} structure on success, or @code{NULL} if the 1047*2e9d4914SAndroid Build Coastguard Workersetting was not found. 1048*2e9d4914SAndroid Build Coastguard Worker 1049*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1050*2e9d4914SAndroid Build Coastguard Worker 1051*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_get_int (@w{const config_setting_t * @var{setting}}) 1052*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {long long} config_setting_get_int64 (@w{const config_setting_t * @var{setting}}) 1053*2e9d4914SAndroid Build Coastguard Worker@deftypefunx double config_setting_get_float (@w{const config_setting_t * @var{setting}}) 1054*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_get_bool (@w{const config_setting_t * @var{setting}}) 1055*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {const char *} config_setting_get_string (@w{const config_setting_t * @var{setting}}) 1056*2e9d4914SAndroid Build Coastguard Worker 1057*2e9d4914SAndroid Build Coastguard WorkerThese functions return the value of the given @var{setting}. If the 1058*2e9d4914SAndroid Build Coastguard Workertype of the setting does not match the type requested, a 0 or 1059*2e9d4914SAndroid Build Coastguard Worker@code{NULL} value is returned. Storage for the string returned by 1060*2e9d4914SAndroid Build Coastguard Worker@code{config_setting_get_string()} is managed by the library and 1061*2e9d4914SAndroid Build Coastguard Workerreleased automatically when the setting is destroyed or when the 1062*2e9d4914SAndroid Build Coastguard Workersetting's value is changed; the string must not be freed by the 1063*2e9d4914SAndroid Build Coastguard Workercaller. 1064*2e9d4914SAndroid Build Coastguard Worker 1065*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1066*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_set_int (@w{config_setting_t * @var{setting}}, @w{int @var{value}}) 1067*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_set_int64 (@w{config_setting_t * @var{setting}}, @w{long long @var{value}}) 1068*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_set_float (@w{config_setting_t * @var{setting}}, @w{double @var{value}}) 1069*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_set_bool (@w{config_setting_t * @var{setting}}, @w{int @var{value}}) 1070*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_set_string (@w{config_setting_t * @var{setting}}, @w{const char * @var{value}}) 1071*2e9d4914SAndroid Build Coastguard Worker 1072*2e9d4914SAndroid Build Coastguard WorkerThese functions set the value of the given @var{setting} to 1073*2e9d4914SAndroid Build Coastguard Worker@var{value}. On success, they return @code{CONFIG_TRUE}. If 1074*2e9d4914SAndroid Build Coastguard Workerthe setting does not match the type of the value, they return 1075*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FALSE}. @code{config_setting_set_string()} makes a copy 1076*2e9d4914SAndroid Build Coastguard Workerof the passed string @var{value}, so it may be subsequently freed or 1077*2e9d4914SAndroid Build Coastguard Workermodified by the caller without affecting the value of the setting. 1078*2e9d4914SAndroid Build Coastguard Worker 1079*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1080*2e9d4914SAndroid Build Coastguard Worker 1081*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_lookup_int (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{int * @var{value}}) 1082*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_lookup_int64 (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{long long * @var{value}}) 1083*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_lookup_float (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{double * @var{value}}) 1084*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_lookup_bool (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{int * @var{value}}) 1085*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_lookup_string (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{const char ** @var{value}}) 1086*2e9d4914SAndroid Build Coastguard Worker 1087*2e9d4914SAndroid Build Coastguard WorkerThese functions look up the value of the child setting named 1088*2e9d4914SAndroid Build Coastguard Worker@var{name} of the setting @var{setting}. They store the value at 1089*2e9d4914SAndroid Build Coastguard Worker@var{value} and return @code{CONFIG_TRUE} on success. If the setting 1090*2e9d4914SAndroid Build Coastguard Workerwas not found or if the type of the value did not match the type 1091*2e9d4914SAndroid Build Coastguard Workerrequested, they leave the data pointed to by @var{value} unmodified 1092*2e9d4914SAndroid Build Coastguard Workerand return @code{CONFIG_FALSE}. 1093*2e9d4914SAndroid Build Coastguard Worker 1094*2e9d4914SAndroid Build Coastguard WorkerStorage for the string returned by @code{config_setting_lookup_string()} is 1095*2e9d4914SAndroid Build Coastguard Workermanaged by the library and released automatically when the setting is 1096*2e9d4914SAndroid Build Coastguard Workerdestroyed or when the setting's value is changed; the string must not 1097*2e9d4914SAndroid Build Coastguard Workerbe freed by the caller. 1098*2e9d4914SAndroid Build Coastguard Worker 1099*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1100*2e9d4914SAndroid Build Coastguard Worker 1101*2e9d4914SAndroid Build Coastguard Worker@deftypefun short config_setting_get_format (@w{config_setting_t * @var{setting}}) 1102*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_set_format (@w{config_setting_t * @var{setting}}, @w{short @var{format}}) 1103*2e9d4914SAndroid Build Coastguard Worker 1104*2e9d4914SAndroid Build Coastguard WorkerThese functions get and set the external format for the setting @var{setting}. 1105*2e9d4914SAndroid Build Coastguard Worker 1106*2e9d4914SAndroid Build Coastguard Worker@tindex SettingFormat 1107*2e9d4914SAndroid Build Coastguard Worker@cindex format 1108*2e9d4914SAndroid Build Coastguard Worker 1109*2e9d4914SAndroid Build Coastguard WorkerThe @var{format} must be one of the constants 1110*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FORMAT_DEFAULT} or @code{CONFIG_FORMAT_HEX}. All settings 1111*2e9d4914SAndroid Build Coastguard Workersupport the @code{CONFIG_FORMAT_DEFAULT} format. The 1112*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FORMAT_HEX} format specifies hexadecimal formatting for 1113*2e9d4914SAndroid Build Coastguard Workerinteger values, and hence only applies to settings of type 1114*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TYPE_INT} and @code{CONFIG_TYPE_INT64}. If @var{format} 1115*2e9d4914SAndroid Build Coastguard Workeris invalid for the given setting, it is ignored. 1116*2e9d4914SAndroid Build Coastguard Worker 1117*2e9d4914SAndroid Build Coastguard WorkerIf a non-default format has not been set for the setting, @code{config_setting_get_format()} returns the default format for the configuration, as set by @code{config_set_default_format()}. 1118*2e9d4914SAndroid Build Coastguard Worker 1119*2e9d4914SAndroid Build Coastguard Worker@code{config_setting_set_format()} returns @code{CONFIG_TRUE} on 1120*2e9d4914SAndroid Build Coastguard Workersuccess and @code{CONFIG_FALSE} on failure. 1121*2e9d4914SAndroid Build Coastguard Worker 1122*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1123*2e9d4914SAndroid Build Coastguard Worker 1124*2e9d4914SAndroid Build Coastguard Worker 1125*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_setting_get_member (@w{config_setting_t * @var{setting}}, @w{const char * @var{name}}) 1126*2e9d4914SAndroid Build Coastguard Worker 1127*2e9d4914SAndroid Build Coastguard WorkerThis function fetches the child setting named @var{name} from the group 1128*2e9d4914SAndroid Build Coastguard Worker@var{setting}. It returns the requested setting on success, or 1129*2e9d4914SAndroid Build Coastguard Worker@code{NULL} if the setting was not found or if @var{setting} is not a 1130*2e9d4914SAndroid Build Coastguard Workergroup. 1131*2e9d4914SAndroid Build Coastguard Worker 1132*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1133*2e9d4914SAndroid Build Coastguard Worker 1134*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_setting_get_elem (@w{const config_setting_t * @var{setting}}, @w{unsigned int @var{index}}) 1135*2e9d4914SAndroid Build Coastguard Worker 1136*2e9d4914SAndroid Build Coastguard WorkerThis function fetches the element at the given index @var{index} in the 1137*2e9d4914SAndroid Build Coastguard Workersetting @var{setting}, which must be an array, list, or group. It returns the 1138*2e9d4914SAndroid Build Coastguard Workerrequested setting on success, or @code{NULL} if @var{index} is out of 1139*2e9d4914SAndroid Build Coastguard Workerrange or if @var{setting} is not an array, list, or group. 1140*2e9d4914SAndroid Build Coastguard Worker 1141*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1142*2e9d4914SAndroid Build Coastguard Worker 1143*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_get_int_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}}) 1144*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {long long} config_setting_get_int64_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}}) 1145*2e9d4914SAndroid Build Coastguard Worker@deftypefunx double config_setting_get_float_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}}) 1146*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_get_bool_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}}) 1147*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {const char *} config_setting_get_string_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}}) 1148*2e9d4914SAndroid Build Coastguard Worker 1149*2e9d4914SAndroid Build Coastguard WorkerThese functions return the value at the specified index @var{index} in the 1150*2e9d4914SAndroid Build Coastguard Workersetting @var{setting}. If the setting is not an array or list, or if 1151*2e9d4914SAndroid Build Coastguard Workerthe type of the element does not match the type requested, or if 1152*2e9d4914SAndroid Build Coastguard Worker@var{index} is out of range, they return 0 or @code{NULL}. Storage for 1153*2e9d4914SAndroid Build Coastguard Workerthe string returned by @code{config_setting_get_string_elem()} is 1154*2e9d4914SAndroid Build Coastguard Workermanaged by the library and released automatically when the setting is 1155*2e9d4914SAndroid Build Coastguard Workerdestroyed or when its value is changed; the string must not be freed 1156*2e9d4914SAndroid Build Coastguard Workerby the caller. 1157*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1158*2e9d4914SAndroid Build Coastguard Worker 1159*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_setting_set_int_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{int @var{value}}) 1160*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {config_setting_t *} config_setting_set_int64_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{long long @var{value}}) 1161*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {config_setting_t *} config_setting_set_float_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{double @var{value}}) 1162*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {config_setting_t *} config_setting_set_bool_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{int @var{value}}) 1163*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {config_setting_t *} config_setting_set_string_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{const char * @var{value}}) 1164*2e9d4914SAndroid Build Coastguard Worker 1165*2e9d4914SAndroid Build Coastguard WorkerThese functions set the value at the specified index @var{index} in the 1166*2e9d4914SAndroid Build Coastguard Workersetting @var{setting} to @var{value}. If @var{index} is negative, a 1167*2e9d4914SAndroid Build Coastguard Workernew element is added to the end of the array or list. On success, 1168*2e9d4914SAndroid Build Coastguard Workerthese functions return a pointer to the setting representing the 1169*2e9d4914SAndroid Build Coastguard Workerelement. If the setting is not an array or list, or if the setting is 1170*2e9d4914SAndroid Build Coastguard Workeran array and the type of the array does not match the type of the 1171*2e9d4914SAndroid Build Coastguard Workervalue, or if @var{index} is out of range, they return 1172*2e9d4914SAndroid Build Coastguard Worker@code{NULL}. @code{config_setting_set_string_elem()} makes a copy of 1173*2e9d4914SAndroid Build Coastguard Workerthe passed string @var{value}, so it may be subsequently freed or 1174*2e9d4914SAndroid Build Coastguard Workermodified by the caller without affecting the value of the setting. 1175*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1176*2e9d4914SAndroid Build Coastguard Worker 1177*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_setting_add (@w{config_setting_t * @var{parent}}, @w{const char * @var{name}}, @w{int @var{type}}) 1178*2e9d4914SAndroid Build Coastguard Worker 1179*2e9d4914SAndroid Build Coastguard WorkerThis function adds a new child setting or element to the setting 1180*2e9d4914SAndroid Build Coastguard Worker@var{parent}, which must be a group, array, or list. If @var{parent} 1181*2e9d4914SAndroid Build Coastguard Workeris an array or list, the @var{name} parameter is ignored and may be 1182*2e9d4914SAndroid Build Coastguard Worker@code{NULL}. 1183*2e9d4914SAndroid Build Coastguard Worker 1184*2e9d4914SAndroid Build Coastguard WorkerThe function returns the new setting on success, or @code{NULL} if 1185*2e9d4914SAndroid Build Coastguard Worker@var{parent} is not a group, array, or list; or if there is already a 1186*2e9d4914SAndroid Build Coastguard Workerchild setting of @var{parent} named @var{name}; or if @var{type} is 1187*2e9d4914SAndroid Build Coastguard Workerinvalid. If @var{type} is a scalar type, the new setting will have a 1188*2e9d4914SAndroid Build Coastguard Workerdefault value of 0, 0.0, @code{false}, or @code{NULL}, as appropriate. 1189*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1190*2e9d4914SAndroid Build Coastguard Worker 1191*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_remove (@w{config_setting_t * @var{parent}}, @w{const char * @var{name}}) 1192*2e9d4914SAndroid Build Coastguard Worker 1193*2e9d4914SAndroid Build Coastguard WorkerThis function removes and destroys the setting named @var{name} from 1194*2e9d4914SAndroid Build Coastguard Workerthe parent setting @var{parent}, which must be a group. Any child 1195*2e9d4914SAndroid Build Coastguard Workersettings of the setting are recursively destroyed as well. 1196*2e9d4914SAndroid Build Coastguard Worker 1197*2e9d4914SAndroid Build Coastguard WorkerThe @var{name} parameter can also specify a setting @i{path} relative to 1198*2e9d4914SAndroid Build Coastguard Workerthe provided @var{parent}. 1199*2e9d4914SAndroid Build Coastguard Worker(In that case, the setting will be looked up and removed.) 1200*2e9d4914SAndroid Build Coastguard Worker 1201*2e9d4914SAndroid Build Coastguard WorkerThe function returns @code{CONFIG_TRUE} on success. If @var{parent} is 1202*2e9d4914SAndroid Build Coastguard Workernot a group, or if it has no setting with the given name, it returns 1203*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FALSE}. 1204*2e9d4914SAndroid Build Coastguard Worker 1205*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1206*2e9d4914SAndroid Build Coastguard Worker 1207*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_remove_elem (@w{config_setting_t * @var{parent}}, @w{unsigned int @var{index}}) 1208*2e9d4914SAndroid Build Coastguard Worker 1209*2e9d4914SAndroid Build Coastguard WorkerThis function removes the child setting at the given index @var{index} from 1210*2e9d4914SAndroid Build Coastguard Workerthe setting @var{parent}, which must be a group, list, or array. Any 1211*2e9d4914SAndroid Build Coastguard Workerchild settings of the removed setting are recursively destroyed as 1212*2e9d4914SAndroid Build Coastguard Workerwell. 1213*2e9d4914SAndroid Build Coastguard Worker 1214*2e9d4914SAndroid Build Coastguard WorkerThe function returns @code{CONFIG_TRUE} on success. If @var{parent} is 1215*2e9d4914SAndroid Build Coastguard Workernot a group, list, or array, or if @var{index} is out of range, it returns 1216*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FALSE}. 1217*2e9d4914SAndroid Build Coastguard Worker 1218*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1219*2e9d4914SAndroid Build Coastguard Worker 1220*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_root_setting (@w{const config_t * @var{config}}) 1221*2e9d4914SAndroid Build Coastguard Worker 1222*2e9d4914SAndroid Build Coastguard WorkerThis function, which is implemented as a macro, returns the root setting for the configuration @var{config}. The root setting is a group. 1223*2e9d4914SAndroid Build Coastguard Worker 1224*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1225*2e9d4914SAndroid Build Coastguard Worker 1226*2e9d4914SAndroid Build Coastguard Worker@deftypefun {const char *} config_setting_name (@w{const config_setting_t * @var{setting}}) 1227*2e9d4914SAndroid Build Coastguard Worker 1228*2e9d4914SAndroid Build Coastguard WorkerThis function returns the name of the given @var{setting}, or 1229*2e9d4914SAndroid Build Coastguard Worker@code{NULL} if the setting has no name. Storage for the returned 1230*2e9d4914SAndroid Build Coastguard Workerstring is managed by the library and released automatically when the 1231*2e9d4914SAndroid Build Coastguard Workersetting is destroyed; the string must not be freed by the caller. 1232*2e9d4914SAndroid Build Coastguard Worker 1233*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1234*2e9d4914SAndroid Build Coastguard Worker 1235*2e9d4914SAndroid Build Coastguard Worker@deftypefun {config_setting_t *} config_setting_parent (@w{const config_setting_t * @var{setting}}) 1236*2e9d4914SAndroid Build Coastguard Worker 1237*2e9d4914SAndroid Build Coastguard WorkerThis function returns the parent setting of the given @var{setting}, 1238*2e9d4914SAndroid Build Coastguard Workeror @code{NULL} if @var{setting} is the root setting. 1239*2e9d4914SAndroid Build Coastguard Worker 1240*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1241*2e9d4914SAndroid Build Coastguard Worker 1242*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_is_root (@w{const config_setting_t * @var{setting}}) 1243*2e9d4914SAndroid Build Coastguard Worker 1244*2e9d4914SAndroid Build Coastguard WorkerThis function returns @code{CONFIG_TRUE} if the given @var{setting} is 1245*2e9d4914SAndroid Build Coastguard Workerthe root setting, and @code{CONFIG_FALSE} otherwise. 1246*2e9d4914SAndroid Build Coastguard Worker 1247*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1248*2e9d4914SAndroid Build Coastguard Worker 1249*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_index (@w{const config_setting_t * @var{setting}}) 1250*2e9d4914SAndroid Build Coastguard Worker 1251*2e9d4914SAndroid Build Coastguard WorkerThis function returns the index of the given @var{setting} within its 1252*2e9d4914SAndroid Build Coastguard Workerparent setting. If @var{setting} is the root setting, this function 1253*2e9d4914SAndroid Build Coastguard Workerreturns -1. 1254*2e9d4914SAndroid Build Coastguard Worker 1255*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1256*2e9d4914SAndroid Build Coastguard Worker 1257*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_length (@w{const config_setting_t * @var{setting}}) 1258*2e9d4914SAndroid Build Coastguard Worker 1259*2e9d4914SAndroid Build Coastguard WorkerThis function returns the number of settings in a group, or the number of 1260*2e9d4914SAndroid Build Coastguard Workerelements in a list or array. For other types of settings, it returns 1261*2e9d4914SAndroid Build Coastguard Worker0. 1262*2e9d4914SAndroid Build Coastguard Worker 1263*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1264*2e9d4914SAndroid Build Coastguard Worker 1265*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_type (@w{const config_setting_t * @var{setting}}) 1266*2e9d4914SAndroid Build Coastguard Worker 1267*2e9d4914SAndroid Build Coastguard WorkerThis function returns the type of the given @var{setting}. The return 1268*2e9d4914SAndroid Build Coastguard Workervalue is one of the constants 1269*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TYPE_INT}, @code{CONFIG_TYPE_INT64}, @code{CONFIG_TYPE_FLOAT}, 1270*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TYPE_STRING}, @code{CONFIG_TYPE_BOOL}, 1271*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TYPE_ARRAY}, @code{CONFIG_TYPE_LIST}, or @code{CONFIG_TYPE_GROUP}. 1272*2e9d4914SAndroid Build Coastguard Worker 1273*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1274*2e9d4914SAndroid Build Coastguard Worker 1275*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_is_group (@w{const config_setting_t * @var{setting}}) 1276*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_is_array (@w{const config_setting_t * @var{setting}}) 1277*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_is_list (@w{const config_setting_t * @var{setting}}) 1278*2e9d4914SAndroid Build Coastguard Worker 1279*2e9d4914SAndroid Build Coastguard WorkerThese convenience functions, which are implemented as macros, test if 1280*2e9d4914SAndroid Build Coastguard Workerthe setting @var{setting} is of a given type. They return 1281*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_TRUE} or @code{CONFIG_FALSE}. 1282*2e9d4914SAndroid Build Coastguard Worker 1283*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1284*2e9d4914SAndroid Build Coastguard Worker 1285*2e9d4914SAndroid Build Coastguard Worker@deftypefun int config_setting_is_aggregate (@w{const config_setting_t * @var{setting}}) 1286*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_is_scalar (@w{const config_setting_t * @var{setting}}) 1287*2e9d4914SAndroid Build Coastguard Worker@deftypefunx int config_setting_is_number (@w{const config_setting_t * @var{setting}}) 1288*2e9d4914SAndroid Build Coastguard Worker 1289*2e9d4914SAndroid Build Coastguard Worker@cindex aggregate value 1290*2e9d4914SAndroid Build Coastguard WorkerThese convenience functions, some of which are implemented as macros, test if 1291*2e9d4914SAndroid Build Coastguard Workerthe setting @var{setting} is of an aggregate type (a group, array, or 1292*2e9d4914SAndroid Build Coastguard Workerlist), of a scalar type (integer, 64-bit integer, floating point, 1293*2e9d4914SAndroid Build Coastguard Workerboolean, or string), and of a number (integer, 64-bit integer, or 1294*2e9d4914SAndroid Build Coastguard Workerfloating point), respectively. They return @code{CONFIG_TRUE} or 1295*2e9d4914SAndroid Build Coastguard Worker@code{CONFIG_FALSE}. 1296*2e9d4914SAndroid Build Coastguard Worker 1297*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1298*2e9d4914SAndroid Build Coastguard Worker 1299*2e9d4914SAndroid Build Coastguard Worker@deftypefun {const char *} config_setting_source_file (@w{const config_setting_t * @var{setting}}) 1300*2e9d4914SAndroid Build Coastguard Worker 1301*2e9d4914SAndroid Build Coastguard WorkerThis function returns the name of the file from which the setting 1302*2e9d4914SAndroid Build Coastguard Worker@var{setting} was read, or NULL if the setting was not read from a 1303*2e9d4914SAndroid Build Coastguard Workerfile. This information is useful for reporting application-level 1304*2e9d4914SAndroid Build Coastguard Workererrors. Storage for the returned string is managed by the library and 1305*2e9d4914SAndroid Build Coastguard Workerreleased automatically when the configuration is destroyed; the 1306*2e9d4914SAndroid Build Coastguard Workerstring must not be freed by the caller. 1307*2e9d4914SAndroid Build Coastguard Worker 1308*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1309*2e9d4914SAndroid Build Coastguard Worker 1310*2e9d4914SAndroid Build Coastguard Worker@deftypefun {unsigned int} config_setting_source_line (@w{const config_setting_t * @var{setting}}) 1311*2e9d4914SAndroid Build Coastguard Worker 1312*2e9d4914SAndroid Build Coastguard WorkerThis function returns the line number of the configuration file or 1313*2e9d4914SAndroid Build Coastguard Workerstream at which the setting @var{setting} was read, or 0 if no line 1314*2e9d4914SAndroid Build Coastguard Workernumber is available. This information is useful for reporting 1315*2e9d4914SAndroid Build Coastguard Workerapplication-level errors. 1316*2e9d4914SAndroid Build Coastguard Worker 1317*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1318*2e9d4914SAndroid Build Coastguard Worker 1319*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_set_hook (@w{config_t * @var{config}}, @w{void * @var{hook}}) 1320*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {void *} config_get_hook (@w{const config_t * @var{config}}) 1321*2e9d4914SAndroid Build Coastguard Worker 1322*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 1323*2e9d4914SAndroid Build Coastguard Worker 1324*2e9d4914SAndroid Build Coastguard Worker@cindex hook 1325*2e9d4914SAndroid Build Coastguard WorkerThese functions make it possible to attach arbitrary data to a configuration 1326*2e9d4914SAndroid Build Coastguard Workerstructure, for instance a ``wrapper'' or ``peer'' object written in 1327*2e9d4914SAndroid Build Coastguard Workeranother programming language. 1328*2e9d4914SAndroid Build Coastguard Worker 1329*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1330*2e9d4914SAndroid Build Coastguard Worker 1331*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_setting_set_hook (@w{config_setting_t * @var{setting}}, @w{void * @var{hook}}) 1332*2e9d4914SAndroid Build Coastguard Worker@deftypefunx {void *} config_setting_get_hook (@w{const config_setting_t * @var{setting}}) 1333*2e9d4914SAndroid Build Coastguard Worker 1334*2e9d4914SAndroid Build Coastguard Worker@cindex hook 1335*2e9d4914SAndroid Build Coastguard WorkerThese functions make it possible to attach arbitrary data to each 1336*2e9d4914SAndroid Build Coastguard Workersetting structure, for instance a ``wrapper'' or ``peer'' object written in 1337*2e9d4914SAndroid Build Coastguard Workeranother programming language. The destructor function, if one has been 1338*2e9d4914SAndroid Build Coastguard Workersupplied via a call to @code{config_set_destructor()}, will be called 1339*2e9d4914SAndroid Build Coastguard Workerby the library to dispose of this data when the setting itself is 1340*2e9d4914SAndroid Build Coastguard Workerdestroyed. There is no default destructor. 1341*2e9d4914SAndroid Build Coastguard Worker 1342*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1343*2e9d4914SAndroid Build Coastguard Worker 1344*2e9d4914SAndroid Build Coastguard Worker@deftypefun void config_set_destructor (@w{config_t * @var{config}}, @w{void (* @var{destructor})(void *)}) 1345*2e9d4914SAndroid Build Coastguard Worker 1346*2e9d4914SAndroid Build Coastguard Worker@cindex destructor function 1347*2e9d4914SAndroid Build Coastguard WorkerThis function assigns the destructor function @var{destructor} for the 1348*2e9d4914SAndroid Build Coastguard Workerconfiguration @var{config}. This function accepts a single @code{void 1349*2e9d4914SAndroid Build Coastguard Worker*} argument and has no return value. See 1350*2e9d4914SAndroid Build Coastguard Worker@code{config_setting_set_hook()} above for more information. 1351*2e9d4914SAndroid Build Coastguard Worker 1352*2e9d4914SAndroid Build Coastguard Worker@end deftypefun 1353*2e9d4914SAndroid Build Coastguard Worker 1354*2e9d4914SAndroid Build Coastguard Worker@node The C++ API, Example Programs, The C API, Top 1355*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 1356*2e9d4914SAndroid Build Coastguard Worker@chapter The C++ API 1357*2e9d4914SAndroid Build Coastguard Worker 1358*2e9d4914SAndroid Build Coastguard Worker@tindex Config 1359*2e9d4914SAndroid Build Coastguard Worker@tindex Setting 1360*2e9d4914SAndroid Build Coastguard WorkerThis chapter describes the C++ library API. The class @code{Config} 1361*2e9d4914SAndroid Build Coastguard Workerrepresents a configuration, and the class @code{Setting} represents a 1362*2e9d4914SAndroid Build Coastguard Workerconfiguration setting. Note that by design, neither of these classes 1363*2e9d4914SAndroid Build Coastguard Workerprovides a public copy constructor or assignment operator. Therefore, 1364*2e9d4914SAndroid Build Coastguard Workerinstances of these classes may only be passed between functions via 1365*2e9d4914SAndroid Build Coastguard Workerreferences or pointers. 1366*2e9d4914SAndroid Build Coastguard Worker 1367*2e9d4914SAndroid Build Coastguard Worker@tindex ConfigException 1368*2e9d4914SAndroid Build Coastguard WorkerThe library defines a group of exceptions, all of which extend the 1369*2e9d4914SAndroid Build Coastguard Workercommon base exception @code{ConfigException}. 1370*2e9d4914SAndroid Build Coastguard Worker 1371*2e9d4914SAndroid Build Coastguard Worker@tindex SettingTypeException 1372*2e9d4914SAndroid Build Coastguard WorkerA @code{SettingTypeException} is thrown when the type of a setting's 1373*2e9d4914SAndroid Build Coastguard Workervalue does not match the type requested. 1374*2e9d4914SAndroid Build Coastguard Worker 1375*2e9d4914SAndroid Build Coastguard Worker@deftypemethod SettingTypeException {} SettingTypeException (@w{const Setting &@var{setting}}) 1376*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx SettingTypeException {} SettingTypeException (@w{const Setting &@var{setting}}, @w{int @var{index}}) 1377*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx SettingTypeException {} SettingTypeException (@w{const Setting &@var{setting}}, @w{const char *@var{name}}) 1378*2e9d4914SAndroid Build Coastguard Worker 1379*2e9d4914SAndroid Build Coastguard WorkerThese methods construct @code{SettingTypeException} objects for the given @var{setting} and/or member @var{index} or @var{name}. 1380*2e9d4914SAndroid Build Coastguard Worker 1381*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1382*2e9d4914SAndroid Build Coastguard Worker 1383*2e9d4914SAndroid Build Coastguard Worker@tindex SettingNotFoundException 1384*2e9d4914SAndroid Build Coastguard WorkerA @code{SettingNotFoundException} is thrown when a setting is not found. 1385*2e9d4914SAndroid Build Coastguard Worker 1386*2e9d4914SAndroid Build Coastguard Worker@deftypemethod SettingNotFoundException {} SettingNotFoundException (@w{const Setting &@var{setting}}, @w{int @var{index}}) 1387*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx SettingNotFoundException {} SettingNotFoundException (@w{const Setting &@var{setting}}, @w{const char *@var{name}}) 1388*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx SettingNotFoundException {} SettingNotFoundException (@w{const char *@var{path}}) 1389*2e9d4914SAndroid Build Coastguard Worker 1390*2e9d4914SAndroid Build Coastguard WorkerThese methods construct @code{SettingTypeException} objects for the given @var{setting} and member @var{index} or @var{name}, or path @var{path}. 1391*2e9d4914SAndroid Build Coastguard Worker 1392*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1393*2e9d4914SAndroid Build Coastguard Worker 1394*2e9d4914SAndroid Build Coastguard Worker@tindex SettingNameException 1395*2e9d4914SAndroid Build Coastguard WorkerA @code{SettingNameException} is thrown when an attempt is made to add 1396*2e9d4914SAndroid Build Coastguard Workera new setting with a non-unique or invalid name. 1397*2e9d4914SAndroid Build Coastguard Worker 1398*2e9d4914SAndroid Build Coastguard Worker@deftypemethod SettingNameException {} SettingNameException (@w{const Setting &@var{setting}}, @w{const char *@var{name}}) 1399*2e9d4914SAndroid Build Coastguard Worker 1400*2e9d4914SAndroid Build Coastguard WorkerThis method constructs a @code{SettingNameExcpetion} object for the given @var{setting} and member name @var{name}. 1401*2e9d4914SAndroid Build Coastguard Worker 1402*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1403*2e9d4914SAndroid Build Coastguard Worker 1404*2e9d4914SAndroid Build Coastguard Worker@tindex ParseException 1405*2e9d4914SAndroid Build Coastguard WorkerA @code{ParseException} is thrown when a parse error occurs while 1406*2e9d4914SAndroid Build Coastguard Workerreading a configuration from a stream. 1407*2e9d4914SAndroid Build Coastguard Worker 1408*2e9d4914SAndroid Build Coastguard Worker@deftypemethod ParseException {} ParseException (@w{const char *@var{file}}, @w{int @var{line}}, @w{const char *@var{error}}) 1409*2e9d4914SAndroid Build Coastguard Worker 1410*2e9d4914SAndroid Build Coastguard WorkerThis method constructs a @code{ParseException} object with the given filename @var{file}, line number @var{line}, and error message @var{error}. 1411*2e9d4914SAndroid Build Coastguard Worker 1412*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1413*2e9d4914SAndroid Build Coastguard Worker 1414*2e9d4914SAndroid Build Coastguard Worker@tindex FileIOException 1415*2e9d4914SAndroid Build Coastguard WorkerA @code{FileIOException} is thrown when an I/O error occurs while 1416*2e9d4914SAndroid Build Coastguard Workerreading/writing a configuration from/to a file. 1417*2e9d4914SAndroid Build Coastguard Worker 1418*2e9d4914SAndroid Build Coastguard Worker@tindex SettingException 1419*2e9d4914SAndroid Build Coastguard Worker@code{SettingTypeException}, @code{SettingNotFoundException}, and 1420*2e9d4914SAndroid Build Coastguard Worker@code{SettingNameException} all extend the common base 1421*2e9d4914SAndroid Build Coastguard Workerexception @code{SettingException}, which provides the following method: 1422*2e9d4914SAndroid Build Coastguard Worker 1423*2e9d4914SAndroid Build Coastguard Worker@deftypemethod SettingException {const char *} getPath () const 1424*2e9d4914SAndroid Build Coastguard Worker 1425*2e9d4914SAndroid Build Coastguard WorkerThis method returns the path to the setting associated with the exception, or 1426*2e9d4914SAndroid Build Coastguard Worker@code{NULL} if there is no applicable path. 1427*2e9d4914SAndroid Build Coastguard Worker 1428*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1429*2e9d4914SAndroid Build Coastguard Worker 1430*2e9d4914SAndroid Build Coastguard WorkerThe remainder of this chapter describes the methods for manipulating 1431*2e9d4914SAndroid Build Coastguard Workerconfigurations and configuration settings. 1432*2e9d4914SAndroid Build Coastguard Worker 1433*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config {} Config () 1434*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config {} ~Config () 1435*2e9d4914SAndroid Build Coastguard Worker 1436*2e9d4914SAndroid Build Coastguard WorkerThese methods create and destroy @code{Config} objects. 1437*2e9d4914SAndroid Build Coastguard Worker 1438*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1439*2e9d4914SAndroid Build Coastguard Worker 1440*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config void clear () 1441*2e9d4914SAndroid Build Coastguard Worker 1442*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 1443*2e9d4914SAndroid Build Coastguard Worker 1444*2e9d4914SAndroid Build Coastguard WorkerThis method clears the configuration. All child settings of the root 1445*2e9d4914SAndroid Build Coastguard Workersetting are recursively destroyed. All other attributes of the 1446*2e9d4914SAndroid Build Coastguard Workerconfiguration are left unchanged. 1447*2e9d4914SAndroid Build Coastguard Worker 1448*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1449*2e9d4914SAndroid Build Coastguard Worker 1450*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config void read (@w{FILE * @var{stream}}) 1451*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void write (@w{FILE * @var{stream}}) const 1452*2e9d4914SAndroid Build Coastguard Worker 1453*2e9d4914SAndroid Build Coastguard WorkerThe @code{read()} method reads and parses a configuration from the given 1454*2e9d4914SAndroid Build Coastguard Worker@var{stream}. A @code{ParseException} is thrown if a parse error occurs. 1455*2e9d4914SAndroid Build Coastguard Worker 1456*2e9d4914SAndroid Build Coastguard WorkerThe @code{write()} method writes the configuration to the given @var{stream}. 1457*2e9d4914SAndroid Build Coastguard Worker 1458*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1459*2e9d4914SAndroid Build Coastguard Worker 1460*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config void readFile (@w{const char * @var{filename}}) 1461*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void readFile (@w{const std::string &@var{filename}}) 1462*2e9d4914SAndroid Build Coastguard Worker 1463*2e9d4914SAndroid Build Coastguard WorkerThe @code{readFile()} method reads and parses a configuration from the 1464*2e9d4914SAndroid Build Coastguard Workerfile named @var{filename}. A @code{ParseException} is thrown if a 1465*2e9d4914SAndroid Build Coastguard Workerparse error occurs. A @code{FileIOException} is thrown if the file 1466*2e9d4914SAndroid Build Coastguard Workercannot be read. 1467*2e9d4914SAndroid Build Coastguard Worker 1468*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1469*2e9d4914SAndroid Build Coastguard Worker 1470*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config void writeFile (@w{const char * @var{filename}}) 1471*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void writeFile (@w{const std::string &@var{filename}}) 1472*2e9d4914SAndroid Build Coastguard Worker 1473*2e9d4914SAndroid Build Coastguard WorkerThe @code{writeFile()} method writes the configuration to the file 1474*2e9d4914SAndroid Build Coastguard Workernamed @var{filename}. A @code{FileIOException} is thrown if the file cannot 1475*2e9d4914SAndroid Build Coastguard Workerbe written. 1476*2e9d4914SAndroid Build Coastguard Worker 1477*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1478*2e9d4914SAndroid Build Coastguard Worker 1479*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config void readString (@w{const char * @var{str}}) 1480*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void readString (@w{const std::string &@var{str}}) 1481*2e9d4914SAndroid Build Coastguard Worker 1482*2e9d4914SAndroid Build Coastguard WorkerThese methods read and parse a configuration from the string 1483*2e9d4914SAndroid Build Coastguard Worker@var{str}. A @code{ParseException} is thrown if a parse error occurs. 1484*2e9d4914SAndroid Build Coastguard Worker 1485*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1486*2e9d4914SAndroid Build Coastguard Worker 1487*2e9d4914SAndroid Build Coastguard Worker@deftypemethod ParseException {const char *} getError () const 1488*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx ParseException {const char *} getFile () const 1489*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx ParseException int getLine () const 1490*2e9d4914SAndroid Build Coastguard Worker 1491*2e9d4914SAndroid Build Coastguard WorkerIf a call to @code{readFile()}, @code{readString()}, or @code{read()} 1492*2e9d4914SAndroid Build Coastguard Workerresulted in a @code{ParseException}, these methods can be called on 1493*2e9d4914SAndroid Build Coastguard Workerthe exception object to obtain the text, filename, and line number of 1494*2e9d4914SAndroid Build Coastguard Workerthe parse error. Storage for the strings returned by @code{getError()} 1495*2e9d4914SAndroid Build Coastguard Workerand @code{getFile()} are managed by the library; the strings must not 1496*2e9d4914SAndroid Build Coastguard Workerbe freed by the caller. 1497*2e9d4914SAndroid Build Coastguard Worker 1498*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1499*2e9d4914SAndroid Build Coastguard Worker 1500*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config void setIncludeDir (@w{const char *@var{includeDir}}) 1501*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config {const char *} getIncludeDir () const 1502*2e9d4914SAndroid Build Coastguard Worker 1503*2e9d4914SAndroid Build Coastguard WorkerThe @code{setIncludeDir()} method specifies the include directory, 1504*2e9d4914SAndroid Build Coastguard Worker@var{includeDir}, relative to which the files specified in 1505*2e9d4914SAndroid Build Coastguard Worker@samp{@@include} directives will be located for the configuration. By 1506*2e9d4914SAndroid Build Coastguard Workerdefault, there is no include directory, and all include files are 1507*2e9d4914SAndroid Build Coastguard Workerexpected to be relative to the current working directory. If 1508*2e9d4914SAndroid Build Coastguard Worker@var{includeDir} is @code{NULL}, the default behavior is reinstated. 1509*2e9d4914SAndroid Build Coastguard Worker 1510*2e9d4914SAndroid Build Coastguard WorkerFor example, if the include directory is set to @file{/usr/local/etc}, 1511*2e9d4914SAndroid Build Coastguard Workerthe include directive @samp{@@include "configs/extra.cfg"} would include the 1512*2e9d4914SAndroid Build Coastguard Workerfile @file{/usr/local/etc/configs/extra.cfg}. 1513*2e9d4914SAndroid Build Coastguard Worker 1514*2e9d4914SAndroid Build Coastguard Worker@code{getIncludeDir()} returns the current include directory for the 1515*2e9d4914SAndroid Build Coastguard Workerconfiguration, or @code{NULL} if none is set. 1516*2e9d4914SAndroid Build Coastguard Worker 1517*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1518*2e9d4914SAndroid Build Coastguard Worker 1519*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config {virtual const char **} evaluateIncludePath (@w{const char * @var{path}}, @w{const char ** @var{error}}) 1520*2e9d4914SAndroid Build Coastguard Worker 1521*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 1522*2e9d4914SAndroid Build Coastguard Worker 1523*2e9d4914SAndroid Build Coastguard WorkerThis method is called to evaluate the path of an @code{@@include} directive. 1524*2e9d4914SAndroid Build Coastguard WorkerThe @var{path} is the literal path argument of the directive. The method may 1525*2e9d4914SAndroid Build Coastguard Workerbe overridden in a subclass to perform tasks like wildcard expansion and 1526*2e9d4914SAndroid Build Coastguard Workervariable substitution. 1527*2e9d4914SAndroid Build Coastguard Worker 1528*2e9d4914SAndroid Build Coastguard WorkerOn success, the method should return a @code{NULL}-terminated array of paths. 1529*2e9d4914SAndroid Build Coastguard WorkerAny relative paths must be relative to the program's current working directory. 1530*2e9d4914SAndroid Build Coastguard WorkerThe contents of these files will be inlined at the point of inclusion, in the 1531*2e9d4914SAndroid Build Coastguard Workerorder that the paths appear in the array. Both the array and its elements should 1532*2e9d4914SAndroid Build Coastguard Workerbe heap allocated; the library will take ownership of and eventually free the 1533*2e9d4914SAndroid Build Coastguard Workerstrings in the array and the array itself. 1534*2e9d4914SAndroid Build Coastguard Worker 1535*2e9d4914SAndroid Build Coastguard WorkerOn failure, the function should return @code{NULL} and set @var{*error} to a 1536*2e9d4914SAndroid Build Coastguard Workerstatic error string which should be used as the parse error for the 1537*2e9d4914SAndroid Build Coastguard Workerconfiguration; the library does not take ownership of or free this string. 1538*2e9d4914SAndroid Build Coastguard Worker 1539*2e9d4914SAndroid Build Coastguard WorkerThe default implementation simply returns a @code{NULL}-terminated array 1540*2e9d4914SAndroid Build Coastguard Workercontaining either a copy of @var{path} if it's an absolute path, or a 1541*2e9d4914SAndroid Build Coastguard Workerconcatenation of the include directory and @var{path} if it's a relative path. 1542*2e9d4914SAndroid Build Coastguard Worker 1543*2e9d4914SAndroid Build Coastguard WorkerFor more information see @code{config_set_include_func()} above. 1544*2e9d4914SAndroid Build Coastguard Worker 1545*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1546*2e9d4914SAndroid Build Coastguard Worker 1547*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config int getOptions () const 1548*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void setOptions (int @var{options}) 1549*2e9d4914SAndroid Build Coastguard Worker 1550*2e9d4914SAndroid Build Coastguard Worker@tindex Config::Option 1551*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the options for the configuration. The 1552*2e9d4914SAndroid Build Coastguard Workeroptions affect how configurations are read and written. The parameter 1553*2e9d4914SAndroid Build Coastguard Worker@var{options} should be a bitwise-OR of the following @var{Config::Option} 1554*2e9d4914SAndroid Build Coastguard Workerenumeration values: 1555*2e9d4914SAndroid Build Coastguard Worker 1556*2e9d4914SAndroid Build Coastguard Worker@table @code 1557*2e9d4914SAndroid Build Coastguard Worker 1558*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionAutoConvert 1559*2e9d4914SAndroid Build Coastguard WorkerTurning this option on enables number auto-conversion for 1560*2e9d4914SAndroid Build Coastguard Workerthe configuration. When this feature is enabled, an attempt to retrieve a 1561*2e9d4914SAndroid Build Coastguard Workerfloating point setting's value into an integer (or vice versa), or 1562*2e9d4914SAndroid Build Coastguard Workerstore an integer to a floating point setting's value (or vice versa) 1563*2e9d4914SAndroid Build Coastguard Workerwill cause the library to silently perform the necessary conversion 1564*2e9d4914SAndroid Build Coastguard Worker(possibly leading to loss of data), rather than reporting failure. By 1565*2e9d4914SAndroid Build Coastguard Workerdefault this option is turned off. 1566*2e9d4914SAndroid Build Coastguard Worker 1567*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionSemicolonSeparators 1568*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether a semicolon (`;') is output after each setting 1569*2e9d4914SAndroid Build Coastguard Workerwhen the configuration is written to a file or stream. (The semicolon 1570*2e9d4914SAndroid Build Coastguard Workerseparators are optional in the configuration syntax.) By default this 1571*2e9d4914SAndroid Build Coastguard Workeroption is turned on. 1572*2e9d4914SAndroid Build Coastguard Worker 1573*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionColonAssignmentForGroups 1574*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether a colon (`:') is output between each 1575*2e9d4914SAndroid Build Coastguard Workergroup setting's name and its value when the configuration is written to 1576*2e9d4914SAndroid Build Coastguard Workera file or stream. If the option is turned off, an equals sign (`=') is 1577*2e9d4914SAndroid Build Coastguard Workeroutput instead. (These tokens are interchangeable in the configuration 1578*2e9d4914SAndroid Build Coastguard Workersyntax.) By default this option is turned on. 1579*2e9d4914SAndroid Build Coastguard Worker 1580*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionColonAssignmentForNonGroups 1581*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether a colon (`:') is output between each 1582*2e9d4914SAndroid Build Coastguard Workernon-group setting's name and its value when the configuration is written 1583*2e9d4914SAndroid Build Coastguard Workerto a file or stream. If the option is turned off, an equals sign (`=') 1584*2e9d4914SAndroid Build Coastguard Workeris output instead. (These tokens are interchangeable in the configuration 1585*2e9d4914SAndroid Build Coastguard Workersyntax.) By default this option is turned off. 1586*2e9d4914SAndroid Build Coastguard Worker 1587*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionOpenBraceOnSeparateLine 1588*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether an open brace (`@{') will be written on its own 1589*2e9d4914SAndroid Build Coastguard Workerline when the configuration is written to a file or stream. If the option is 1590*2e9d4914SAndroid Build Coastguard Workerturned off, the brace will be written at the end of the previous line. 1591*2e9d4914SAndroid Build Coastguard WorkerBy default this option is turned on. 1592*2e9d4914SAndroid Build Coastguard Worker 1593*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionAllowScientificNotation 1594*2e9d4914SAndroid Build Coastguard Worker(@b{Since @i{v1.7}}) 1595*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether scientific notation may be used as appropriate 1596*2e9d4914SAndroid Build Coastguard Workerwhen writing floating point values (corresponding to @code{printf()} 1597*2e9d4914SAndroid Build Coastguard Worker@samp{%g} format) or should never be used (corresponding to @code{printf()} 1598*2e9d4914SAndroid Build Coastguard Worker@samp{%f} format). By default this option is turned off. 1599*2e9d4914SAndroid Build Coastguard Worker 1600*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionFsync 1601*2e9d4914SAndroid Build Coastguard Worker(@b{Since @i{v1.7.1}}) 1602*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether the @code{writeFile()} method performs an @i{fsync} 1603*2e9d4914SAndroid Build Coastguard Workeroperation after writing the configuration and before closing the file. By 1604*2e9d4914SAndroid Build Coastguard Workerdefault this option is turned off. 1605*2e9d4914SAndroid Build Coastguard Worker 1606*2e9d4914SAndroid Build Coastguard Worker@item Config::OptionAllowOverrides 1607*2e9d4914SAndroid Build Coastguard Worker(@b{Since @i{v1.7.3}}) 1608*2e9d4914SAndroid Build Coastguard WorkerThis option controls whether duplicate settings override previous settings 1609*2e9d4914SAndroid Build Coastguard Workerwith the same name. If this option is turned off, duplicate settings are 1610*2e9d4914SAndroid Build Coastguard Workerrejected. By default this option is turned off. 1611*2e9d4914SAndroid Build Coastguard Worker 1612*2e9d4914SAndroid Build Coastguard Worker@end table 1613*2e9d4914SAndroid Build Coastguard Worker 1614*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1615*2e9d4914SAndroid Build Coastguard Worker 1616*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config bool getOption (@w{Config::Option @var{option}}) const 1617*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void setOption (@w{Config::Option @var{option}}, @w{bool @var{flag}}) 1618*2e9d4914SAndroid Build Coastguard Worker 1619*2e9d4914SAndroid Build Coastguard Worker@b{Since @i{v1.7}} 1620*2e9d4914SAndroid Build Coastguard Worker 1621*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the option @var{option} for the configuration. The 1622*2e9d4914SAndroid Build Coastguard Workeroption is enabled if @var{flag} is @code{true} and disabled if it is 1623*2e9d4914SAndroid Build Coastguard Worker@code{false}. 1624*2e9d4914SAndroid Build Coastguard Worker 1625*2e9d4914SAndroid Build Coastguard WorkerSee @code{setOptions()} above for the list of available options. 1626*2e9d4914SAndroid Build Coastguard Worker 1627*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1628*2e9d4914SAndroid Build Coastguard Worker 1629*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config bool getAutoConvert () const 1630*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void setAutoConvert (bool @var{flag}) 1631*2e9d4914SAndroid Build Coastguard Worker 1632*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the @code{OptionAutoConvert} option. They 1633*2e9d4914SAndroid Build Coastguard Workerare obsoleted by the @code{setOption()} and @code{getOption()} 1634*2e9d4914SAndroid Build Coastguard Workermethods described above. 1635*2e9d4914SAndroid Build Coastguard Worker 1636*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1637*2e9d4914SAndroid Build Coastguard Worker 1638*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config Setting::Format getDefaultFormat () const 1639*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void setDefaultFormat (@w{Setting::Format @var{format}}) 1640*2e9d4914SAndroid Build Coastguard Worker 1641*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the default external format for settings in 1642*2e9d4914SAndroid Build Coastguard Workerthe configuration. If a non-default format has not been set for a 1643*2e9d4914SAndroid Build Coastguard Workersetting with @code{Setting::setFormat()}, this configuration-wide 1644*2e9d4914SAndroid Build Coastguard Workerdefault format will be used instead when that setting is written to a 1645*2e9d4914SAndroid Build Coastguard Workerfile or stream. 1646*2e9d4914SAndroid Build Coastguard Worker 1647*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1648*2e9d4914SAndroid Build Coastguard Worker 1649*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config {unsigned short} getTabWidth () const 1650*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void setTabWidth (@w{unsigned short @var{width}}) 1651*2e9d4914SAndroid Build Coastguard Worker 1652*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the tab width for the configuration. The tab 1653*2e9d4914SAndroid Build Coastguard Workerwidth affects the formatting of the configuration when it is written 1654*2e9d4914SAndroid Build Coastguard Workerto a file or stream: each level of nesting is indented by @var{width} 1655*2e9d4914SAndroid Build Coastguard Workerspaces, or by a single tab character if @var{width} is 0. The tab 1656*2e9d4914SAndroid Build Coastguard Workerwidth has no effect on parsing. 1657*2e9d4914SAndroid Build Coastguard Worker 1658*2e9d4914SAndroid Build Coastguard WorkerValid tab widths range from 0 to 15. The default tab width is 2. 1659*2e9d4914SAndroid Build Coastguard Worker 1660*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1661*2e9d4914SAndroid Build Coastguard Worker 1662*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config {unsigned short} getFloatPrecision () const 1663*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config void setFloatPrecision (@w{unsigned short @var{width}}) 1664*2e9d4914SAndroid Build Coastguard Worker 1665*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the float precision for the configuration. 1666*2e9d4914SAndroid Build Coastguard WorkerThis parameter influences the formatting of floating point settings in 1667*2e9d4914SAndroid Build Coastguard Workerthe configuration when it is written to a file or stream. 1668*2e9d4914SAndroid Build Coastguard WorkerFloat precision has no effect on parsing. 1669*2e9d4914SAndroid Build Coastguard Worker 1670*2e9d4914SAndroid Build Coastguard WorkerValid precisions range from 0 to about 15 (implementation dependent), 1671*2e9d4914SAndroid Build Coastguard Workerthough the library will accept and store values up to 255. 1672*2e9d4914SAndroid Build Coastguard Worker 1673*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1674*2e9d4914SAndroid Build Coastguard Worker 1675*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config {Setting &} getRoot () const 1676*2e9d4914SAndroid Build Coastguard Worker 1677*2e9d4914SAndroid Build Coastguard WorkerThis method returns the root setting for the configuration, which is a group. 1678*2e9d4914SAndroid Build Coastguard Worker 1679*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1680*2e9d4914SAndroid Build Coastguard Worker 1681*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config {Setting &} lookup (@w{const std::string &@var{path}}) const 1682*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config {Setting &} lookup (@w{const char * @var{path}}) const 1683*2e9d4914SAndroid Build Coastguard Worker 1684*2e9d4914SAndroid Build Coastguard WorkerThese methods locate the setting specified by the path @var{path}. If 1685*2e9d4914SAndroid Build Coastguard Workerthe requested setting is not found, a @code{SettingNotFoundException} is 1686*2e9d4914SAndroid Build Coastguard Workerthrown. 1687*2e9d4914SAndroid Build Coastguard Worker 1688*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1689*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config bool exists (@w{const std::string &@var{path}}) const 1690*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool exists (@w{const char *@var{path}}) const 1691*2e9d4914SAndroid Build Coastguard Worker 1692*2e9d4914SAndroid Build Coastguard WorkerThese methods test if a setting with the given @var{path} exists in 1693*2e9d4914SAndroid Build Coastguard Workerthe configuration. They return @code{true} if the setting exists, and 1694*2e9d4914SAndroid Build Coastguard Worker@code{false} otherwise. These methods do not throw exceptions. 1695*2e9d4914SAndroid Build Coastguard Worker 1696*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1697*2e9d4914SAndroid Build Coastguard Worker 1698*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Config bool lookupValue (@w{const char *@var{path}}, @w{bool &@var{value}}) const 1699*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{bool &@var{value}}) const 1700*2e9d4914SAndroid Build Coastguard Worker 1701*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{int &@var{value}}) const 1702*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{int &@var{value}}) const 1703*2e9d4914SAndroid Build Coastguard Worker 1704*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{unsigned int &@var{value}}) const 1705*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{unsigned int &@var{value}}) const 1706*2e9d4914SAndroid Build Coastguard Worker 1707*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{long long &@var{value}}) const 1708*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{long long &@var{value}}) const 1709*2e9d4914SAndroid Build Coastguard Worker 1710*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{float &@var{value}}) const 1711*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{float &@var{value}}) const 1712*2e9d4914SAndroid Build Coastguard Worker 1713*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{double &@var{value}}) const 1714*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{double &@var{value}}) const 1715*2e9d4914SAndroid Build Coastguard Worker 1716*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{const char *&@var{value}}) const 1717*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{const char *&@var{value}}) const 1718*2e9d4914SAndroid Build Coastguard Worker 1719*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{std::string &@var{value}}) const 1720*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{std::string &@var{value}}) const 1721*2e9d4914SAndroid Build Coastguard Worker 1722*2e9d4914SAndroid Build Coastguard WorkerThese are convenience methods for looking up the value of a setting 1723*2e9d4914SAndroid Build Coastguard Workerwith the given @var{path}. If the setting is found and is of an 1724*2e9d4914SAndroid Build Coastguard Workerappropriate type, the value is stored in @var{value} and the method 1725*2e9d4914SAndroid Build Coastguard Workerreturns @code{true}. Otherwise, @var{value} is left unmodified and the 1726*2e9d4914SAndroid Build Coastguard Workermethod returns @code{false}. These methods do not throw exceptions. 1727*2e9d4914SAndroid Build Coastguard Worker 1728*2e9d4914SAndroid Build Coastguard WorkerStorage for @w{@i{const char *}} values is managed by the library and 1729*2e9d4914SAndroid Build Coastguard Workerreleased automatically when the setting is destroyed or when its value 1730*2e9d4914SAndroid Build Coastguard Workeris changed; the string must not be freed by the caller. For safety and 1731*2e9d4914SAndroid Build Coastguard Workerconvenience, always assigning string values to a @code{std::string} is 1732*2e9d4914SAndroid Build Coastguard Workersuggested. 1733*2e9d4914SAndroid Build Coastguard Worker 1734*2e9d4914SAndroid Build Coastguard WorkerSince these methods have boolean return values and do not throw 1735*2e9d4914SAndroid Build Coastguard Workerexceptions, they can be used within boolean logic expressions. The following 1736*2e9d4914SAndroid Build Coastguard Workerexample presents a concise way to look up three values at once and 1737*2e9d4914SAndroid Build Coastguard Workerperform error handling if any of them are not found or are of the 1738*2e9d4914SAndroid Build Coastguard Workerwrong type: 1739*2e9d4914SAndroid Build Coastguard Worker 1740*2e9d4914SAndroid Build Coastguard Worker@sp 1 1741*2e9d4914SAndroid Build Coastguard Worker@cartouche 1742*2e9d4914SAndroid Build Coastguard Worker@smallexample 1743*2e9d4914SAndroid Build Coastguard Workerint var1; 1744*2e9d4914SAndroid Build Coastguard Workerdouble var2; 1745*2e9d4914SAndroid Build Coastguard Workerconst char *var3; 1746*2e9d4914SAndroid Build Coastguard Worker 1747*2e9d4914SAndroid Build Coastguard Workerif(config.lookupValue("values.var1", var1) 1748*2e9d4914SAndroid Build Coastguard Worker && config.lookupValue("values.var2", var2) 1749*2e9d4914SAndroid Build Coastguard Worker && config.lookupValue("values.var3", var3)) 1750*2e9d4914SAndroid Build Coastguard Worker@{ 1751*2e9d4914SAndroid Build Coastguard Worker // use var1, var2, var3 1752*2e9d4914SAndroid Build Coastguard Worker@} 1753*2e9d4914SAndroid Build Coastguard Workerelse 1754*2e9d4914SAndroid Build Coastguard Worker@{ 1755*2e9d4914SAndroid Build Coastguard Worker // error handling here 1756*2e9d4914SAndroid Build Coastguard Worker@} 1757*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1758*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1759*2e9d4914SAndroid Build Coastguard Worker 1760*2e9d4914SAndroid Build Coastguard WorkerThis approach also takes advantage of the short-circuit evaluation rules 1761*2e9d4914SAndroid Build Coastguard Workerof C++, e.g., if the first lookup fails (returning @code{false}), the 1762*2e9d4914SAndroid Build Coastguard Workerremaining lookups are skipped entirely. 1763*2e9d4914SAndroid Build Coastguard Worker 1764*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1765*2e9d4914SAndroid Build Coastguard Worker 1766*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {} {operator bool ()} const 1767*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator int ()} const 1768*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator unsigned int ()} const 1769*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator long ()} const 1770*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator unsigned long ()} const 1771*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator long long ()} const 1772*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator unsigned long long ()} const 1773*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator float ()} const 1774*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator double ()} const 1775*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator const char * ()} const 1776*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {} {operator std::string ()} const 1777*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {const char *} c_str () const 1778*2e9d4914SAndroid Build Coastguard Worker 1779*2e9d4914SAndroid Build Coastguard WorkerThese cast operators allow a @code{Setting} object to be assigned to a 1780*2e9d4914SAndroid Build Coastguard Workervariable of type @i{bool} if it is of type @code{TypeBoolean}; 1781*2e9d4914SAndroid Build Coastguard Worker@i{int}, @i{unsigned int}; @code{long long} or @code{unsigned long long} if 1782*2e9d4914SAndroid Build Coastguard Workerit is of type @code{TypeInt64}, @i{float} or @i{double} if it is of type 1783*2e9d4914SAndroid Build Coastguard Worker@code{TypeFloat}; or @w{@i{const char *}} or @i{std::string} if it is 1784*2e9d4914SAndroid Build Coastguard Workerof type @code{TypeString}. 1785*2e9d4914SAndroid Build Coastguard Worker 1786*2e9d4914SAndroid Build Coastguard WorkerValues of type @code{TypeInt} or @code{TypeInt64} may be assigned to 1787*2e9d4914SAndroid Build Coastguard Workervariables of type @i{long}, or @i{unsigned long}, depending on the 1788*2e9d4914SAndroid Build Coastguard Workersizes of those types on the host system. 1789*2e9d4914SAndroid Build Coastguard Worker 1790*2e9d4914SAndroid Build Coastguard WorkerStorage for @w{@i{const char *}} return values is managed by the 1791*2e9d4914SAndroid Build Coastguard Workerlibrary and released automatically when the setting is destroyed or 1792*2e9d4914SAndroid Build Coastguard Workerwhen its value is changed; the string must not be freed by the 1793*2e9d4914SAndroid Build Coastguard Workercaller. For safety and convenience, always assigning string return 1794*2e9d4914SAndroid Build Coastguard Workervalues to a @code{std::string} is suggested. 1795*2e9d4914SAndroid Build Coastguard Worker 1796*2e9d4914SAndroid Build Coastguard WorkerThe following examples demonstrate this usage: 1797*2e9d4914SAndroid Build Coastguard Worker 1798*2e9d4914SAndroid Build Coastguard Worker@cartouche 1799*2e9d4914SAndroid Build Coastguard Worker@smallexample 1800*2e9d4914SAndroid Build Coastguard Workerlong width = config.lookup("application.window.size.w"); 1801*2e9d4914SAndroid Build Coastguard Worker 1802*2e9d4914SAndroid Build Coastguard Workerbool splashScreen = config.lookup("application.splash_screen"); 1803*2e9d4914SAndroid Build Coastguard Worker 1804*2e9d4914SAndroid Build Coastguard Workerstd::string title = config.lookup("application.window.title"); 1805*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1806*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1807*2e9d4914SAndroid Build Coastguard Worker 1808*2e9d4914SAndroid Build Coastguard WorkerNote that certain conversions can lead to loss of precision or 1809*2e9d4914SAndroid Build Coastguard Workerclipping of values, e.g., assigning a negative value to an @i{unsigned 1810*2e9d4914SAndroid Build Coastguard Workerint} (in which case the value will be treated as 0), or a 1811*2e9d4914SAndroid Build Coastguard Workerdouble-precision value to a @i{float}. The library does not treat 1812*2e9d4914SAndroid Build Coastguard Workerthese lossy conversions as errors. 1813*2e9d4914SAndroid Build Coastguard Worker 1814*2e9d4914SAndroid Build Coastguard WorkerPerhaps surprisingly, the following code in particular will cause a 1815*2e9d4914SAndroid Build Coastguard Workercompiler error: 1816*2e9d4914SAndroid Build Coastguard Worker 1817*2e9d4914SAndroid Build Coastguard Worker@cartouche 1818*2e9d4914SAndroid Build Coastguard Worker@smallexample 1819*2e9d4914SAndroid Build Coastguard Workerstd::string title; 1820*2e9d4914SAndroid Build Coastguard Worker. 1821*2e9d4914SAndroid Build Coastguard Worker. 1822*2e9d4914SAndroid Build Coastguard Worker. 1823*2e9d4914SAndroid Build Coastguard Workertitle = config.lookup("application.window.title"); 1824*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1825*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1826*2e9d4914SAndroid Build Coastguard Worker 1827*2e9d4914SAndroid Build Coastguard WorkerThis is because the assignment operator of @code{std::string} is being 1828*2e9d4914SAndroid Build Coastguard Workerinvoked with a @code{Setting &} as an argument. The compiler is unable 1829*2e9d4914SAndroid Build Coastguard Workerto make an implicit conversion because both the @code{const char *} 1830*2e9d4914SAndroid Build Coastguard Workerand the @code{std::string} cast operators of @code{Setting} are 1831*2e9d4914SAndroid Build Coastguard Workerequally appropriate. This is not a bug in @i{libconfig}; providing 1832*2e9d4914SAndroid Build Coastguard Workeronly the @code{const char *} cast operator would resolve this 1833*2e9d4914SAndroid Build Coastguard Workerparticular ambiguity, but would cause assignments to 1834*2e9d4914SAndroid Build Coastguard Worker@code{std::string} like the one in the previous example to produce a 1835*2e9d4914SAndroid Build Coastguard Workercompiler error. (To understand why, see section 11.4.1 of @i{The C++ 1836*2e9d4914SAndroid Build Coastguard WorkerProgramming Language}.) 1837*2e9d4914SAndroid Build Coastguard Worker 1838*2e9d4914SAndroid Build Coastguard WorkerThe solution to this problem is to use an explicit conversion that 1839*2e9d4914SAndroid Build Coastguard Workeravoids the construction of an intermediate @code{std::string} object, 1840*2e9d4914SAndroid Build Coastguard Workeras follows: 1841*2e9d4914SAndroid Build Coastguard Worker 1842*2e9d4914SAndroid Build Coastguard Worker@cartouche 1843*2e9d4914SAndroid Build Coastguard Worker@smallexample 1844*2e9d4914SAndroid Build Coastguard Workerstd::string title; 1845*2e9d4914SAndroid Build Coastguard Worker. 1846*2e9d4914SAndroid Build Coastguard Worker. 1847*2e9d4914SAndroid Build Coastguard Worker. 1848*2e9d4914SAndroid Build Coastguard Workertitle = (const char *)config.lookup("application.window.title"); 1849*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1850*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1851*2e9d4914SAndroid Build Coastguard Worker 1852*2e9d4914SAndroid Build Coastguard WorkerOr, alternatively, use the @code{c_str()} method, which has the same effect: 1853*2e9d4914SAndroid Build Coastguard Worker 1854*2e9d4914SAndroid Build Coastguard Worker@cartouche 1855*2e9d4914SAndroid Build Coastguard Worker@smallexample 1856*2e9d4914SAndroid Build Coastguard Workerstd::string title; 1857*2e9d4914SAndroid Build Coastguard Worker. 1858*2e9d4914SAndroid Build Coastguard Worker. 1859*2e9d4914SAndroid Build Coastguard Worker. 1860*2e9d4914SAndroid Build Coastguard Workertitle = config.lookup("application.window.title").c_str(); 1861*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1862*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1863*2e9d4914SAndroid Build Coastguard Worker 1864*2e9d4914SAndroid Build Coastguard WorkerIf the assignment is invalid due to a type mismatch, a 1865*2e9d4914SAndroid Build Coastguard Worker@code{SettingTypeException} is thrown. 1866*2e9d4914SAndroid Build Coastguard Worker 1867*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1868*2e9d4914SAndroid Build Coastguard Worker 1869*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {Setting &} operator= (@w{bool @var{value}}) 1870*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{int @var{value}}) 1871*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{long @var{value}}) 1872*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{const long long &@var{value}}) 1873*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{float @var{value}}) 1874*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{const double &@var{value}}) 1875*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{const char *@var{value}}) 1876*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} operator= (@w{const std::string &@var{value}}) 1877*2e9d4914SAndroid Build Coastguard Worker 1878*2e9d4914SAndroid Build Coastguard WorkerThese assignment operators allow values of type @i{bool}, @i{int}, 1879*2e9d4914SAndroid Build Coastguard Worker@i{long}, @i{long long}, @i{float}, @i{double}, @i{const char *}, and 1880*2e9d4914SAndroid Build Coastguard Worker@i{std::string} to be assigned to a setting. In the case of strings, 1881*2e9d4914SAndroid Build Coastguard Workerthe library makes a copy of the passed string @var{value}, so it may 1882*2e9d4914SAndroid Build Coastguard Workerbe subsequently freed or modified by the caller without affecting the 1883*2e9d4914SAndroid Build Coastguard Workervalue of the setting. 1884*2e9d4914SAndroid Build Coastguard Worker 1885*2e9d4914SAndroid Build Coastguard WorkerThe following example code looks up a (presumably) integer setting 1886*2e9d4914SAndroid Build Coastguard Workerand changes its value: 1887*2e9d4914SAndroid Build Coastguard Worker 1888*2e9d4914SAndroid Build Coastguard Worker@cartouche 1889*2e9d4914SAndroid Build Coastguard Worker@smallexample 1890*2e9d4914SAndroid Build Coastguard WorkerSetting &setting = config.lookup("application.window.size.w"); 1891*2e9d4914SAndroid Build Coastguard Workersetting = 1024; 1892*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1893*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1894*2e9d4914SAndroid Build Coastguard Worker 1895*2e9d4914SAndroid Build Coastguard WorkerIf the assignment is invalid due to a type mismatch, a 1896*2e9d4914SAndroid Build Coastguard Worker@code{SettingTypeException} is thrown. 1897*2e9d4914SAndroid Build Coastguard Worker 1898*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1899*2e9d4914SAndroid Build Coastguard Worker 1900*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {Setting &} {operator[]} (@w{int @var{index}}) const 1901*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} {operator[]} (@w{const std::string &@var{name}}) const 1902*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} {operator[]} (@w{const char *@var{name}}) const 1903*2e9d4914SAndroid Build Coastguard Worker 1904*2e9d4914SAndroid Build Coastguard WorkerA @code{Setting} object may be subscripted with an integer index 1905*2e9d4914SAndroid Build Coastguard Worker@var{index} if it is an array or list, or with either a string 1906*2e9d4914SAndroid Build Coastguard Worker@var{name} or an integer index @var{index} if it is a group. For example, 1907*2e9d4914SAndroid Build Coastguard Workerthe following code would produce the string @samp{Last Name} when 1908*2e9d4914SAndroid Build Coastguard Workerapplied to the example configuration in @ref{Configuration Files}. 1909*2e9d4914SAndroid Build Coastguard Worker 1910*2e9d4914SAndroid Build Coastguard Worker@cartouche 1911*2e9d4914SAndroid Build Coastguard Worker@smallexample 1912*2e9d4914SAndroid Build Coastguard WorkerSetting& setting = config.lookup("application.misc"); 1913*2e9d4914SAndroid Build Coastguard Workerconst char *s = setting["columns"][0]; 1914*2e9d4914SAndroid Build Coastguard Worker@end smallexample 1915*2e9d4914SAndroid Build Coastguard Worker@end cartouche 1916*2e9d4914SAndroid Build Coastguard Worker 1917*2e9d4914SAndroid Build Coastguard WorkerIf the setting is not an array, list, or group, a 1918*2e9d4914SAndroid Build Coastguard Worker@code{SettingTypeException} is thrown. If the subscript (@var{index} 1919*2e9d4914SAndroid Build Coastguard Workeror @var{name}) does not refer to a valid element, a 1920*2e9d4914SAndroid Build Coastguard Worker@code{SettingNotFoundException} is thrown. 1921*2e9d4914SAndroid Build Coastguard Worker 1922*2e9d4914SAndroid Build Coastguard WorkerIterating over a group's child settings with an integer index will 1923*2e9d4914SAndroid Build Coastguard Workerreturn the settings in the same order that they appear in the 1924*2e9d4914SAndroid Build Coastguard Workerconfiguration. 1925*2e9d4914SAndroid Build Coastguard Worker 1926*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1927*2e9d4914SAndroid Build Coastguard Worker 1928*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {Setting &} lookup (@w{const char * @var{path}}) const 1929*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} lookup (@w{const std::string &@var{path}}) const 1930*2e9d4914SAndroid Build Coastguard Worker 1931*2e9d4914SAndroid Build Coastguard WorkerThese methods locate a setting by a path @var{path} relative to 1932*2e9d4914SAndroid Build Coastguard Workerthis setting. If requested setting is not found, a 1933*2e9d4914SAndroid Build Coastguard Worker@code{SettingNotFoundException} is thrown. 1934*2e9d4914SAndroid Build Coastguard Worker 1935*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 1936*2e9d4914SAndroid Build Coastguard Worker 1937*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting bool lookupValue (@w{const char *@var{name}}, @w{bool &@var{value}}) const 1938*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{bool &@var{value}}) const 1939*2e9d4914SAndroid Build Coastguard Worker 1940*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{int &@var{value}}) const 1941*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{int &@var{value}}) const 1942*2e9d4914SAndroid Build Coastguard Worker 1943*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{unsigned int &@var{value}}) const 1944*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{unsigned int &@var{value}}) const 1945*2e9d4914SAndroid Build Coastguard Worker 1946*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{long long &@var{value}}) const 1947*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{long long &@var{value}}) const 1948*2e9d4914SAndroid Build Coastguard Worker 1949*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{unsigned long long &@var{value}}) const 1950*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{unsigned long long &@var{value}}) const 1951*2e9d4914SAndroid Build Coastguard Worker 1952*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{float &@var{value}}) const 1953*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{float &@var{value}}) const 1954*2e9d4914SAndroid Build Coastguard Worker 1955*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{double &@var{value}}) const 1956*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{double &@var{value}}) const 1957*2e9d4914SAndroid Build Coastguard Worker 1958*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{const char *&@var{value}}) const 1959*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{const char *&@var{value}}) const 1960*2e9d4914SAndroid Build Coastguard Worker 1961*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{std::string &@var{value}}) const 1962*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{std::string &@var{value}}) const 1963*2e9d4914SAndroid Build Coastguard Worker 1964*2e9d4914SAndroid Build Coastguard WorkerThese are convenience methods for looking up the value of a child setting 1965*2e9d4914SAndroid Build Coastguard Workerwith the given @var{name}. If the setting is found and is of an 1966*2e9d4914SAndroid Build Coastguard Workerappropriate type, the value is stored in @var{value} and the method 1967*2e9d4914SAndroid Build Coastguard Workerreturns @code{true}. Otherwise, @var{value} is left unmodified and the 1968*2e9d4914SAndroid Build Coastguard Workermethod returns @code{false}. These methods do not throw exceptions. 1969*2e9d4914SAndroid Build Coastguard Worker 1970*2e9d4914SAndroid Build Coastguard WorkerStorage for @w{@i{const char *}} values is managed by the library and 1971*2e9d4914SAndroid Build Coastguard Workerreleased automatically when the setting is destroyed or when its value 1972*2e9d4914SAndroid Build Coastguard Workeris changed; the string must not be freed by the caller. For safety and 1973*2e9d4914SAndroid Build Coastguard Workerconvenience, always assigning string values to a @code{std::string} is 1974*2e9d4914SAndroid Build Coastguard Workersuggested. 1975*2e9d4914SAndroid Build Coastguard Worker 1976*2e9d4914SAndroid Build Coastguard WorkerSince these methods have boolean return values and do not throw 1977*2e9d4914SAndroid Build Coastguard Workerexceptions, they can be used within boolean logic expressions. The following 1978*2e9d4914SAndroid Build Coastguard Workerexample presents a concise way to look up three values at once and 1979*2e9d4914SAndroid Build Coastguard Workerperform error handling if any of them are not found or are of the 1980*2e9d4914SAndroid Build Coastguard Workerwrong type: 1981*2e9d4914SAndroid Build Coastguard Worker 1982*2e9d4914SAndroid Build Coastguard Worker@sp 1 1983*2e9d4914SAndroid Build Coastguard Worker@cartouche 1984*2e9d4914SAndroid Build Coastguard Worker@smallexample 1985*2e9d4914SAndroid Build Coastguard Workerint var1; 1986*2e9d4914SAndroid Build Coastguard Workerdouble var2; 1987*2e9d4914SAndroid Build Coastguard Workerconst char *var3; 1988*2e9d4914SAndroid Build Coastguard Worker 1989*2e9d4914SAndroid Build Coastguard Workerif(setting.lookupValue("var1", var1) 1990*2e9d4914SAndroid Build Coastguard Worker && setting.lookupValue("var2", var2) 1991*2e9d4914SAndroid Build Coastguard Worker && setting.lookupValue("var3", var3)) 1992*2e9d4914SAndroid Build Coastguard Worker@{ 1993*2e9d4914SAndroid Build Coastguard Worker // use var1, var2, var3 1994*2e9d4914SAndroid Build Coastguard Worker@} 1995*2e9d4914SAndroid Build Coastguard Workerelse 1996*2e9d4914SAndroid Build Coastguard Worker@{ 1997*2e9d4914SAndroid Build Coastguard Worker // error handling here 1998*2e9d4914SAndroid Build Coastguard Worker@} 1999*2e9d4914SAndroid Build Coastguard Worker@end smallexample 2000*2e9d4914SAndroid Build Coastguard Worker@end cartouche 2001*2e9d4914SAndroid Build Coastguard Worker 2002*2e9d4914SAndroid Build Coastguard WorkerThis approach also takes advantage of the short-circuit evaluation 2003*2e9d4914SAndroid Build Coastguard Workerrules of C++, e.g., if the first lookup fails (returning @code{false}), the 2004*2e9d4914SAndroid Build Coastguard Workerremaining lookups are skipped entirely. 2005*2e9d4914SAndroid Build Coastguard Worker 2006*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2007*2e9d4914SAndroid Build Coastguard Worker 2008*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {Setting &} add (@w{const std::string &@var{name}}, @w{Setting::Type @var{type}}) 2009*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting {Setting &} add (@w{const char *@var{name}}, @w{Setting::Type @var{type}}) 2010*2e9d4914SAndroid Build Coastguard Worker 2011*2e9d4914SAndroid Build Coastguard WorkerThese methods add a new child setting with the given @var{name} and 2012*2e9d4914SAndroid Build Coastguard Worker@var{type} to the setting, which must be a group. They return a 2013*2e9d4914SAndroid Build Coastguard Workerreference to the new setting. If the setting already has a child 2014*2e9d4914SAndroid Build Coastguard Workersetting with the given name, or if the name is invalid, a 2015*2e9d4914SAndroid Build Coastguard Worker@code{SettingNameException} is thrown. If the setting is not a group, 2016*2e9d4914SAndroid Build Coastguard Workera @code{SettingTypeException} is thrown. 2017*2e9d4914SAndroid Build Coastguard Worker 2018*2e9d4914SAndroid Build Coastguard WorkerOnce a setting has been created, neither its name nor type can be 2019*2e9d4914SAndroid Build Coastguard Workerchanged. 2020*2e9d4914SAndroid Build Coastguard Worker 2021*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2022*2e9d4914SAndroid Build Coastguard Worker 2023*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {Setting &} add (@w{Setting::Type @var{type}}) 2024*2e9d4914SAndroid Build Coastguard Worker 2025*2e9d4914SAndroid Build Coastguard WorkerThis method adds a new element to the setting, which must be of type 2026*2e9d4914SAndroid Build Coastguard Worker@code{TypeArray} or @code{TypeList}. If the setting is an array which 2027*2e9d4914SAndroid Build Coastguard Workercurrently has zero elements, the @var{type} parameter (which must be 2028*2e9d4914SAndroid Build Coastguard Worker@code{TypeInt}, @code{TypeInt64}, @code{TypeFloat}, @code{TypeBool}, 2029*2e9d4914SAndroid Build Coastguard Workeror @code{TypeString}) determines the type for the array; otherwise it 2030*2e9d4914SAndroid Build Coastguard Workermust match the type of the existing elements in the array. 2031*2e9d4914SAndroid Build Coastguard Worker 2032*2e9d4914SAndroid Build Coastguard WorkerThe method returns the new setting on success. If @var{type} is a 2033*2e9d4914SAndroid Build Coastguard Workerscalar type, the new setting will have a default value of 0, 0.0, 2034*2e9d4914SAndroid Build Coastguard Worker@code{false}, or @code{NULL}, as appropriate. 2035*2e9d4914SAndroid Build Coastguard Worker 2036*2e9d4914SAndroid Build Coastguard WorkerThe method throws a @code{SettingTypeException} if the setting is not 2037*2e9d4914SAndroid Build Coastguard Workeran array or list, or if @var{type} is invalid. 2038*2e9d4914SAndroid Build Coastguard Worker 2039*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2040*2e9d4914SAndroid Build Coastguard Worker 2041*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting void remove (@w{const std::string &@var{name}}) 2042*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting void remove (@w{const char *@var{name}}) 2043*2e9d4914SAndroid Build Coastguard Worker 2044*2e9d4914SAndroid Build Coastguard WorkerThese methods remove the child setting with the given @var{name} from 2045*2e9d4914SAndroid Build Coastguard Workerthe setting, which must be a group. Any child settings of the removed 2046*2e9d4914SAndroid Build Coastguard Workersetting are recursively destroyed as well. 2047*2e9d4914SAndroid Build Coastguard Worker 2048*2e9d4914SAndroid Build Coastguard WorkerIf the setting is not a group, a @code{SettingTypeException} is 2049*2e9d4914SAndroid Build Coastguard Workerthrown. If the setting does not have a child setting with the given 2050*2e9d4914SAndroid Build Coastguard Workername, a @code{SettingNotFoundException} is thrown. 2051*2e9d4914SAndroid Build Coastguard Worker 2052*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2053*2e9d4914SAndroid Build Coastguard Worker 2054*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting void remove (@w{unsigned int @var{index}}) 2055*2e9d4914SAndroid Build Coastguard Worker 2056*2e9d4914SAndroid Build Coastguard WorkerThis method removes the child setting at the given index @var{index} from 2057*2e9d4914SAndroid Build Coastguard Workerthe setting, which must be a group, list, or array. Any child settings 2058*2e9d4914SAndroid Build Coastguard Workerof the removed setting are recursively destroyed as well. 2059*2e9d4914SAndroid Build Coastguard Worker 2060*2e9d4914SAndroid Build Coastguard WorkerIf the setting is not a group, list, or array, a 2061*2e9d4914SAndroid Build Coastguard Worker@code{SettingTypeException} is thrown. If @var{index} is out of range, 2062*2e9d4914SAndroid Build Coastguard Workera @code{SettingNotFoundException} is thrown. 2063*2e9d4914SAndroid Build Coastguard Worker 2064*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2065*2e9d4914SAndroid Build Coastguard Worker 2066*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {const char *} getName () const 2067*2e9d4914SAndroid Build Coastguard Worker 2068*2e9d4914SAndroid Build Coastguard WorkerThis method returns the name of the setting, or @code{NULL} if the 2069*2e9d4914SAndroid Build Coastguard Workersetting has no name. Storage for the returned string is managed by the 2070*2e9d4914SAndroid Build Coastguard Workerlibrary and released automatically when the setting is destroyed; the 2071*2e9d4914SAndroid Build Coastguard Workerstring must not be freed by the caller. For safety and convenience, 2072*2e9d4914SAndroid Build Coastguard Workerconsider assigning the return value to a @code{std::string}. 2073*2e9d4914SAndroid Build Coastguard Worker 2074*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2075*2e9d4914SAndroid Build Coastguard Worker 2076*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {std::string} getPath () const 2077*2e9d4914SAndroid Build Coastguard Worker 2078*2e9d4914SAndroid Build Coastguard WorkerThis method returns the complete dot-separated path to the 2079*2e9d4914SAndroid Build Coastguard Workersetting. Settings which do not have a name (list and array elements) 2080*2e9d4914SAndroid Build Coastguard Workerare represented by their index in square brackets. 2081*2e9d4914SAndroid Build Coastguard Worker 2082*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2083*2e9d4914SAndroid Build Coastguard Worker 2084*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {Setting &} getParent () const 2085*2e9d4914SAndroid Build Coastguard Worker 2086*2e9d4914SAndroid Build Coastguard WorkerThis method returns the parent setting of the setting. If the setting 2087*2e9d4914SAndroid Build Coastguard Workeris the root setting, a @code{SettingNotFoundException} is thrown. 2088*2e9d4914SAndroid Build Coastguard Worker 2089*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2090*2e9d4914SAndroid Build Coastguard Worker 2091*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting bool isRoot () const 2092*2e9d4914SAndroid Build Coastguard Worker 2093*2e9d4914SAndroid Build Coastguard WorkerThis method returns @code{true} if the setting is the root setting, and 2094*2e9d4914SAndroid Build Coastguard Worker@code{false} otherwise. 2095*2e9d4914SAndroid Build Coastguard Worker 2096*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2097*2e9d4914SAndroid Build Coastguard Worker 2098*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting int getIndex () const 2099*2e9d4914SAndroid Build Coastguard Worker 2100*2e9d4914SAndroid Build Coastguard WorkerThis method returns the index of the setting within its parent 2101*2e9d4914SAndroid Build Coastguard Workersetting. When applied to the root setting, this method returns -1. 2102*2e9d4914SAndroid Build Coastguard Worker 2103*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2104*2e9d4914SAndroid Build Coastguard Worker 2105*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting Setting::Type getType () const 2106*2e9d4914SAndroid Build Coastguard Worker 2107*2e9d4914SAndroid Build Coastguard Worker@tindex Setting::Type 2108*2e9d4914SAndroid Build Coastguard WorkerThis method returns the type of the setting. The 2109*2e9d4914SAndroid Build Coastguard Worker@code{Setting::Type} enumeration consists of the following constants: 2110*2e9d4914SAndroid Build Coastguard Worker@code{TypeInt}, @code{TypeInt64}, @code{TypeFloat}, @code{TypeString}, 2111*2e9d4914SAndroid Build Coastguard Worker@code{TypeBoolean}, @code{TypeArray}, @code{TypeList}, and 2112*2e9d4914SAndroid Build Coastguard Worker@code{TypeGroup}. 2113*2e9d4914SAndroid Build Coastguard Worker 2114*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2115*2e9d4914SAndroid Build Coastguard Worker 2116*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting Setting::Format getFormat () const 2117*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting void setFormat (@w{Setting::Format @var{format}}) 2118*2e9d4914SAndroid Build Coastguard Worker 2119*2e9d4914SAndroid Build Coastguard WorkerThese methods get and set the external format for the setting. 2120*2e9d4914SAndroid Build Coastguard Worker 2121*2e9d4914SAndroid Build Coastguard Worker@tindex Setting::Format 2122*2e9d4914SAndroid Build Coastguard WorkerThe @var{Setting::Format} enumeration consists of the following 2123*2e9d4914SAndroid Build Coastguard Workerconstants: @code{FormatDefault} and @code{FormatHex}. All settings 2124*2e9d4914SAndroid Build Coastguard Workersupport the @code{FormatDefault} format. The @code{FormatHex} format 2125*2e9d4914SAndroid Build Coastguard Workerspecifies hexadecimal formatting for integer values, and hence only 2126*2e9d4914SAndroid Build Coastguard Workerapplies to settings of type @code{TypeInt} and @code{TypeInt64}. If 2127*2e9d4914SAndroid Build Coastguard Worker@var{format} is invalid for the given setting, it is ignored. 2128*2e9d4914SAndroid Build Coastguard Worker 2129*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2130*2e9d4914SAndroid Build Coastguard Worker 2131*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting bool exists (@w{const std::string &@var{name}}) const 2132*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool exists (@w{const char *@var{name}}) const 2133*2e9d4914SAndroid Build Coastguard Worker 2134*2e9d4914SAndroid Build Coastguard WorkerThese methods test if the setting has a child setting with the given 2135*2e9d4914SAndroid Build Coastguard Worker@var{name}. They return @code{true} if the setting exists, and 2136*2e9d4914SAndroid Build Coastguard Worker@code{false} otherwise. These methods do not throw exceptions. 2137*2e9d4914SAndroid Build Coastguard Worker 2138*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2139*2e9d4914SAndroid Build Coastguard Worker@page 2140*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting iterator begin () 2141*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting iterator end () 2142*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting const_iterator begin () 2143*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting const_iterator end () 2144*2e9d4914SAndroid Build Coastguard Worker 2145*2e9d4914SAndroid Build Coastguard WorkerThese methods return STL-style iterators that can be used to enumerate 2146*2e9d4914SAndroid Build Coastguard Workerthe child settings of a given setting. If the setting is not an array, list, 2147*2e9d4914SAndroid Build Coastguard Workeror group, they throw a @code{SettingTypeException}. 2148*2e9d4914SAndroid Build Coastguard Worker 2149*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2150*2e9d4914SAndroid Build Coastguard Worker 2151*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting int getLength () const 2152*2e9d4914SAndroid Build Coastguard Worker 2153*2e9d4914SAndroid Build Coastguard WorkerThis method returns the number of settings in a group, or the number of 2154*2e9d4914SAndroid Build Coastguard Workerelements in a list or array. For other types of settings, it returns 2155*2e9d4914SAndroid Build Coastguard Worker0. 2156*2e9d4914SAndroid Build Coastguard Worker 2157*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2158*2e9d4914SAndroid Build Coastguard Worker 2159*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting bool isGroup () const 2160*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool isArray () const 2161*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool isList () const 2162*2e9d4914SAndroid Build Coastguard Worker 2163*2e9d4914SAndroid Build Coastguard WorkerThese convenience methods test if a setting is of a given type. 2164*2e9d4914SAndroid Build Coastguard Worker 2165*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2166*2e9d4914SAndroid Build Coastguard Worker 2167*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting bool isAggregate () const 2168*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool isScalar () const 2169*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool isNumber () const 2170*2e9d4914SAndroid Build Coastguard Worker@deftypemethodx Setting bool isString () const 2171*2e9d4914SAndroid Build Coastguard Worker 2172*2e9d4914SAndroid Build Coastguard WorkerThese convenience methods test if a setting is of an aggregate type (a 2173*2e9d4914SAndroid Build Coastguard Workergroup, array, or list), of a scalar type (integer, 64-bit integer, 2174*2e9d4914SAndroid Build Coastguard Workerfloating point, boolean, or string), of a number (integer, 64-bit 2175*2e9d4914SAndroid Build Coastguard Workerinteger, or floating point), and of a string respectively. 2176*2e9d4914SAndroid Build Coastguard Worker 2177*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2178*2e9d4914SAndroid Build Coastguard Worker 2179*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {const char *} getSourceFile () const 2180*2e9d4914SAndroid Build Coastguard Worker 2181*2e9d4914SAndroid Build Coastguard WorkerThis method returns the name of the file from which the setting was 2182*2e9d4914SAndroid Build Coastguard Workerread, or NULL if the setting was not read from a file. This 2183*2e9d4914SAndroid Build Coastguard Workerinformation is useful for reporting application-level errors. Storage 2184*2e9d4914SAndroid Build Coastguard Workerfor the returned string is managed by the library and released 2185*2e9d4914SAndroid Build Coastguard Workerautomatically when the configuration is destroyed; the string must 2186*2e9d4914SAndroid Build Coastguard Workernot be freed by the caller. 2187*2e9d4914SAndroid Build Coastguard Worker 2188*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2189*2e9d4914SAndroid Build Coastguard Worker 2190*2e9d4914SAndroid Build Coastguard Worker@deftypemethod Setting {unsigned int} getSourceLine () const 2191*2e9d4914SAndroid Build Coastguard Worker 2192*2e9d4914SAndroid Build Coastguard WorkerThis method returns the line number of the configuration file or 2193*2e9d4914SAndroid Build Coastguard Workerstream at which the setting @var{setting} was read, or 0 if no line 2194*2e9d4914SAndroid Build Coastguard Workernumber is available. This information is useful for reporting 2195*2e9d4914SAndroid Build Coastguard Workerapplication-level errors. 2196*2e9d4914SAndroid Build Coastguard Worker 2197*2e9d4914SAndroid Build Coastguard Worker@end deftypemethod 2198*2e9d4914SAndroid Build Coastguard Worker 2199*2e9d4914SAndroid Build Coastguard Worker@node Example Programs, Other Bindings and Implementations, The C++ API, Top 2200*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2201*2e9d4914SAndroid Build Coastguard Worker@chapter Example Programs 2202*2e9d4914SAndroid Build Coastguard Worker 2203*2e9d4914SAndroid Build Coastguard WorkerPractical example programs that illustrate how to use @i{libconfig} 2204*2e9d4914SAndroid Build Coastguard Workerfrom both C and C++ are included in the @file{examples} subdirectory 2205*2e9d4914SAndroid Build Coastguard Workerof the distribution. These examples include: 2206*2e9d4914SAndroid Build Coastguard Worker 2207*2e9d4914SAndroid Build Coastguard Worker@table @file 2208*2e9d4914SAndroid Build Coastguard Worker 2209*2e9d4914SAndroid Build Coastguard Worker@item examples/c/example1.c 2210*2e9d4914SAndroid Build Coastguard WorkerAn example C program that reads a configuration from an existing file 2211*2e9d4914SAndroid Build Coastguard Worker@file{example.cfg} (also located in @file{examples/c}) and displays 2212*2e9d4914SAndroid Build Coastguard Workersome of its contents. 2213*2e9d4914SAndroid Build Coastguard Worker 2214*2e9d4914SAndroid Build Coastguard Worker@item examples/c++/example1.cpp 2215*2e9d4914SAndroid Build Coastguard WorkerThe C++ equivalent of @file{example1.c}. 2216*2e9d4914SAndroid Build Coastguard Worker 2217*2e9d4914SAndroid Build Coastguard Worker@item examples/c/example2.c 2218*2e9d4914SAndroid Build Coastguard WorkerAn example C program that reads a configuration from an existing file 2219*2e9d4914SAndroid Build Coastguard Worker@file{example.cfg} (also located in @file{examples/c}), adds new 2220*2e9d4914SAndroid Build Coastguard Workersettings to the configuration, and writes the updated configuration to 2221*2e9d4914SAndroid Build Coastguard Workeranother file. 2222*2e9d4914SAndroid Build Coastguard Worker 2223*2e9d4914SAndroid Build Coastguard Worker@item examples/c++/example2.cpp 2224*2e9d4914SAndroid Build Coastguard WorkerThe C++ equivalent of @file{example2.c} 2225*2e9d4914SAndroid Build Coastguard Worker 2226*2e9d4914SAndroid Build Coastguard Worker@item examples/c/example3.c 2227*2e9d4914SAndroid Build Coastguard WorkerAn example C program that constructs a new configuration in memory and writes it to a file. 2228*2e9d4914SAndroid Build Coastguard Worker 2229*2e9d4914SAndroid Build Coastguard Worker@item examples/c++/example3.cpp 2230*2e9d4914SAndroid Build Coastguard WorkerThe C++ equivalent of @file{example3.c} 2231*2e9d4914SAndroid Build Coastguard Worker 2232*2e9d4914SAndroid Build Coastguard Worker@item examples/c/example4.c 2233*2e9d4914SAndroid Build Coastguard WorkerAn example C program that uses a custom include function for processing 2234*2e9d4914SAndroid Build Coastguard Workerwildcard includes. Note that this code will not compile on Windows. 2235*2e9d4914SAndroid Build Coastguard Worker 2236*2e9d4914SAndroid Build Coastguard Worker@end table 2237*2e9d4914SAndroid Build Coastguard Worker 2238*2e9d4914SAndroid Build Coastguard Worker@node Other Bindings and Implementations, License, Example Programs, Top 2239*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2240*2e9d4914SAndroid Build Coastguard Worker@chapter Other Bindings and Implementations 2241*2e9d4914SAndroid Build Coastguard Worker@menu 2242*2e9d4914SAndroid Build Coastguard Worker* Bourne Shell:: 2243*2e9d4914SAndroid Build Coastguard Worker* D:: 2244*2e9d4914SAndroid Build Coastguard Worker* Haskell:: 2245*2e9d4914SAndroid Build Coastguard Worker* Java:: 2246*2e9d4914SAndroid Build Coastguard Worker* Lisp:: 2247*2e9d4914SAndroid Build Coastguard Worker* Perl:: 2248*2e9d4914SAndroid Build Coastguard Worker* Python:: 2249*2e9d4914SAndroid Build Coastguard Worker* Ruby:: 2250*2e9d4914SAndroid Build Coastguard Worker@end menu 2251*2e9d4914SAndroid Build Coastguard Worker 2252*2e9d4914SAndroid Build Coastguard WorkerVarious open-source libraries have been written that provide access to 2253*2e9d4914SAndroid Build Coastguard Worker@i{libconfig}-style configuration files from other programming languages. Some 2254*2e9d4914SAndroid Build Coastguard Workerof these libraries are wrappers which add new language bindings for 2255*2e9d4914SAndroid Build Coastguard Worker@i{libconfig} while others are syntax-compatible reimplementations in other 2256*2e9d4914SAndroid Build Coastguard Workerlanguages. 2257*2e9d4914SAndroid Build Coastguard Worker 2258*2e9d4914SAndroid Build Coastguard WorkerHere is a list of some of these implementations. 2259*2e9d4914SAndroid Build Coastguard Worker 2260*2e9d4914SAndroid Build Coastguard Worker@node Bourne Shell, D, , Other Bindings and Implementations 2261*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2262*2e9d4914SAndroid Build Coastguard Worker@section Bourne Shell 2263*2e9d4914SAndroid Build Coastguard Worker 2264*2e9d4914SAndroid Build Coastguard Worker@L{}ukasz A. Grabowski's @i{ls-config} provides a means to read and write 2265*2e9d4914SAndroid Build Coastguard Workervalues in @i{libconfig} configuration files from Bourne shell scripts. The 2266*2e9d4914SAndroid Build Coastguard Workerimplementation is included in the @i{libconfig} git repository at 2267*2e9d4914SAndroid Build Coastguard Worker@url{https://github.com/hyperrealm/libconfig}, in the @file{contrib/ls-config} 2268*2e9d4914SAndroid Build Coastguard Workersubdirectory. 2269*2e9d4914SAndroid Build Coastguard Worker 2270*2e9d4914SAndroid Build Coastguard Worker@node D, Haskell, Bourne Shell, Other Bindings and Implementations 2271*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2272*2e9d4914SAndroid Build Coastguard Worker@section D 2273*2e9d4914SAndroid Build Coastguard Worker 2274*2e9d4914SAndroid Build Coastguard WorkerRemi Thebault's @i{libconfig-d} is a port of @i{libconfig} to the D programming 2275*2e9d4914SAndroid Build Coastguard Workerlanguage. It may be found at @url{https://code.dlang.org/packages/libconfig-d}. 2276*2e9d4914SAndroid Build Coastguard Worker 2277*2e9d4914SAndroid Build Coastguard Worker@node Haskell, Java, D, Other Bindings and Implementations 2278*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2279*2e9d4914SAndroid Build Coastguard Worker@section Haskell 2280*2e9d4914SAndroid Build Coastguard Worker 2281*2e9d4914SAndroid Build Coastguard WorkerMatthew Peddie's @i{libconfig} provides Haskell bindings to 2282*2e9d4914SAndroid Build Coastguard Worker@i{libconfig}. It may be found at 2283*2e9d4914SAndroid Build Coastguard Worker@url{https://hackage.haskell.org/package/libconfig-0.3.0.0}. 2284*2e9d4914SAndroid Build Coastguard Worker 2285*2e9d4914SAndroid Build Coastguard Worker@node Java, Lisp, Haskell, Other Bindings and Implementations 2286*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2287*2e9d4914SAndroid Build Coastguard Worker@section Java 2288*2e9d4914SAndroid Build Coastguard Worker 2289*2e9d4914SAndroid Build Coastguard WorkerAndrey V. Pleskach has a pure-Java implementation of @i{libconfig}. It may be 2290*2e9d4914SAndroid Build Coastguard Workerfound on github at @url{https://github.com/willyborankin/libconfig}. 2291*2e9d4914SAndroid Build Coastguard Worker 2292*2e9d4914SAndroid Build Coastguard Worker@node Lisp, Perl, Java, Other Bindings and Implementations 2293*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2294*2e9d4914SAndroid Build Coastguard Worker@section Lisp 2295*2e9d4914SAndroid Build Coastguard Worker 2296*2e9d4914SAndroid Build Coastguard WorkerOleg Shalaev's @i{cl-libconfig} provides Common Lisp bindings for @i{libconfig}. 2297*2e9d4914SAndroid Build Coastguard WorkerIt may be found on github at @url{https://github.com/chalaev/cl-libconfig}. 2298*2e9d4914SAndroid Build Coastguard Worker 2299*2e9d4914SAndroid Build Coastguard Worker@node Perl, Python, Lisp, Other Bindings and Implementations 2300*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2301*2e9d4914SAndroid Build Coastguard Worker@section Perl 2302*2e9d4914SAndroid Build Coastguard Worker 2303*2e9d4914SAndroid Build Coastguard WorkerThe @i{Conf::Libconfig} module provides Perl bindings for @i{libconfig}. It may 2304*2e9d4914SAndroid Build Coastguard Workerbe found on CPAN at @url{http://search.cpan.org/~cnangel/Conf-Libconfig-0.05/} 2305*2e9d4914SAndroid Build Coastguard Workeror on github at @url{https://github.com/cnangel/Conf-Libconfig}. 2306*2e9d4914SAndroid Build Coastguard Worker 2307*2e9d4914SAndroid Build Coastguard Worker@node Python, Ruby, Perl, Other Bindings and Implementations 2308*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2309*2e9d4914SAndroid Build Coastguard Worker@section Python 2310*2e9d4914SAndroid Build Coastguard Worker 2311*2e9d4914SAndroid Build Coastguard WorkerHeiner Tholen's @i{pylibconfig2} is a Python library that is syntax-compatible 2312*2e9d4914SAndroid Build Coastguard Workerwith @i{libconfig}. It may be found at 2313*2e9d4914SAndroid Build Coastguard Worker@url{https://pypi.python.org/pypi/pylibconfig2/0.1.2}. 2314*2e9d4914SAndroid Build Coastguard Worker 2315*2e9d4914SAndroid Build Coastguard Worker@sp 1 2316*2e9d4914SAndroid Build Coastguard Worker 2317*2e9d4914SAndroid Build Coastguard WorkerChristian Aichinger's @i{libconf} is another pure-Python implementation with a 2318*2e9d4914SAndroid Build Coastguard Workermore permissive license. It may be found at 2319*2e9d4914SAndroid Build Coastguard Worker@url{https://pypi.python.org/pypi/libconf} or on github at 2320*2e9d4914SAndroid Build Coastguard Worker@url{https://github.com/Grk0/python-libconf}. 2321*2e9d4914SAndroid Build Coastguard Worker 2322*2e9d4914SAndroid Build Coastguard Worker@sp 1 2323*2e9d4914SAndroid Build Coastguard Worker 2324*2e9d4914SAndroid Build Coastguard WorkerThe @i{python-libconfig} wrapper provides Python bindings to @i{libconfig}. It 2325*2e9d4914SAndroid Build Coastguard Workermay be found on github at @url{https://github.com/cnangel/python-libconfig/}. 2326*2e9d4914SAndroid Build Coastguard Worker 2327*2e9d4914SAndroid Build Coastguard Worker@node Ruby, , Python, Other Bindings and Implementations 2328*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2329*2e9d4914SAndroid Build Coastguard Worker@section Ruby 2330*2e9d4914SAndroid Build Coastguard Worker 2331*2e9d4914SAndroid Build Coastguard WorkerChristopher Mark Gore's @i{ruby-libconfig} is a Ruby library that provides Ruby 2332*2e9d4914SAndroid Build Coastguard Workerbindings for @i{libconfig}. It may be found at 2333*2e9d4914SAndroid Build Coastguard Worker@url{https://rubygems.org/gems/libconfig} or on github at 2334*2e9d4914SAndroid Build Coastguard Worker@url{https://github.com/cgore/ruby-libconfig}. 2335*2e9d4914SAndroid Build Coastguard Worker 2336*2e9d4914SAndroid Build Coastguard Worker@sp 1 2337*2e9d4914SAndroid Build Coastguard Worker 2338*2e9d4914SAndroid Build Coastguard WorkerThere is also another Ruby wrapper, @i{libconfig-ruby}, that is included in 2339*2e9d4914SAndroid Build Coastguard Workerthe @i{libconfig} git repository at @url{https://github.com/hyperrealm/libconfig}, 2340*2e9d4914SAndroid Build Coastguard Workerin the @file{contrib/libconfig-ruby} subdirectory. 2341*2e9d4914SAndroid Build Coastguard Worker 2342*2e9d4914SAndroid Build Coastguard Worker@node License, Configuration File Grammar, Other Bindings and Implementations, Top 2343*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2344*2e9d4914SAndroid Build Coastguard Worker@appendix License 2345*2e9d4914SAndroid Build Coastguard Worker 2346*2e9d4914SAndroid Build Coastguard Worker@include LGPL.texi 2347*2e9d4914SAndroid Build Coastguard Worker 2348*2e9d4914SAndroid Build Coastguard Worker@node Configuration File Grammar, Function Index, License, Top 2349*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2350*2e9d4914SAndroid Build Coastguard Worker@appendix Configuration File Grammar 2351*2e9d4914SAndroid Build Coastguard Worker 2352*2e9d4914SAndroid Build Coastguard WorkerBelow is the BNF grammar for configuration files. Comments and include 2353*2e9d4914SAndroid Build Coastguard Workerdirectives are not part of the grammar, so they are not included here. 2354*2e9d4914SAndroid Build Coastguard Worker 2355*2e9d4914SAndroid Build Coastguard Worker@sp 1 2356*2e9d4914SAndroid Build Coastguard Worker@example 2357*2e9d4914SAndroid Build Coastguard Worker<configuration> ::= 2358*2e9d4914SAndroid Build Coastguard Worker <setting-list> 2359*2e9d4914SAndroid Build Coastguard Worker | <empty> 2360*2e9d4914SAndroid Build Coastguard Worker 2361*2e9d4914SAndroid Build Coastguard Worker<setting-list> ::= 2362*2e9d4914SAndroid Build Coastguard Worker <setting> 2363*2e9d4914SAndroid Build Coastguard Worker | <setting-list> <setting> 2364*2e9d4914SAndroid Build Coastguard Worker 2365*2e9d4914SAndroid Build Coastguard Worker<setting> ::= 2366*2e9d4914SAndroid Build Coastguard Worker <name> ( ":" | "=" ) <value> ( ";" | "," | <empty> ) 2367*2e9d4914SAndroid Build Coastguard Worker 2368*2e9d4914SAndroid Build Coastguard Worker<value> ::= 2369*2e9d4914SAndroid Build Coastguard Worker <scalar-value> 2370*2e9d4914SAndroid Build Coastguard Worker | <array> 2371*2e9d4914SAndroid Build Coastguard Worker | <list> 2372*2e9d4914SAndroid Build Coastguard Worker | <group> 2373*2e9d4914SAndroid Build Coastguard Worker 2374*2e9d4914SAndroid Build Coastguard Worker<value-list> ::= 2375*2e9d4914SAndroid Build Coastguard Worker <value> 2376*2e9d4914SAndroid Build Coastguard Worker | <value-list> "," <value> 2377*2e9d4914SAndroid Build Coastguard Worker | <value-list> "," 2378*2e9d4914SAndroid Build Coastguard Worker 2379*2e9d4914SAndroid Build Coastguard Worker<scalar-value> ::= 2380*2e9d4914SAndroid Build Coastguard Worker <boolean> 2381*2e9d4914SAndroid Build Coastguard Worker | <integer> 2382*2e9d4914SAndroid Build Coastguard Worker | <integer64> 2383*2e9d4914SAndroid Build Coastguard Worker | <hex> 2384*2e9d4914SAndroid Build Coastguard Worker | <hex64> 2385*2e9d4914SAndroid Build Coastguard Worker | <float> 2386*2e9d4914SAndroid Build Coastguard Worker | <string> 2387*2e9d4914SAndroid Build Coastguard Worker 2388*2e9d4914SAndroid Build Coastguard Worker<scalar-value-list> ::= 2389*2e9d4914SAndroid Build Coastguard Worker <scalar-value> 2390*2e9d4914SAndroid Build Coastguard Worker | <scalar-value-list> "," <scalar-value> 2391*2e9d4914SAndroid Build Coastguard Worker | <scalar-value-list> "," 2392*2e9d4914SAndroid Build Coastguard Worker 2393*2e9d4914SAndroid Build Coastguard Worker<array> ::= 2394*2e9d4914SAndroid Build Coastguard Worker "[" ( <scalar-value-list> | <empty> ) "]" 2395*2e9d4914SAndroid Build Coastguard Worker 2396*2e9d4914SAndroid Build Coastguard Worker<list> ::= 2397*2e9d4914SAndroid Build Coastguard Worker "(" ( <value-list> | <empty> ) ")" 2398*2e9d4914SAndroid Build Coastguard Worker 2399*2e9d4914SAndroid Build Coastguard Worker<group> ::= 2400*2e9d4914SAndroid Build Coastguard Worker "@{" ( <setting-list> | <empty> ) "@}" 2401*2e9d4914SAndroid Build Coastguard Worker 2402*2e9d4914SAndroid Build Coastguard Worker<empty> ::= 2403*2e9d4914SAndroid Build Coastguard Worker@end example 2404*2e9d4914SAndroid Build Coastguard Worker 2405*2e9d4914SAndroid Build Coastguard Worker@sp 2 2406*2e9d4914SAndroid Build Coastguard WorkerTerminals are defined below as regular expressions: 2407*2e9d4914SAndroid Build Coastguard Worker@sp 1 2408*2e9d4914SAndroid Build Coastguard Worker 2409*2e9d4914SAndroid Build Coastguard Worker@multitable @columnfractions .2 .8 2410*2e9d4914SAndroid Build Coastguard Worker@item @code{<boolean>} @tab 2411*2e9d4914SAndroid Build Coastguard Worker@code{([Tt][Rr][Uu][Ee])|([Ff][Aa][Ll][Ss][Ee])} 2412*2e9d4914SAndroid Build Coastguard Worker@item @code{<string>} @tab 2413*2e9d4914SAndroid Build Coastguard Worker@code{\"([^\"\\]|\\.)*\"} 2414*2e9d4914SAndroid Build Coastguard Worker@item @code{<name>} @tab 2415*2e9d4914SAndroid Build Coastguard Worker@code{[A-Za-z\*][-A-Za-z0-9_\*]*} 2416*2e9d4914SAndroid Build Coastguard Worker@item @code{<integer>} @tab 2417*2e9d4914SAndroid Build Coastguard Worker@code{[-+]?[0-9]+} 2418*2e9d4914SAndroid Build Coastguard Worker@item @code{<integer64>} @tab 2419*2e9d4914SAndroid Build Coastguard Worker@code{[-+]?[0-9]+L(L)?} 2420*2e9d4914SAndroid Build Coastguard Worker@item @code{<hex>} @tab 2421*2e9d4914SAndroid Build Coastguard Worker@code{0[Xx][0-9A-Fa-f]+} 2422*2e9d4914SAndroid Build Coastguard Worker@item @code{<hex64>} @tab 2423*2e9d4914SAndroid Build Coastguard Worker@code{0[Xx][0-9A-Fa-f]+(L(L)?)?} 2424*2e9d4914SAndroid Build Coastguard Worker@item @code{<float>} @tab 2425*2e9d4914SAndroid Build Coastguard Worker@code{([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)} 2426*2e9d4914SAndroid Build Coastguard Worker@end multitable 2427*2e9d4914SAndroid Build Coastguard Worker 2428*2e9d4914SAndroid Build Coastguard Worker@sp 1 2429*2e9d4914SAndroid Build Coastguard Worker 2430*2e9d4914SAndroid Build Coastguard WorkerNote that adjacent strings are automatically concatenated. Non-printable 2431*2e9d4914SAndroid Build Coastguard Workercharacters can be represented within strings using a sequence @samp{\xx}, 2432*2e9d4914SAndroid Build Coastguard Workerrepresenting the ASCII value as two hex digits. 2433*2e9d4914SAndroid Build Coastguard Worker 2434*2e9d4914SAndroid Build Coastguard Worker@node Function Index, Type Index, Configuration File Grammar, Top 2435*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2436*2e9d4914SAndroid Build Coastguard Worker@unnumbered Function Index 2437*2e9d4914SAndroid Build Coastguard Worker 2438*2e9d4914SAndroid Build Coastguard Worker@printindex fn 2439*2e9d4914SAndroid Build Coastguard Worker 2440*2e9d4914SAndroid Build Coastguard Worker@node Type Index, Concept Index, Function Index, Top 2441*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2442*2e9d4914SAndroid Build Coastguard Worker@unnumbered Type Index 2443*2e9d4914SAndroid Build Coastguard Worker 2444*2e9d4914SAndroid Build Coastguard Worker@printindex tp 2445*2e9d4914SAndroid Build Coastguard Worker 2446*2e9d4914SAndroid Build Coastguard Worker@node Concept Index, , Type Index, Top 2447*2e9d4914SAndroid Build Coastguard Worker@comment node-name, next, previous, up 2448*2e9d4914SAndroid Build Coastguard Worker@unnumbered Concept Index 2449*2e9d4914SAndroid Build Coastguard Worker 2450*2e9d4914SAndroid Build Coastguard Worker@printindex cp 2451*2e9d4914SAndroid Build Coastguard Worker 2452*2e9d4914SAndroid Build Coastguard Worker@bye 2453