Exiv2::CommentValue Class Reference

Value for an Exif comment. More...

#include <value.hpp>

Inheritance diagram for Exiv2::CommentValue:
Inheritance graph
[legend]
Collaboration diagram for Exiv2::CommentValue:
Collaboration graph
[legend]

List of all members.

Classes

class  CharsetInfo
 Charset information lookup functions. Implemented as a static class. More...
struct  CharsetTable
 Information pertaining to the defined character sets. More...

Public Types

enum  CharsetId {
  ascii, jis, unicode, undefined,
  invalidCharsetId, lastCharsetId
}
 

Character set identifiers for the character sets defined by Exif.


typedef std::auto_ptr
< CommentValue
AutoPtr
 Shortcut for a CommentValue auto pointer.

Public Member Functions

Creators

 CommentValue ()
 Default constructor.
 CommentValue (const std::string &comment)
 Constructor, uses read(const std::string& comment).
virtual ~CommentValue ()
 Virtual destructor.
Manipulators

int read (const std::string &comment)
 Read the value from a comment.
int read (const byte *buf, long len, ByteOrder byteOrder)
 Read the comment from a byte buffer.
Accessors

AutoPtr clone () const
 Return an auto-pointer to a copy of itself (deep copy). The caller owns this copy and the auto-pointer ensures that it will be deleted.
long copy (byte *buf, ByteOrder byteOrder) const
 Write value to a character data buffer.
std::ostream & write (std::ostream &os) const
 Write the comment in a format which can be read by read(const std::string& comment).
std::string comment (const char *encoding=0) const
 Return the comment (without a charset="..." prefix).
const char * detectCharset (std::string &c) const
 Determine the character encoding that was used to encode the UNICODE comment value as an iconv(3) name.
CharsetId charsetId () const
 Return the Exif charset id of the comment.

Public Attributes

ByteOrder byteOrder_
 Byte order of the comment string that was read.

Detailed Description

Value for an Exif comment.

This can be a plain Ascii string or a multipe byte encoded string. The comment is expected to be encoded in the character set indicated (default undefined), but this is not checked. It is left to caller to decode and encode the string to and from readable text if that is required.


Member Function Documentation

std::string Exiv2::CommentValue::comment ( const char *  encoding = 0  )  const

Return the comment (without a charset="..." prefix).

The comment is decoded to UTF-8. For Exif UNICODE comments, the function makes an attempt to correctly determine the character encoding of the value. Alternatively, the optional encoding parameter can be used to specify it.

Parameters:
encoding Optional argument to specify the character encoding that the comment is encoded in, as an iconv(3) name. Only used for Exif UNICODE comments.
Returns:
A string containing the comment converted to UTF-8.

References charsetId(), Exiv2::convertStringCharset(), detectCharset(), Exiv2::string, and Exiv2::StringValueBase::value_.

Referenced by Exiv2::Converter::cnvExifComment(), Action::Print::printMetadatum(), Action::FixCom::run(), and write().

long Exiv2::CommentValue::copy ( byte buf,
ByteOrder  byteOrder 
) const [virtual]

Write value to a character data buffer.

The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.

Note:
The byte order is required by the interface but not used by this method, so just use the default.
Parameters:
buf Data buffer to write to.
byteOrder Byte order. Not used.
Returns:
Number of characters written.

Reimplemented from Exiv2::StringValueBase.

References byteOrder_, charsetId(), Exiv2::convertStringCharset(), Exiv2::string, and Exiv2::StringValueBase::value_.

const char * Exiv2::CommentValue::detectCharset ( std::string &  c  )  const

Determine the character encoding that was used to encode the UNICODE comment value as an iconv(3) name.

If the comment c starts with a BOM, the BOM is interpreted and removed from the string.

Todo: Implement rules to guess if the comment is UTF-8 encoded.

References byteOrder_.

Referenced by comment().

int Exiv2::CommentValue::read ( const std::string &  comment  )  [virtual]

Read the value from a comment.

The format of comment is:
[charset=["]Ascii|Jis|Unicode|Undefined["] ]comment
The default charset is Undefined.

Returns:
0 if successful
1 if an invalid character set is encountered

Reimplemented from Exiv2::StringValueBase.

References byteOrder_, charsetId(), Exiv2::CommentValue::CharsetInfo::charsetIdByName(), Exiv2::CommentValue::CharsetInfo::code(), Exiv2::convertStringCharset(), and Exiv2::string.

Referenced by CommentValue(), and read().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Tue Aug 3 15:55:22 2010 for Exiv2 by  doxygen 1.6.3