Commit ce19ec5c4b0ae88592289bf3c5b32b71b9c22eaa

Authored by Jay Berkenbilt
1 parent de0b11fc

Update examples to use QPDFObjectHandle iterators

Showing 1 changed file with 7 additions and 10 deletions
examples/pdf-mod-info.cc
... ... @@ -40,25 +40,22 @@ void dumpInfoDict(QPDF& pdf,
40 40 if (trailer.hasKey("/Info"))
41 41 {
42 42 QPDFObjectHandle info = trailer.getKey("/Info");
43   - std::set<std::string> keys = info.getKeys();
44   - for (std::set<std::string>::const_iterator it = keys.begin();
45   - keys.end() != it; ++it)
  43 + for (auto& it: QPDFDictItems(info))
46 44 {
47   - QPDFObjectHandle elt = info.getKey(*it);
48 45 std::string val;
49   - if (elt.isString())
  46 + if (it.second.isString())
50 47 {
51   - val = elt.getStringValue();
  48 + val = it.second.getStringValue();
52 49 }
53   - else if (elt.isName())
  50 + else if (it.second.isName())
54 51 {
55   - val = elt.getName();
  52 + val = it.second.getName();
56 53 }
57 54 else // according to PDF Spec 1.5, shouldn't happen
58 55 {
59   - val = elt.unparseResolved();
  56 + val = it.second.unparseResolved();
60 57 }
61   - os << it->substr(1) << sep << val << std::endl; // skip '/'
  58 + os << it.first.substr(1) << sep << val << std::endl; // skip '/'
62 59 }
63 60 }
64 61 }
... ...