Updated examples for use on website, updated tests accordingly

v0.27.3
Andreas Huggel 21 years ago
parent daac70b5ef
commit e09052e2d5

@ -8,52 +8,34 @@
void printIptc(const Exiv2::IptcData& iptcData);
int main()
int main(int argc, char* const argv[])
try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
}
std::string file(argv[1]);
Exiv2::IptcData iptcData;
iptcData["Iptc.Application2.Headline"] = "The headline I am";
iptcData["Iptc.Application2.Keywords"] = "Yet another keyword";
iptcData["Iptc.Application2.DateCreated"] = "2004-8-3";
iptcData["Iptc.Application2.Urgency"] = uint16_t(3);
iptcData["Iptc.Application2.SuppCategory"] = "bla bla bla";
iptcData["Iptc.Envelope.ModelVersion"] = 2;
iptcData["Iptc.Application2.Urgency"] = uint16_t(1);
iptcData["Iptc.Envelope.ModelVersion"] = 42;
iptcData["Iptc.Envelope.TimeSent"] = "14:41:0-05:00";
iptcData["Iptc.Application2.RasterizedCaption"] = "230 42 34 2 90 84 23 146";
iptcData["Iptc.0x0009.0x0001"] = "Who am I?";
Exiv2::StringValue value;
value.read("Hi there!");
iptcData["Iptc.Envelope.ModelVersion"] = value;
std::cout << "Time sent: " << iptcData["Iptc.Envelope.TimeSent"] << "\n\n";
value.read("very!");
iptcData["Iptc.Application2.Urgency"] = value;
printIptc(iptcData);
std::cout << "Time sent: " << iptcData["Iptc.Envelope.TimeSent"] << "\n";
return 0;
return iptcData.write(file); // Write IPTC data to file and exit
}
catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
void printIptc(const Exiv2::IptcData& iptcData)
{
Exiv2::IptcData::const_iterator end = iptcData.end();
Exiv2::IptcData::const_iterator md;
for (md = iptcData.begin(); md != end; ++md) {
std::cout << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md->tag() << " "
<< std::setw(12) << std::setfill(' ') << std::left
<< md->recordName() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< md->count() << " "
<< std::setw(27) << std::setfill(' ') << std::left
<< md->tagName() << " "
<< std::dec << md->value()
<< std::endl;
}
}

