@@ -174,33 +174,13 @@ std::enable_if_t<
174174 // length, start, and valueType.
175175
176176 // For this get(), the caller has stipulated a particular vector type.
177- // We'll print a warning if that type appears to conflict with valueType,
178- // or if valueType isn't something we know what to do with. In any event,
179- // we'll return what the caller requested. Note that valueType = "" (the
180- // empty string) is acceptable with any element type.
181-
182- bool consistent = true ;
183- if (valueType () == " Integer32" ) {
184- if (!std::is_same_v<T,Integer32>)
185- consistent = false ;
186- } else if (valueType () == " Float64" ) {
187- if (!std::is_same_v<T,Float64>)
188- consistent = false ;
189- } else if (valueType () == " UTF8Text" ) {
190- if (!std::is_same_v<T,UTF8Text>)
191- consistent = false ;
192- } else if (valueType () != " " ) {
177+ // We'll print a warning if that vector type appears to conflict with
178+ // valueType. Regardless, we'll return what the caller requested. Note
179+ // that valueType == "" is acceptable with any element type.
180+ if (valueType () != " " && !detail::MapTypeString<T>::find (valueType ())) {
193181 log::warning (
194- " Unrecognized valueType == \" {}\" ; ignoring" ,
195- valueType ()
196- );
197- log::member (context_rebuilding);
198- }
199-
200- if (!consistent) {
201- log::warning (
202- " Element type T may be inconsistent with valueType == \" {}\" ;\n " ,
203- " we'll create the requested std::vector<T> anyway" ,
182+ " Vector element type may be inconsistent with valueType \" {}\" ;\n "
183+ " we'll create the requested std::vector<> anyway" ,
204184 valueType ()
205185 );
206186 log::member (context_rebuilding);
@@ -401,16 +381,13 @@ std::conditional_t<
401381> get () const
402382{
403383 if constexpr (runtime) {
404- if (valueType () == " Integer32" )
405- get<std::vector<Integer32>>();
406- else if (valueType () == " Float64" )
407- get<std::vector<Float64>>();
408- else
409- get<std::vector<std::string>>();
410-
411- // We can't return the specific variant *alternative* that exists right
412- // now, because that depended on valueType (run-time). So, we'll return
413- // the whole variant, for whatever use that might have to a caller.
384+ detail::MapStringType (
385+ valueType (),
386+ [this ](auto &&t) { get<std::vector<std::decay_t <decltype (t)>>>(); }
387+ );
388+ // We can't return the specific variant alternative that was just put
389+ // in place; it depended on a run-time check. So, we return the whole
390+ // variant, for whatever use that might have to a caller.
414391 return variant;
415392 } else {
416393 // Simpler, but we do still need a get (in case the *string* is active).
@@ -552,8 +529,8 @@ operator[](const std::size_t n)
552529 template <class D = DATA> \
553530 std::enable_if_t < \
554531 detail::isVoid<D> || \
555- std::is_same_v<TYPE,D>, std::vector<TYPE> & \
556- > name () { return get<std::vector<TYPE>>(); } \
532+ std::is_same_v<TYPE,D>, std::vector<TYPE> & \
533+ > name () { return get<std::vector<TYPE>>(); } \
557534 \
558535 template <class D = DATA> \
559536 std::enable_if_t < \
@@ -564,26 +541,23 @@ operator[](const std::size_t n)
564541 template <class D = DATA> \
565542 std::enable_if_t < \
566543 detail::isVoid<D> || \
567- std::is_same_v<TYPE,D>, TYPE & \
568- > name (const std::size_t n) { return get<TYPE>(n); }
569-
570- GNDSTK_MAKE_GETTER (strings, std::string);
571- GNDSTK_MAKE_GETTER (chars, char );
572-
573- GNDSTK_MAKE_GETTER (schars, signed char );
574- GNDSTK_MAKE_GETTER (shorts, short );
575- GNDSTK_MAKE_GETTER (ints, int );
576- GNDSTK_MAKE_GETTER (longs, long );
577- GNDSTK_MAKE_GETTER (longlongs, long long );
578-
579- GNDSTK_MAKE_GETTER (uchars, unsigned char );
580- GNDSTK_MAKE_GETTER (ushorts, unsigned short );
581- GNDSTK_MAKE_GETTER (uints, unsigned int );
582- GNDSTK_MAKE_GETTER (ulongs, unsigned long );
583- GNDSTK_MAKE_GETTER (ulonglongs, unsigned long long );
584-
585- GNDSTK_MAKE_GETTER (floats, float );
586- GNDSTK_MAKE_GETTER (doubles, double );
587- GNDSTK_MAKE_GETTER (longdoubles, long double );
544+ std::is_same_v<TYPE,D>, TYPE & \
545+ > name (const std::size_t n) { return get<TYPE>(n); }
546+
547+ GNDSTK_MAKE_GETTER (strings, std::string)
548+ GNDSTK_MAKE_GETTER(chars, char )
549+ GNDSTK_MAKE_GETTER(schars, signed char )
550+ GNDSTK_MAKE_GETTER(shorts, short )
551+ GNDSTK_MAKE_GETTER(ints, int )
552+ GNDSTK_MAKE_GETTER(longs, long )
553+ GNDSTK_MAKE_GETTER(longlongs, long long )
554+ GNDSTK_MAKE_GETTER(uchars, unsigned char )
555+ GNDSTK_MAKE_GETTER(ushorts, unsigned short )
556+ GNDSTK_MAKE_GETTER(uints, unsigned int )
557+ GNDSTK_MAKE_GETTER(ulongs, unsigned long )
558+ GNDSTK_MAKE_GETTER(ulonglongs, unsigned long long )
559+ GNDSTK_MAKE_GETTER(floats, float )
560+ GNDSTK_MAKE_GETTER(doubles, double )
561+ GNDSTK_MAKE_GETTER(longdoubles, long double )
588562
589563#undef GNDSTK_MAKE_GETTER
0 commit comments