2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-02 03:42:30 +00:00
qpdf/libtests/numrange.cc
Jay Berkenbilt 4f24617e1e Code clean up: use range-style for loops wherever possible
Where not possible, use "auto" to get the iterator type.

Editorial note: I have avoid this change for a long time because of
not wanting to make gratuitous changes to version history, which can
obscure when certain changes were made, but with having recently
touched every single file to apply automatic code formatting and with
making several broad changes to the API, I decided it was time to take
the plunge and get rid of the older (pre-C++11) verbose iterator
syntax. The new code is just easier to read and understand, and in
many cases, it will be more effecient as fewer temporary copies are
being made.

m-holger, if you're reading, you can see that I've finally come
around. :-)
2022-04-30 13:27:18 -04:00

31 lines
607 B
C++

#include <qpdf/QUtil.hh>
#include <iostream>
static void
test_numrange(char const* range)
{
if (range == 0) {
std::cout << "null" << std::endl;
} else {
std::vector<int> result = QUtil::parse_numrange(range, 15);
std::cout << "numeric range " << range << " ->";
for (int i: result) {
std::cout << " " << i;
}
std::cout << std::endl;
}
}
int
main(int argc, char* argv[])
{
try {
test_numrange(argv[1]);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
return 2;
}
return 0;
}