7 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 * Copyright (C) 2011, MinGW Project
11 * Public declarations of the data structures, values and functions
12 * for specification and control of global program options.
15 * This is free software. Permission is granted to copy, modify and
16 * redistribute this software, under the provisions of the GNU General
17 * Public License, Version 3, (or, at your option, any later version),
18 * as published by the Free Software Foundation; see the file COPYING
19 * for licensing details.
21 * Note, in particular, that this software is provided "as is", in the
22 * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23 * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24 * PARTICULAR PURPOSE. Under no circumstances will the author, or the
25 * MinGW Project, accept liability for any damages, however caused,
26 * arising from the use of this software.
32 { /* Specification of symbolic names (keys) for each of the individual
33 * entries in the options parameter array.
38 /* This final entry specifies the size of the parameter array which
39 * comprises the data content of the options structure; it MUST be the
40 * final item in the enumeration, but is NOT intended to be used as
41 * a key into the data table itself.
48 /* The primary data structure used to accumulate the settings data for
49 * user specified global program options; (fundamentally, this is a type
53 { /* ...which is suitable for storage of...
55 unsigned numeric; /* ...integer numeric, or bit-map data... */
56 const char *string; /* ...and reference pointers for string data) */
58 flags[OPTION_TABLE_SIZE];
61 /* Bit-mapped control tags used by the CLI options parsing code...
63 #define OPTION_STORAGE_CLASS (0x00000007 << 28)
65 * ...to determine how option arguments are to be inserted into the
66 * global options table...
68 #define OPTION_STORE_STRING (0x00000001 << 28)
69 #define OPTION_STORE_NUMBER (0x00000002 << 28)
70 #define OPTION_MERGE_NUMBER (0x00000003 << 28)
72 * ...with specific handling for individual options.
74 #define OPTION_TRACE (OPTION_MERGE_NUMBER | OPTION_DEBUGLEVEL)
76 /* Options controlled by bit-mapped flags within OPTION_FLAGS...
78 #define OPTION_VERBOSE (0x00000003)
79 #define OPTION_VERBOSE_MAX (0x00000003)
83 * We provide additional features for use in C++ modules.
88 /* This is primarily for convenience...
90 # define EXTERN_C extern "C"
93 class pkgOpts : protected pkgopts
95 /* A derived "convenience" class, associating a collection
96 * of utility methods with the pkgopts structure.
99 inline unsigned GetValue( int index )
101 /* Retrieve the value of a numeric data entry.
103 return this ? (flags[index].numeric) : 0;
105 inline const char *GetString( int index )
107 /* Retrieve a pointer to a string data entry.
109 return this ? (flags[index].string) : NULL;
111 inline unsigned Test( unsigned mask, int index = OPTION_FLAGS )
113 /* Test the state of specified bits within
114 * a bit-mapped numeric data (flags) entry.
116 return this ? (flags[index].numeric & mask) : 0;
120 /* Access modes for the following global options accessor function.
122 enum { OPTION_TABLE_LOOKUP, OPTION_TABLE_ASSIGN };
124 /* Global options accessor function; the default access mode is
125 * OPTION_TABLE_LOOKUP, (in which case the second argument is ignored),
126 * which allows us to simply use
128 * result = pkgOptions()->GetValue( OPTION_KEY );
130 * to retrieve a value from the global options table.
132 * The OPTION_TABLE_ASSIGN access mode is provided for initialisation
133 * of the global options table reference pointer; it is used during
134 * program start-up, after which it is not normally used again.
136 EXTERN_C pkgOpts *pkgOptions( int = OPTION_TABLE_LOOKUP, struct pkgopts* = NULL );
138 #endif /* __cplusplus */
140 #endif /* PKGOPTS_H: $RCSfile$: end of file */