From e887b6487f6761e603d3054645180934145d5e84 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Thu, 19 Nov 2020 09:21:56 +0000 Subject: [PATCH] fix_1393_iptc_tags_web_0.27 --- doc/templates/Makefile | 8 +++---- doc/templates/iptc.awk | 47 ------------------------------------------ doc/templates/iptc.py | 39 +++++++++++++++++++++++++++++++++++ doc/templates/tags.awk | 43 -------------------------------------- doc/templates/tags.py | 35 +++++++++++++++++++++++++++++++ doc/templates/xmp.awk | 42 ------------------------------------- doc/templates/xmp.py | 34 ++++++++++++++++++++++++++++++ src/datasets.cpp | 12 +++++++++-- src/properties.cpp | 23 +++++++++++++++------ src/tags.cpp | 23 ++++++++++++++------- 10 files changed, 154 insertions(+), 152 deletions(-) delete mode 100644 doc/templates/iptc.awk create mode 100755 doc/templates/iptc.py delete mode 100644 doc/templates/tags.awk create mode 100755 doc/templates/tags.py delete mode 100644 doc/templates/xmp.awk create mode 100755 doc/templates/xmp.py diff --git a/doc/templates/Makefile b/doc/templates/Makefile index f33bed88..cfdcd849 100644 --- a/doc/templates/Makefile +++ b/doc/templates/Makefile @@ -36,7 +36,7 @@ # # Description: # Simple Makefile to create html documentation from templates. Requires -# some special tools (awk, python, xsltproc) but really only needs to +# some special tools (python3, xsltproc) but really only needs to # be used to update the documentation after changing Exiv2 tags in the # source code. # @@ -168,7 +168,7 @@ tags: $(TABLES) Iptc $(SCHEMA) $(TABLES): @echo Generating $@ table... - @$(TAGLIST) $@ | sed -e"s//\>/g" | awk -f tags.awk > $@.xml + @$(TAGLIST) $@ | sed -e"s//\>/g" | python3 tags.py > $@.xml @xsltproc tags.xsl $@.xml > $@.tmp @sed "s/report1/$@/" $@.tmp > __$@__ @touch $@ @@ -177,7 +177,7 @@ $(TABLES): Iptc: @echo Generating $@ table... @$(TAGLIST) $@ | sed -e"s//\>/g" -e"s/�/\±/g" \ - | awk -f iptc.awk > $@.xml + | python3 iptc.py > $@.xml @xsltproc iptc.xsl $@.xml > $@.tmp @sed "s/report1/$@/g" $@.tmp > __$@__ @touch $@ @@ -185,7 +185,7 @@ Iptc: $(SCHEMA): @echo Generating $@ table... - @echo $@ | sed "s/xmp_//" | xargs $(TAGLIST) | sed -e"s//\>/g" | awk -f xmp.awk > $@.xml + @echo $@ | sed "s/xmp_//" | xargs $(TAGLIST) | sed -e"s//\>/g" | python3 xmp.py > $@.xml @xsltproc xmp.xsl $@.xml > $@.tmp @sed "s/report1/$@/" $@.tmp > __$@__ @touch $@ diff --git a/doc/templates/iptc.awk b/doc/templates/iptc.awk deleted file mode 100644 index c1b8e505..00000000 --- a/doc/templates/iptc.awk +++ /dev/null @@ -1,47 +0,0 @@ -################################################################################ -# File : iptc.awk -# Author(s): Andreas Huggel (ahu) -# History : 07-Feb-04, ahu: created -# -# Description: -# Awk script to convert a taglist to XML format used in the documentation. -# $ taglist [SectionName] | awk -f iptc.awk > iptc.xml -################################################################################ - -BEGIN { - FS = ", " - print ""; - print ""; - - print "" - print "
" - print "Iptc datasets defined in Exiv2" - print "" - print "

Datasets are defined according to the specification of the Iptc " - print "Information Interchange Model (IIM).

" - print "

Click on a column header to sort the table.

" - print "
" - print "
" - print "" -} - -{ - print " "; - print " " $1 "" - print " " $2 "" - print " " $3 "" - print " " $4 "" - print " " $5 "" - print " " $6 "" - print " " $7 "" - print " " $8 "" - print " " $9 "" - print " " $10 "" - print " " $11 "" - print " "; -} - -END { - print "" - print "
" -} diff --git a/doc/templates/iptc.py b/doc/templates/iptc.py new file mode 100755 index 00000000..09609d88 --- /dev/null +++ b/doc/templates/iptc.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +import sys +import csv + +print(""" + + +
+Iptc datasets defined in Exiv2 + +

Datasets are defined according to the specification of the Iptc +Information Interchange Model (IIM).

+

Click on a column header to sort the table.

+
+
+""") + +row=0 +data = sys.stdin.readlines() +for line in csv.reader(data,quotechar='"',skipinitialspace=True): + row=row+1 + print(" " % row) + print(" " + line[ 0] + "") + print(" " + line[ 1] + "") + print(" " + line[ 2] + "") + print(" " + line[ 3] + "") + print(" " + line[ 4] + "") + print(" " + line[ 5] + "") + print(" " + line[ 6] + "") + print(" " + line[ 7] + "") + print(" " + line[ 8] + "") + print(" " + line[ 9] + "") + print(" " + line[10] + "") + print(" ") + +print("") +print("
") + diff --git a/doc/templates/tags.awk b/doc/templates/tags.awk deleted file mode 100644 index 04010feb..00000000 --- a/doc/templates/tags.awk +++ /dev/null @@ -1,43 +0,0 @@ -################################################################################ -# File : tags.awk -# Author(s): Andreas Huggel (ahu) -# History : 07-Feb-04, ahu: created -# -# Description: -# Awk script to convert a taglist to XML format used in the documentation. -# $ taglist [itemName] | awk -f tags.awk > tags.xml -################################################################################ - -BEGIN { - FS = ", " # ,\t - print ""; - print ""; - - print "" - print "
" - print "XYZ MakerNote Tags defined in Exiv2" - print "" - print "

Tags found in the MakerNote of images taken with XYZ cameras. These tags " - print "are defined by Exiv2 in accordance with [X].

" - print "

Click on a column header to sort the table.

" - print "
" - print "
" - print "" -} - -{ - print " "; - print " " $1 "" - print " " $2 "" - print " " $3 "" - print " " $4 "" - print " " $5 "" - print " " $6 "" - print " " $7 "" - print " "; -} - -END { - print "" - print "
" -} diff --git a/doc/templates/tags.py b/doc/templates/tags.py new file mode 100755 index 00000000..60d99c3a --- /dev/null +++ b/doc/templates/tags.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import sys +import csv + +print(""" + + +
+XYZ MakerNote Tags defined in Exiv2 + +

Tags found in the MakerNote of images taken with XYZ cameras. These tags +are defined by Exiv2 in accordance with [X].

+

Click on a column header to sort the table.

+
+
+""") + +row=0 +data = sys.stdin.readlines() +for line in csv.reader(data,quotechar='"',skipinitialspace=True): + row=row+1 + print(" " % row) + print(" " + line[0] + "") + print(" " + line[1] + "") + print(" " + line[2] + "") + print(" " + line[3] + "") + print(" " + line[4] + "") + print(" " + line[5] + "") + print(" " + line[6] + "") + print(" ") + +print("") +print("
") + diff --git a/doc/templates/xmp.awk b/doc/templates/xmp.awk deleted file mode 100644 index d3114c69..00000000 --- a/doc/templates/xmp.awk +++ /dev/null @@ -1,42 +0,0 @@ -################################################################################ -# File : xmp.awk -# Author(s): Andreas Huggel (ahu) -# History : 23-Nov-07, ahu: created -# -# Description: -# Awk script to convert an XMP property list to XML format used in the -# documentation. -# $ taglist [xmpList] | awk -f xmp.awk > [xmpList].xml -################################################################################ - -BEGIN { - FS = ", " # ,\t - print ""; - print ""; - - print "" - print "
" - print "XMP tags defined in Exiv2" - print "" - print "

Some description

" - print "

Click on a column header to sort the table.

" - print "
" - print "
" - print "" -} - -{ - print " "; - print " " $1 "" - print " " $2 "" - print " " $3 "" - print " " $4 "" - print " " $5 "" - print " " $6 "" - print " "; -} - -END { - print "" - print "
" -} diff --git a/doc/templates/xmp.py b/doc/templates/xmp.py new file mode 100755 index 00000000..df8b14d6 --- /dev/null +++ b/doc/templates/xmp.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import sys +import csv + +print(""" + + +
+XMP tags defined in Exiv2 + +

