diff --git a/src/nikonmn.cpp b/src/nikonmn.cpp index 28f2508e..767aad78 100644 --- a/src/nikonmn.cpp +++ b/src/nikonmn.cpp @@ -2488,6 +2488,7 @@ fmountlens[] = { const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); if (value.count() != 1 || value.typeId() != unsignedByte || value.toLong() == 0 || value.toLong() == 255) { return os << "(" << value << ")"; } @@ -2495,6 +2496,7 @@ fmountlens[] = { oss.copyfmt(os); os << std::fixed << std::setprecision(2) << value.toLong() << " Hz"; os.copyfmt(oss); + os.flags(f); return os; } @@ -2502,6 +2504,7 @@ fmountlens[] = { const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); if (value.count() != 1 || value.typeId() != unsignedByte || value.toLong() == 0 || value.toLong() == 255) { return os << "(" << value << ")"; } @@ -2509,6 +2512,7 @@ fmountlens[] = { oss.copyfmt(os); os << std::fixed << std::setprecision(2) << value.toLong(); os.copyfmt(oss); + os.flags(f); return os; } diff --git a/src/olympusmn.cpp b/src/olympusmn.cpp index 8820a1d6..88b2ce42 100644 --- a/src/olympusmn.cpp +++ b/src/olympusmn.cpp @@ -1174,6 +1174,7 @@ namespace Exiv2 { std::ostream& OlympusMakerNote::print0x0204(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags of( os.flags() ); if ( value.count() == 0 || value.toRational().second == 0) { return os << "(" << value << ")"; @@ -1184,6 +1185,7 @@ namespace Exiv2 { oss.copyfmt(os); os << std::fixed << std::setprecision(1) << f << "x"; os.copyfmt(oss); + os.flags(of); return os; } // OlympusMakerNote::print0x0204 diff --git a/src/panasonicmn.cpp b/src/panasonicmn.cpp index cbfe7bdf..7f8624eb 100644 --- a/src/panasonicmn.cpp +++ b/src/panasonicmn.cpp @@ -320,12 +320,14 @@ namespace Exiv2 { const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); std::ostringstream oss; oss.copyfmt(os); os << std::fixed << std::setprecision(1) << value.toLong() / 3 << _(" EV"); os.copyfmt(oss); + os.flags(f); return os; } // PanasonicMakerNote::print0x0023 diff --git a/src/pentaxmn_int.hpp b/src/pentaxmn_int.hpp index 2aba980a..26f94658 100644 --- a/src/pentaxmn_int.hpp +++ b/src/pentaxmn_int.hpp @@ -93,6 +93,7 @@ namespace Exiv2 { template std::ostream& printCombiTag(std::ostream& os, const Value& value, const ExifData* metadata) { + std::ios::fmtflags f( os.flags() ); if ((value.count() != count && (value.count() < (count + ignoredcount) || value.count() > (count + ignoredcountmax))) || count > 4) { return printValue(os, value, metadata); } @@ -113,6 +114,7 @@ namespace Exiv2 { << std::hex << l << std::dec << ")"; } + os.flags(f); return os; } diff --git a/src/samsungmn.cpp b/src/samsungmn.cpp index 9559f548..6f302fe3 100644 --- a/src/samsungmn.cpp +++ b/src/samsungmn.cpp @@ -90,6 +90,7 @@ namespace Exiv2 { //! Print the 35mm focal length std::ostream& printFocalLength35(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); if (value.count() != 1 || value.typeId() != unsignedLong) { return os << value; } @@ -103,6 +104,7 @@ namespace Exiv2 { os << std::fixed << std::setprecision(1) << length / 10.0 << " mm"; os.copyfmt(oss); } + os.flags(f); return os; } diff --git a/src/tags.cpp b/src/tags.cpp index 08558d81..927d718e 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -2277,6 +2277,7 @@ namespace Exiv2 { std::ostream& printDegrees(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); if (value.count() == 3) { std::ostringstream oss; oss.copyfmt(os); @@ -2301,7 +2302,7 @@ namespace Exiv2 { else { os << value; } - + os.flags(f); return os; } // printDegrees @@ -2348,6 +2349,7 @@ namespace Exiv2 { std::ostream& print0x0006(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); std::ostringstream oss; oss.copyfmt(os); const int32_t d = value.toRational().second; @@ -2356,11 +2358,13 @@ namespace Exiv2 { os << std::fixed << std::setprecision(p) << value.toFloat() << " m"; os.copyfmt(oss); + os.flags(f); return os; } std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); if (value.count() == 3) { for (int i = 0; i < 3; ++i) { if (value.toRational(i).second == 0) { @@ -2390,6 +2394,7 @@ namespace Exiv2 { os << value; } + os.flags(f); return os; } @@ -2472,6 +2477,7 @@ namespace Exiv2 { std::ostream& print0x829d(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); Rational fnumber = value.toRational(); if (fnumber.second != 0) { std::ostringstream oss; @@ -2483,6 +2489,7 @@ namespace Exiv2 { else { os << "(" << value << ")"; } + os.flags(f); return os; } @@ -2529,6 +2536,7 @@ namespace Exiv2 { std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); if ( value.count() == 0 || value.toRational().second == 0) { return os << "(" << value << ")"; @@ -2537,6 +2545,7 @@ namespace Exiv2 { oss.copyfmt(os); os << "F" << std::setprecision(2) << fnumber(value.toFloat()); os.copyfmt(oss); + os.flags(f); return os; } @@ -2564,6 +2573,7 @@ namespace Exiv2 { std::ostream& print0x9206(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); Rational distance = value.toRational(); if (distance.first == 0) { os << _("Unknown"); @@ -2582,6 +2592,7 @@ namespace Exiv2 { else { os << "(" << value << ")"; } + os.flags(f); return os; } @@ -2597,6 +2608,7 @@ namespace Exiv2 { std::ostream& print0x920a(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); Rational length = value.toRational(); if (length.second != 0) { std::ostringstream oss; @@ -2609,6 +2621,7 @@ namespace Exiv2 { else { os << "(" << value << ")"; } + os.flags(f); return os; } @@ -2661,6 +2674,7 @@ namespace Exiv2 { std::ostream& print0xa404(std::ostream& os, const Value& value, const ExifData*) { + std::ios::fmtflags f( os.flags() ); Rational zoom = value.toRational(); if (zoom.second == 0) { os << _("Digital zoom not used"); @@ -2672,6 +2686,7 @@ namespace Exiv2 { << (float)zoom.first / zoom.second; os.copyfmt(oss); } + os.flags(f); return os; } @@ -3109,15 +3124,19 @@ namespace Exiv2 { std::ostream& operator<<(std::ostream& os, const TagInfo& ti) { + std::ios::fmtflags f( os.flags() ); ExifKey exifKey(ti); - return os << exifKey.tagName() << ",\t" - << std::dec << exifKey.tag() << ",\t" - << "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(); + os << exifKey.tagName() << ",\t" + << std::dec << exifKey.tag() << ",\t" + << "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(); + + os.flags(f); + return os; } } // namespace Exiv2 diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index cb858352..39126783 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -2050,6 +2050,7 @@ namespace Exiv2 { void TiffHeaderBase::print(std::ostream& os, const std::string& prefix) const { + std::ios::fmtflags f( os.flags() ); os << prefix << _("TIFF header, offset") << " = 0x" << std::setw(8) << std::setfill('0') << std::hex << std::right @@ -2061,6 +2062,7 @@ namespace Exiv2 { case invalidByteOrder: break; } os << "\n"; + os.flags(f); } // TiffHeaderBase::print ByteOrder TiffHeaderBase::byteOrder() const diff --git a/src/types.cpp b/src/types.cpp index 6b77e8f9..c5a70151 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -444,6 +444,7 @@ namespace Exiv2 { { const std::string::size_type pos = 8 + 16 * 3 + 2; const std::string align(pos, ' '); + std::ios::fmtflags f( os.flags() ); long i = 0; while (i < len) { @@ -461,6 +462,7 @@ namespace Exiv2 { os << (width > pos ? "" : align.substr(width)) << ss.str() << "\n"; } os << std::dec << std::setfill(' '); + os.flags(f); } // hexdump bool isHex(const std::string& str, size_t size, const std::string& prefix)