From d1a305e30f354bed10ffffebe349ebbeea6093ff Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Thu, 1 May 2008 08:22:26 +0000 Subject: [PATCH] Added LangAltValue::toString(const std::string&) to get the value for a specific language qualifier (suggested by Marco Piovanelli). --- src/value.cpp | 10 ++++++++++ src/value.hpp | 14 +++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/value.cpp b/src/value.cpp index 96ef9b78..9e40c3a5 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -702,6 +702,16 @@ namespace Exiv2 { std::string LangAltValue::toString(long /*n*/) const { + return toString("x-default"); + } + + std::string LangAltValue::toString(const std::string& qualifier) const + { + ValueType::const_iterator i = value_.find(qualifier); + if (i != value_.end()) { + ok_ = true; + return i->second; + } ok_ = false; return ""; } diff --git a/src/value.hpp b/src/value.hpp index e95ca14f..82b5ddda 100644 --- a/src/value.hpp +++ b/src/value.hpp @@ -893,11 +893,19 @@ namespace Exiv2 { AutoPtr clone() const; virtual long count() const; /*! - @brief Return the n-th component of the value as a string. - The behaviour of this method may be undefined if there is no - n-th component. + @brief Return the text value associated with the default language + qualifier \c x-default. The parameter \em n is not used, but + it is suggested that only 0 is passed in. Returns an empty + string and sets the ok-flag to \c false if there is no + default value. */ virtual std::string toString(long n) const; + /*! + @brief Return the text value associated with the language qualifier + \em qualifier. Returns an empty string and sets the ok-flag + to \c false if there is no entry for the language qualifier. + */ + std::string toString(const std::string& qualifier) const; virtual long toLong(long n =0) const; virtual float toFloat(long n =0) const; virtual Rational toRational(long n =0) const;