Some description

+

Click on a column header to sort the table.

+
+
+""") + +row=0 +data = sys.stdin.readlines() +print(data) +for line in csv.reader(data,quotechar='"',skipinitialspace=True): + row=row+1 + print(" " % row) + print(" " + line[0] + "") + print(" " + line[1] + "") + print(" " + line[2] + "") + print(" " + line[3] + "") + print(" " + line[4] + "") + print(" " + line[5] + "") + print(" ") + +print("") +print("
") + diff --git a/src/datasets.cpp b/src/datasets.cpp index 97042037..8837270d 100644 --- a/src/datasets.cpp +++ b/src/datasets.cpp @@ -722,8 +722,16 @@ namespace Exiv2 { << iptcKey.key() << ", " << TypeInfo::typeName( IptcDataSets::dataSetType(dataSet.number_, - dataSet.recordId_)) << ", " - << dataSet.desc_; + dataSet.recordId_)) << ", "; + // CSV encoded I am \"dead\" beat" => "I am ""dead"" beat" + char Q = '"'; + os << Q; + for ( size_t i = 0 ; i < ::strlen(dataSet.desc_) ; i++ ) { + char c = dataSet.desc_[i]; + if ( c == Q ) os << Q; + os << c; + } + os << Q; os.flags(f); return os; } diff --git a/src/properties.cpp b/src/properties.cpp index c6ebd34d..ff00bbdb 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -2837,16 +2837,27 @@ namespace Exiv2 { prefix_ = prefix; } // XmpKey::Impl::decomposeKey + // ************************************************************************* + // free functions // ************************************************************************* // free functions std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& property) { - return os << property.name_ << ",\t" - << property.title_ << ",\t" - << property.xmpValueType_ << ",\t" - << TypeInfo::typeName(property.typeId_) << ",\t" - << ( property.xmpCategory_ == xmpExternal ? "External" : "Internal" ) << ",\t" - << property.desc_ << "\n"; + os << property.name_ << "," + << property.title_ << "," + << property.xmpValueType_ << "," + << TypeInfo::typeName(property.typeId_) << "," + << ( property.xmpCategory_ == xmpExternal ? "External" : "Internal" ) << ","; + // CSV encoded I am \"dead\" beat" => "I am ""dead"" beat" + char Q = '"'; + os << Q; + for ( size_t i = 0 ; i < ::strlen(property.desc_) ; i++ ) { + char c = property.desc_[i]; + if ( c == Q ) os << Q; + os << c; + } + os << Q << std::endl; + return os; } //! @endcond diff --git a/src/tags.cpp b/src/tags.cpp index a7ec89af..25ec1e44 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -441,15 +441,22 @@ namespace Exiv2 { { std::ios::fmtflags f( os.flags() ); ExifKey exifKey(ti); - os << exifKey.tagName() << ",\t" - << std::dec << exifKey.tag() << ",\t" + os << exifKey.tagName() << "," + << std::dec << exifKey.tag() << "," << "0x" << std::setw(4) << std::setfill('0') - << std::right << std::hex << exifKey.tag() << ",\t" - << exifKey.groupName() << ",\t" - << exifKey.key() << ",\t" - << TypeInfo::typeName(exifKey.defaultTypeId()) << ",\t" - << exifKey.tagDesc(); - + << std::right << std::hex << exifKey.tag() << "," + << exifKey.groupName() << "," + << exifKey.key() << "," + << TypeInfo::typeName(exifKey.defaultTypeId()) << ","; + // CSV encoded I am \"dead\" beat" => "I am ""dead"" beat" + char Q = '"'; + os << Q; + for ( size_t i = 0 ; i < exifKey.tagDesc().size() ; i++ ) { + char c = exifKey.tagDesc()[i]; + if ( c == Q ) os << Q; + os << c; + } + os << Q; os.flags(f); return os; }