|
||||
File indexing completed on 2025-01-18 09:53:38
0001 0002 // (C) Copyright Edward Diener 2011-2015 0003 // Use, modification and distribution are subject to the Boost Software License, 0004 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 0005 // http://www.boost.org/LICENSE_1_0.txt). 0006 0007 #if !defined(BOOST_VMD_ELEM_HPP) 0008 #define BOOST_VMD_ELEM_HPP 0009 0010 #include <boost/vmd/detail/setup.hpp> 0011 0012 #if BOOST_PP_VARIADICS 0013 0014 #include <boost/vmd/detail/modifiers.hpp> 0015 #include <boost/vmd/detail/sequence_elem.hpp> 0016 0017 /* 0018 0019 The succeeding comments in this file are in doxygen format. 0020 0021 */ 0022 0023 /** \file 0024 */ 0025 0026 /** \def BOOST_VMD_ELEM(elem,...) 0027 0028 \brief Accesses an element of a sequence. 0029 0030 elem = A sequence element number. From 0 to sequence size - 1. <br/> 0031 ... = Variadic parameters. 0032 0033 The first variadic parameter is required and is the sequence to access. 0034 Further variadic parameters are all optional. 0035 0036 With no further variadic parameters the macro returns the particular element 0037 in the sequence. If the element number is outside the bounds of the sequence 0038 macro access fails and the macro turns emptiness. 0039 0040 Optional parameters determine what it means that an element is successfully 0041 accessed as well as what data is returned by the macro. 0042 0043 Filters: specifying a VMD type tells the macro to return the element only 0044 if it is of the VMD type specified, else macro access fails. If more than 0045 one VMD type is specified as an optional parameter the last one 0046 specified is the filter. 0047 0048 Matching Identifiers: If the filter is specified as the identifier type, BOOST_VMD_TYPE_IDENTIFIER, 0049 optional parameters which are identifiers specify that the element accessed 0050 must match one of the identifiers else access fails. The identifiers may be specified multiple 0051 times as single optional parameters or once as a tuple of identifier 0052 parameters. If the identifiers are specified as single optional parameters 0053 they cannot be any of the specific BOOST_VMD_ optional parameters in order to be 0054 recognized as matching identifiers. Normally this should never be the case. 0055 The only situation where this could occur is if the VMD types, which are filters, 0056 are used as matching identifiers; in this case the matching identifiers need 0057 to be passed as a tuple of identifier parameters so they are not treated 0058 as filters. 0059 0060 Filters and matching identifiers change what it means that an element is successfully 0061 accessed. They do not change what data is returned by the macro. The remaining optional 0062 parameters do not change what it means that an element is successfully accessed but they 0063 do change what data is returned by the macro. 0064 0065 @code 0066 0067 Splitting: Splitting allows the macro to return the rest of the sequence 0068 after the element accessed. 0069 0070 If BOOST_VMD_RETURN_AFTER is specified the return is a tuple 0071 with the element accessed as the first tuple parameter and the rest of 0072 the sequence as the second tuple parameter. If element access fails 0073 both tuple parameters are empty. 0074 0075 If BOOST_VMD_RETURN_ONLY_AFTER 0076 is specified the return is the rest of the sequence after the element accessed 0077 found. If the element access fails the return is emptiness. 0078 0079 If BOOST_VMD_RETURN_NO_AFTER, the default, is specified no splitting 0080 occurs. 0081 0082 If more than one of the splitting identifiers are specified 0083 the last one specified determines the splitting. 0084 0085 Return Type: The element accessed can be changed to return both the type 0086 of the element as well as the element data with optional return type 0087 parameters. When a type is returned, the element accessed which is returned becomes a 0088 two-element tuple where the type of the element accessed is the first tuple element and the element 0089 data itself is the second tuple element. If the macro fails to access the 0090 element the element access returned is emptiness and not a tuple. 0091 0092 If BOOST_VMD_RETURN_NO_TYPE, the default, is specified no type is returned 0093 as part of the element accessed. 0094 0095 If BOOST_VMD_RETURN_TYPE is specified the specific type of the element 0096 is returned in the tuple. 0097 0098 If BOOST_VMD_RETURN_TYPE_ARRAY is specified 0099 an array type is returned if the element is an array, else a tuple 0100 type is returned if the element is a tuple, else the actual type 0101 is returned for non-tuple data. 0102 0103 If BOOST_VMD_RETURN_TYPE_LIST is specified 0104 a list type is returned if the element is a list, else a tuple 0105 type is returned if the element is a tuple, else the actual type 0106 is returned for non-tuple data. 0107 0108 If BOOST_VMD_RETURN_TYPE_TUPLE is specified 0109 a tuple type is returned for all tuple-like data, else the actual type 0110 is returned for non-tuple data. 0111 0112 If more than one return type optional 0113 parameter is specified the last one specified determines the return type. 0114 0115 If a filter is specified optional return type parameters are ignored and 0116 the default BOOST_VMD_RETURN_NO_TYPE is in effect. 0117 0118 Index: If the filter is specified as the identifier type, BOOST_VMD_TYPE_IDENTIFIER, 0119 and matching identifiers are specified, an index parameter specifies that the 0120 numeric index, starting with 0, of the matching identifier found, be returned 0121 as part of the result. 0122 0123 If BOOST_VMD_RETURN_INDEX is specified an index is returned 0124 as part of the result. 0125 0126 If BOOST_VMD_RETURN_NO_INDEX, the default, is specified 0127 no index is returned as part of the result. 0128 0129 If both are specified the last one specified determines the index parameter. 0130 0131 When an index is returned as part of the result, the result is a tuple where the 0132 element accessed is the first tuple parameter and the index is the last tuple parameter. 0133 If element access fails the index is empty. If there is no BOOST_VMD_TYPE_IDENTIFIER 0134 filter or if there are no matching identifiers the BOOST_VMD_RETURN_INDEX is ignored 0135 and no index is returned as part of the result. 0136 0137 @endcode 0138 0139 returns = With no optional parameters the element accessed is returned, or emptiness if 0140 element is outside the bounds of the sequence. Filters and matching identifiers 0141 can change the meaning of whether the element accessed is returned or failure 0142 occurs, but whenever failure occurs emptiness is returned as the element access part 0143 of that failure, else the element accessed is returned. Return type optional parameters, 0144 when filters are not used, return the element accessed as a two-element tuple 0145 where the first tuple element is the type and the second tuple element is the 0146 data; if the element is not accessed then emptiness is returned as the element access 0147 and not a tuple. Splitting with BOOST_VMD_RETURN_AFTER returns a tuple where the element accessed 0148 is the first tuple element and the rest of the sequence is the second tuple element. 0149 Splitting with BOOST_VMD_RETURN_ONLY_AFTER returns the rest of the sequence after 0150 the element accessed or emptiness if the element can not be accessed. Indexing 0151 returns the index as part of the output only if filtering with 0152 BOOST_VMD_TYPE_IDENTIFIER is specified and matching identifiers are specified. 0153 When the index is returned with BOOST_VMD_RETURN_AFTER it is the third element 0154 of the tuple returned, else it is the second element of a tuple where the element 0155 accessed is the first element of the tuple. 0156 0157 */ 0158 0159 #define BOOST_VMD_ELEM(elem,...) \ 0160 BOOST_VMD_DETAIL_SEQUENCE_ELEM(BOOST_VMD_ALLOW_ALL,elem,__VA_ARGS__) \ 0161 /**/ 0162 0163 /** \def BOOST_VMD_ELEM_D(d,elem,...) 0164 0165 \brief Accesses an element of a sequence. Re-entrant version. 0166 0167 d = The next available BOOST_PP_WHILE iteration. <br/> 0168 elem = A sequence element number. From 0 to sequence size - 1. <br/> 0169 ... = Variadic parameters. 0170 0171 The first variadic parameter is required and is the sequence to access. 0172 Further variadic parameters are all optional. 0173 0174 With no further variadic parameters the macro returns the particular element 0175 in the sequence. If the element number is outside the bounds of the sequence 0176 macro access fails and the macro turns emptiness. 0177 0178 Optional parameters determine what it means that an element is successfully 0179 accessed as well as what data is returned by the macro. 0180 0181 Filters: specifying a VMD type tells the macro to return the element only 0182 if it is of the VMD type specified, else macro access fails. If more than 0183 one VMD type is specified as an optional parameter the last one 0184 specified is the filter. 0185 0186 Matching Identifiers: If the filter is specified as the identifier type, BOOST_VMD_TYPE_IDENTIFIER, 0187 optional parameters which are identifiers specify that the element accessed 0188 must match one of the identifiers else access fails. The identifiers may be specified multiple 0189 times as single optional parameters or once as a tuple of identifier 0190 parameters. If the identifiers are specified as single optional parameters 0191 they cannot be any of the specific BOOST_VMD_ optional parameters in order to be 0192 recognized as matching identifiers. Normally this should never be the case. 0193 The only situation where this could occur is if the VMD types, which are filters, 0194 are used as matching identifiers; in this case the matching identifiers need 0195 to be passed as a tuple of identifier parameters so they are not treated 0196 as filters. 0197 0198 Filters and matching identifiers change what it means that an element is successfully 0199 accessed. They do not change what data is returned by the macro. The remaining optional 0200 parameters do not change what it means that an element is successfully accessed but they 0201 do change what data is returned by the macro. 0202 0203 @code 0204 0205 Splitting: Splitting allows the macro to return the rest of the sequence 0206 after the element accessed. 0207 0208 If BOOST_VMD_RETURN_AFTER is specified the return is a tuple 0209 with the element accessed as the first tuple parameter and the rest of 0210 the sequence as the second tuple parameter. If element access fails 0211 both tuple parameters are empty. 0212 0213 If BOOST_VMD_RETURN_ONLY_AFTER 0214 is specified the return is the rest of the sequence after the element accessed 0215 found. If the element access fails the return is emptiness. 0216 0217 If BOOST_VMD_RETURN_NO_AFTER, the default, is specified no splitting 0218 occurs. 0219 0220 If more than one of the splitting identifiers are specified 0221 the last one specified determines the splitting. 0222 0223 Return Type: The element accessed can be changed to return both the type 0224 of the element as well as the element data with optional return type 0225 parameters. When a type is returned, the element accessed which is returned becomes a 0226 two-element tuple where the type of the element accessed is the first tuple element and the element 0227 data itself is the second tuple element. If the macro fails to access the 0228 element the element access returned is emptiness and not a tuple. 0229 0230 If BOOST_VMD_RETURN_NO_TYPE, the default, is specified no type is returned 0231 as part of the element accessed. 0232 0233 If BOOST_VMD_RETURN_TYPE is specified the specific type of the element 0234 is returned in the tuple. 0235 0236 If BOOST_VMD_RETURN_TYPE_ARRAY is specified 0237 an array type is returned if the element is an array, else a tuple 0238 type is returned if the element is a tuple, else the actual type 0239 is returned for non-tuple data. 0240 0241 If BOOST_VMD_RETURN_TYPE_LIST is specified 0242 a list type is returned if the element is a list, else a tuple 0243 type is returned if the element is a tuple, else the actual type 0244 is returned for non-tuple data. 0245 0246 If BOOST_VMD_RETURN_TYPE_TUPLE is specified 0247 a tuple type is returned for all tuple-like data, else the actual type 0248 is returned for non-tuple data. If more than one return type optional 0249 parameter is specified the last one specified determines the return type. 0250 0251 If a filter is specified optional return type parameters are ignored and 0252 the default BOOST_VMD_RETURN_NO_TYPE is in effect. 0253 0254 Index: If the filter is specified as the identifier type, BOOST_VMD_TYPE_IDENTIFIER, 0255 and matching identifiers are specified, an index parameter specifies that the 0256 numeric index, starting with 0, of the matching identifier found, be returned 0257 as part of the result. 0258 0259 If BOOST_VMD_RETURN_INDEX is specified an index is returned 0260 as part of the result. 0261 0262 If BOOST_VMD_RETURN_NO_INDEX, the default, is specified 0263 no index is returned as part of the result. 0264 0265 If both are specified the last one specified determines the index parameter. 0266 0267 When an index is returned as part of the result, the result is a tuple where the 0268 element accessed is the first tuple parameter and the index is the last tuple parameter. 0269 If element access fails the index is empty. If there is no BOOST_VMD_TYPE_IDENTIFIER 0270 filter or if there are no matching identifiers the BOOST_VMD_RETURN_INDEX is ignored 0271 and no index is returned as part of the result. 0272 0273 @endcode 0274 0275 returns = With no optional parameters the element accessed is returned, or emptiness if 0276 element is outside the bounds of the sequence. Filters and matching identifiers 0277 can change the meaning of whether the element accessed is returned or failure 0278 occurs, but whenever failure occurs emptiness is returned as the element access part 0279 of that failure, else the element accessed is returned. Return type optional parameters, 0280 when filters are not used, return the element accessed as a two-element tuple 0281 where the first tuple element is the type and the second tuple element is the 0282 data; if the element is not accessed then emptiness is returned as the element access 0283 and not a tuple. Splitting with BOOST_VMD_RETURN_AFTER returns a tuple where the element accessed 0284 is the first tuple element and the rest of the sequence is the second tuple element. 0285 Splitting with BOOST_VMD_RETURN_ONLY_AFTER returns the rest of the sequence after 0286 the element accessed or emptiness if the element can not be accessed. Indexing 0287 returns the index as part of the output only if filtering with 0288 BOOST_VMD_TYPE_IDENTIFIER is specified and matching identifiers are specified. 0289 When the index is returned with BOOST_VMD_RETURN_AFTER it is the third element 0290 of the tuple returned, else it is the second element of a tuple where the element 0291 accessed is the first element of the tuple. 0292 0293 */ 0294 0295 #define BOOST_VMD_ELEM_D(d,elem,...) \ 0296 BOOST_VMD_DETAIL_SEQUENCE_ELEM_D(d,BOOST_VMD_ALLOW_ALL,elem,__VA_ARGS__) \ 0297 /**/ 0298 0299 #endif /* BOOST_PP_VARIADICS */ 0300 #endif /* BOOST_VMD_ELEM_HPP */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |