Home » U++ Library support » U++ Core » NFormat should check if args were left
NFormat should check if args were left [message #2501] |
Sat, 15 April 2006 09:48 |
hans
Messages: 44 Registered: March 2006 Location: Germany
|
Member |
|
|
IMHO the NFormat function should check if any args were not printed, so NFormat("%n", 23, 43) will bugcheck.
Could be something like (in format.cpp)
RegisterValueFormatter(L"vt", &StdFormatFormatter);
...
...
if(*s == '\0') {
#ifdef _DEBUG
if (pos < v.GetCount()) {
LOG("Not enough formatter: " << pos << " but " << v.GetCount() << " arg(s)");
NEVER();
}
#else
if (pos < v.GetCount()) {
result << " !MOREARGS! ";
for (int i= pos; i < v.GetCount(); ++i)
result << v[i] << ' ';
}
#endif
return result;
}
|
|
|
Re: NFormat should check if args were left [message #2552 is a reply to message #2501] |
Mon, 17 April 2006 19:11 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Well, a good idea, however things are not that easy: "pos < v.GetCount" even if all parameters were used (because you can apply them in arbitrary order, using position in formatting specifiers).
Would require some sort of bitset or Index, I am not sure whether it is worth the trouble...
Mirek
[Updated on: Mon, 17 April 2006 19:11] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Sat May 04 09:45:02 CEST 2024
Total time taken to generate the page: 0.03202 seconds
|