@ -22,13 +22,18 @@ try {
}
Exiv2::IptcData::iterator end = iptcData.end();
for (Exiv2::IptcData::iterator i = iptcData.begin(); i != end; ++i) {
std::cout << std::setw(40) << std::setfill(' ') << std::left
<< i->key() << " "
for (Exiv2::IptcData::iterator md = iptcData.begin(); md != end; ++md) {
std::cout << std::setw(36) << std::setfill(' ') << std::left
<< md->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " "
<< std::dec << i->value()
<< "\n";
<< std::hex << md->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< md->count() << " "
<< std::dec << md->value()
<< std::endl;
}
return rc;

@ -1,9 +1,9 @@
Iptc.Application2.Caption 0x0078 A picture of a glider being built
Iptc.Application2.Headline 0x0069 The headline I am
Iptc.Application2.Keywords 0x0019 Yet another keyword
Iptc.Application2.DateCreated 0x0037 2004-08-03
Iptc.Application2.Urgency 0x000a 3
Iptc.Application2.SuppCategory 0x0014 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 2
Iptc.Envelope.TimeSent 0x0050 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d 230 42 34 2 90 84 23 146
Iptc.Application2.Caption 0x0078 String 33 A picture of a glider being built
Iptc.Application2.Headline 0x0069 String 17 The headline I am
Iptc.Application2.Keywords 0x0019 String 19 Yet another keyword
Iptc.Application2.DateCreated 0x0037 Date 8 2004-08-03
Iptc.Application2.Urgency 0x000a String 1 3
Iptc.Application2.SuppCategory 0x0014 String 10 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 Short 1 2
Iptc.Envelope.TimeSent 0x0050 Time 11 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d Undefined 8 230 42 34 2 90 84 23 146

@ -1 +1 @@
Iptc.Application2.Caption 0x0078 A picture of a glider being built
Iptc.Application2.Caption 0x0078 String 33 A picture of a glider being built

File diff suppressed because one or more lines are too long

@ -1,20 +1,20 @@
Iptc.Application2.Caption 0x0078 yelimS green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a Nobody
Iptc.Application2.Byline 0x0050 Its me
Iptc.Application2.ObjectName 0x0005 GreeenDude
Iptc.Application2.DateCreated 0x0037 2004-08-03
Iptc.Application2.City 0x005a Seattle
Iptc.Application2.ProvinceState 0x005f WA
Iptc.Application2.CountryName 0x0065 USA
Iptc.Application2.Category 0x000f Things
Iptc.Application2.Keywords 0x0019 Green
Iptc.Application2.Keywords 0x0019 Smiley
Iptc.Application2.Keywords 0x0019 Dude
Iptc.Application2.Copyright 0x0074 © 2004 Nobody
Iptc.Application2.Headline 0x0069 The headline I am
Iptc.Application2.Keywords 0x0019 Yet another keyword
Iptc.Application2.Urgency 0x000a 3
Iptc.Application2.SuppCategory 0x0014 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 2
Iptc.Envelope.TimeSent 0x0050 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d 230 42 34 2 90 84 23 146
Iptc.Application2.Caption 0x0078 String 38 yelimS green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a String 6 Nobody
Iptc.Application2.Byline 0x0050 String 6 Its me
Iptc.Application2.ObjectName 0x0005 String 10 GreeenDude
Iptc.Application2.DateCreated 0x0037 Date 8 2004-08-03
Iptc.Application2.City 0x005a String 7 Seattle
Iptc.Application2.ProvinceState 0x005f String 2 WA
Iptc.Application2.CountryName 0x0065 String 3 USA
Iptc.Application2.Category 0x000f String 6 Things
Iptc.Application2.Keywords 0x0019 String 5 Green
Iptc.Application2.Keywords 0x0019 String 6 Smiley
Iptc.Application2.Keywords 0x0019 String 4 Dude
Iptc.Application2.Copyright 0x0074 String 13 © 2004 Nobody
Iptc.Application2.Headline 0x0069 String 17 The headline I am
Iptc.Application2.Keywords 0x0019 String 19 Yet another keyword
Iptc.Application2.Urgency 0x000a String 1 3
Iptc.Application2.SuppCategory 0x0014 String 10 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 Short 1 2
Iptc.Envelope.TimeSent 0x0050 Time 11 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d Undefined 8 230 42 34 2 90 84 23 146

@ -1,13 +1,13 @@
Iptc.Application2.Caption 0x0078 yelimS green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a Nobody
Iptc.Application2.Byline 0x0050 Its me
Iptc.Application2.ObjectName 0x0005 GreeenDude
Iptc.Application2.DateCreated 0x0037 2004-07-13
Iptc.Application2.City 0x005a Seattle
Iptc.Application2.ProvinceState 0x005f WA
Iptc.Application2.CountryName 0x0065 USA
Iptc.Application2.Category 0x000f Things
Iptc.Application2.Keywords 0x0019 Green
Iptc.Application2.Keywords 0x0019 Smiley
Iptc.Application2.Keywords 0x0019 Dude
Iptc.Application2.Copyright 0x0074 © 2004 Nobody
Iptc.Application2.Caption 0x0078 String 38 yelimS green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a String 6 Nobody
Iptc.Application2.Byline 0x0050 String 6 Its me
Iptc.Application2.ObjectName 0x0005 String 10 GreeenDude
Iptc.Application2.DateCreated 0x0037 Date 8 2004-07-13
Iptc.Application2.City 0x005a String 7 Seattle
Iptc.Application2.ProvinceState 0x005f String 2 WA
Iptc.Application2.CountryName 0x0065 String 3 USA
Iptc.Application2.Category 0x000f String 6 Things
Iptc.Application2.Keywords 0x0019 String 5 Green
Iptc.Application2.Keywords 0x0019 String 6 Smiley
Iptc.Application2.Keywords 0x0019 String 4 Dude
Iptc.Application2.Copyright 0x0074 String 13 © 2004 Nobody

@ -1,7 +1,7 @@
Iptc.Application2.Writer 0x007a Nobody
Iptc.Application2.ObjectName 0x0005 GreeenDude
Iptc.Application2.DateCreated 0x0037 2004-07-13
Iptc.Application2.City 0x005a Seattle
Iptc.Application2.ProvinceState 0x005f WA
Iptc.Application2.Category 0x000f Things
Iptc.Application2.Copyright 0x0074 © 2004 Nobody
Iptc.Application2.Writer 0x007a String 6 Nobody
Iptc.Application2.ObjectName 0x0005 String 10 GreeenDude
Iptc.Application2.DateCreated 0x0037 Date 8 2004-07-13
Iptc.Application2.City 0x005a String 7 Seattle
Iptc.Application2.ProvinceState 0x005f String 2 WA
Iptc.Application2.Category 0x000f String 6 Things
Iptc.Application2.Copyright 0x0074 String 13 © 2004 Nobody

File diff suppressed because one or more lines are too long

@ -1,14 +1,14 @@
Iptc.Application2.RecordVersion 0x0000 2
Iptc.Application2.Caption 0x0078 A bunch of squares
Iptc.Application2.Byline 0x0050 Brad
Iptc.Application2.ObjectName 0x0005 This is a title
Iptc.Application2.Keywords 0x0019 nothing
Iptc.Application2.Keywords 0x0019 really
Iptc.Application2.Headline 0x0069 The headline I am
Iptc.Application2.Keywords 0x0019 Yet another keyword
Iptc.Application2.DateCreated 0x0037 2004-08-03
Iptc.Application2.Urgency 0x000a 3
Iptc.Application2.SuppCategory 0x0014 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 2
Iptc.Envelope.TimeSent 0x0050 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d 230 42 34 2 90 84 23 146
Iptc.Application2.RecordVersion 0x0000 Short 1 2
Iptc.Application2.Caption 0x0078 String 18 A bunch of squares
Iptc.Application2.Byline 0x0050 String 4 Brad
Iptc.Application2.ObjectName 0x0005 String 15 This is a title
Iptc.Application2.Keywords 0x0019 String 7 nothing
Iptc.Application2.Keywords 0x0019 String 6 really
Iptc.Application2.Headline 0x0069 String 17 The headline I am
Iptc.Application2.Keywords 0x0019 String 19 Yet another keyword
Iptc.Application2.DateCreated 0x0037 Date 8 2004-08-03
Iptc.Application2.Urgency 0x000a String 1 3
Iptc.Application2.SuppCategory 0x0014 String 10 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 Short 1 2
Iptc.Envelope.TimeSent 0x0050 Time 11 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d Undefined 8 230 42 34 2 90 84 23 146

@ -1,6 +1,6 @@
Iptc.Application2.RecordVersion 0x0000 2
Iptc.Application2.Caption 0x0078 A bunch of squares
Iptc.Application2.Byline 0x0050 Brad
Iptc.Application2.ObjectName 0x0005 This is a title
Iptc.Application2.Keywords 0x0019 nothing
Iptc.Application2.Keywords 0x0019 really
Iptc.Application2.RecordVersion 0x0000 Short 1 2
Iptc.Application2.Caption 0x0078 String 18 A bunch of squares
Iptc.Application2.Byline 0x0050 String 4 Brad
Iptc.Application2.ObjectName 0x0005 String 15 This is a title
Iptc.Application2.Keywords 0x0019 String 7 nothing
Iptc.Application2.Keywords 0x0019 String 6 really

@ -1,2 +1,2 @@
Iptc.Application2.RecordVersion 0x0000 2
Iptc.Application2.ObjectName 0x0005 This is a title
Iptc.Application2.RecordVersion 0x0000 Short 1 2
Iptc.Application2.ObjectName 0x0005 String 15 This is a title

File diff suppressed because one or more lines are too long

@ -1,20 +1,20 @@
Iptc.Application2.Caption 0x0078 Smiley green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a Nobody
Iptc.Application2.Byline 0x0050 Its me
Iptc.Application2.ObjectName 0x0005 GreeenDude
Iptc.Application2.DateCreated 0x0037 2004-08-03
Iptc.Application2.City 0x005a Seattle
Iptc.Application2.ProvinceState 0x005f WA
Iptc.Application2.CountryName 0x0065 USA
Iptc.Application2.Category 0x000f Things
Iptc.Application2.Keywords 0x0019 Green
Iptc.Application2.Keywords 0x0019 Smiley
Iptc.Application2.Keywords 0x0019 Dude
Iptc.Application2.Copyright 0x0074 © 2004 Nobody
Iptc.Application2.Headline 0x0069 The headline I am
Iptc.Application2.Keywords 0x0019 Yet another keyword
Iptc.Application2.Urgency 0x000a 3
Iptc.Application2.SuppCategory 0x0014 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 2
Iptc.Envelope.TimeSent 0x0050 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d 230 42 34 2 90 84 23 146
Iptc.Application2.Caption 0x0078 String 38 Smiley green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a String 6 Nobody
Iptc.Application2.Byline 0x0050 String 6 Its me
Iptc.Application2.ObjectName 0x0005 String 10 GreeenDude
Iptc.Application2.DateCreated 0x0037 Date 8 2004-08-03
Iptc.Application2.City 0x005a String 7 Seattle
Iptc.Application2.ProvinceState 0x005f String 2 WA
Iptc.Application2.CountryName 0x0065 String 3 USA
Iptc.Application2.Category 0x000f String 6 Things
Iptc.Application2.Keywords 0x0019 String 5 Green
Iptc.Application2.Keywords 0x0019 String 6 Smiley
Iptc.Application2.Keywords 0x0019 String 4 Dude
Iptc.Application2.Copyright 0x0074 String 13 © 2004 Nobody
Iptc.Application2.Headline 0x0069 String 17 The headline I am
Iptc.Application2.Keywords 0x0019 String 19 Yet another keyword
Iptc.Application2.Urgency 0x000a String 1 3
Iptc.Application2.SuppCategory 0x0014 String 10 bla bla ba
Iptc.Envelope.ModelVersion 0x0000 Short 1 2
Iptc.Envelope.TimeSent 0x0050 Time 11 14:41:00-05:00
Iptc.Application2.RasterizedCaption 0x007d Undefined 8 230 42 34 2 90 84 23 146

@ -1,13 +1,13 @@
Iptc.Application2.Caption 0x0078 Smiley green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a Nobody
Iptc.Application2.Byline 0x0050 Its me
Iptc.Application2.ObjectName 0x0005 GreeenDude
Iptc.Application2.DateCreated 0x0037 2004-07-13
Iptc.Application2.City 0x005a Seattle
Iptc.Application2.ProvinceState 0x005f WA
Iptc.Application2.CountryName 0x0065 USA
Iptc.Application2.Category 0x000f Things
Iptc.Application2.Keywords 0x0019 Green
Iptc.Application2.Keywords 0x0019 Smiley
Iptc.Application2.Keywords 0x0019 Dude
Iptc.Application2.Copyright 0x0074 © 2004 Nobody
Iptc.Application2.Caption 0x0078 String 38 Smiley green faced dude (iptc caption)
Iptc.Application2.Writer 0x007a String 6 Nobody
Iptc.Application2.Byline 0x0050 String 6 Its me
Iptc.Application2.ObjectName 0x0005 String 10 GreeenDude
Iptc.Application2.DateCreated 0x0037 Date 8 2004-07-13
Iptc.Application2.City 0x005a String 7 Seattle
Iptc.Application2.ProvinceState 0x005f String 2 WA
Iptc.Application2.CountryName 0x0065 String 3 USA
Iptc.Application2.Category 0x000f String 6 Things
Iptc.Application2.Keywords 0x0019 String 5 Green
Iptc.Application2.Keywords 0x0019 String 6 Smiley
Iptc.Application2.Keywords 0x0019 String 4 Dude
Iptc.Application2.Copyright 0x0074 String 13 © 2004 Nobody

@ -1,7 +1,7 @@
Iptc.Application2.Writer 0x007a Nobody
Iptc.Application2.ObjectName 0x0005 GreeenDude
Iptc.Application2.DateCreated 0x0037 2004-07-13
Iptc.Application2.City 0x005a Seattle
Iptc.Application2.ProvinceState 0x005f WA
Iptc.Application2.Category 0x000f Things
Iptc.Application2.Copyright 0x0074 © 2004 Nobody
Iptc.Application2.Writer 0x007a String 6 Nobody
Iptc.Application2.ObjectName 0x0005 String 10 GreeenDude
Iptc.Application2.DateCreated 0x0037 Date 8 2004-07-13
Iptc.Application2.City 0x005a String 7 Seattle
Iptc.Application2.ProvinceState 0x005f String 2 WA
Iptc.Application2.Category 0x000f String 6 Things
Iptc.Application2.Copyright 0x0074 String 13 © 2004 Nobody

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save