libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ _M_extract_name()

template<typename _CharT, typename _InIter>
_InIter std::time_get< _CharT, _InIter >::_M_extract_name ( iter_type __beg,
iter_type __end,
int & __member,
const _CharT ** __names,
size_t __indexlen,
ios_base & __io,
ios_base::iostate & __err ) const
protectedinherited

Definition at line 1093 of file locale_facets_nonio.tcc.

1097 {
1099 const locale& __loc = __io._M_getloc();
1101
1102 size_t* __matches
1103 = static_cast<size_t*>(__builtin_alloca(2 * sizeof(size_t)
1104 * __indexlen));
1105 size_t* __lengths = __matches + __indexlen;
1106 size_t __nmatches = 0;
1107 size_t __pos = 0;
1108 bool __testvalid = true;
1109 const char_type* __name;
1110 bool __begupdated = false;
1111
1112 // Look for initial matches.
1113 if (__beg != __end)
1114 {
1115 const char_type __c = *__beg;
1116 // TODO real case-insensitive comparison
1117 const char_type __cl = __ctype.tolower(__c);
1118 const char_type __cu = __ctype.toupper(__c);
1119 for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1120 if (__cl == __ctype.tolower(__names[__i1][0])
1121 || __cu == __ctype.toupper(__names[__i1][0]))
1122 {
1126 }
1127 }
1128
1129 while (__nmatches > 1)
1130 {
1131 // Find smallest matching string.
1132 size_t __minlen = __lengths[0];
1133 for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
1135 ++__pos;
1136 ++__beg;
1137 if (__pos == __minlen)
1138 {
1139 // If some match has remaining length of 0,
1140 // need to decide if any match with remaining
1141 // length non-zero matches the next character.
1142 // If so, remove all matches with remaining length
1143 // 0 from consideration, otherwise keep only matches
1144 // with remaining length 0.
1145 bool __match_longer = false;
1146
1147 if (__beg != __end)
1148 {
1149 // TODO real case-insensitive comparison
1150 const char_type __cl = __ctype.tolower(*__beg);
1151 const char_type __cu = __ctype.toupper(*__beg);
1152 for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1153 {
1155 if (__lengths[__i3] > __pos
1156 && (__ctype.tolower(__name[__pos]) == __cl
1157 || __ctype.toupper(__name[__pos]) == __cu))
1158 {
1159 __match_longer = true;
1160 break;
1161 }
1162 }
1163 }
1164 for (size_t __i4 = 0; __i4 < __nmatches;)
1165 if (__match_longer == (__lengths[__i4] == __pos))
1166 {
1169 }
1170 else
1171 ++__i4;
1172 if (__match_longer)
1173 {
1174 __minlen = __lengths[0];
1175 for (size_t __i5 = 1; __i5 < __nmatches; ++__i5)
1177 }
1178 else
1179 {
1180 // Deal with May being full as well as abbreviated month
1181 // name. Pick the smaller index.
1182 if (__nmatches == 2 && (__indexlen & 1) == 0)
1183 {
1184 if (__matches[0] < __indexlen / 2)
1185 {
1186 if (__matches[1] == __matches[0] + __indexlen / 2)
1187 __nmatches = 1;
1188 }
1189 else if (__matches[1] == __matches[0] - __indexlen / 2)
1190 {
1191 __matches[0] = __matches[1];
1192 __lengths[0] = __lengths[1];
1193 __nmatches = 1;
1194 }
1195 }
1196 __begupdated = true;
1197 break;
1198 }
1199 }
1200 if (__pos < __minlen && __beg != __end)
1201 {
1202 // TODO real case-insensitive comparison
1203 const char_type __cl = __ctype.tolower(*__beg);
1204 const char_type __cu = __ctype.toupper(*__beg);
1205 for (size_t __i6 = 0; __i6 < __nmatches;)
1206 {
1208 if (__ctype.tolower(__name[__pos]) != __cl
1209 && __ctype.toupper(__name[__pos]) != __cu)
1210 {
1213 }
1214 else
1215 ++__i6;
1216 }
1217 }
1218 else
1219 break;
1220 }
1221
1222 if (__nmatches == 1)
1223 {
1224 // Make sure found name is completely extracted.
1225 if (!__begupdated)
1226 {
1227 ++__beg;
1228 ++__pos;
1229 }
1230 __name = __names[__matches[0]];
1231 const size_t __len = __lengths[0];
1232 while (__pos < __len
1233 && __beg != __end
1234 // TODO real case-insensitive comparison
1235 && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
1236 || (__ctype.toupper(__name[__pos])
1237 == __ctype.toupper(*__beg))))
1238 ++__beg, (void)++__pos;
1239
1240 if (__len == __pos)
1241 __member = __matches[0];
1242 else
1243 __testvalid = false;
1244 }
1245 else
1246 __testvalid = false;
1247 if (!__testvalid)
1249
1250 return __beg;
1251 }
_CharT char_type
Public typedefs.
Primary class template time_get.

References time_get(), std::ios_base::_M_getloc(), std::ios_base::failbit, std::locale::facet::locale, std::min(), std::__ctype_abstract_base< _CharT >::tolower(), std::__ctype_abstract_base< _CharT >::toupper(), and std::use_facet().

Referenced by _M_extract_via_format().

Here is the call graph for this function:
Here is the caller graph for this function: