~ubuntu-branches/ubuntu/precise/exiv2/precise

« back to all changes in this revision

Viewing changes to src/value.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-07-09 19:43:59 UTC
  • mfrom: (1.1.12 upstream) (11.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100709194359-7w1hbf33l7d2rgmq
Tags: 0.20-2
Upload to unstable - cleared with debian-release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ***************************************************************** -*- C++ -*-
2
2
/*
3
 
 * Copyright (C) 2004-2009 Andreas Huggel <ahuggel@gmx.net>
 
3
 * Copyright (C) 2004-2010 Andreas Huggel <ahuggel@gmx.net>
4
4
 *
5
5
 * This program is part of the Exiv2 distribution.
6
6
 *
21
21
/*!
22
22
  @file    value.hpp
23
23
  @brief   Value interface and concrete subclasses
24
 
  @version $Rev: 1937 $
 
24
  @version $Rev: 2073 $
25
25
  @author  Andreas Huggel (ahu)
26
26
           <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
27
27
  @date    09-Jan-04, ahu: created
529
529
            const char* code_;                      //!< Code of the charset
530
530
        }; // struct CharsetTable
531
531
        //! Charset information lookup functions. Implemented as a static class.
532
 
        class CharsetInfo {
 
532
        class EXIV2API CharsetInfo {
533
533
            //! Prevent construction: not implemented.
534
534
            CharsetInfo() {}
535
535
            //! Prevent copy-construction: not implemented.
566
566
 
567
567
        //! @name Manipulators
568
568
        //@{
569
 
        using StringValueBase::read;
570
569
        /*!
571
570
          @brief Read the value from a comment
572
571
 
580
579
                  1 if an invalid character set is encountered
581
580
        */
582
581
        int read(const std::string& comment);
 
582
        /*!
 
583
          @brief Read the comment from a byte buffer.
 
584
         */
 
585
        int read(const byte* buf, long len, ByteOrder byteOrder);
583
586
        //@}
584
587
 
585
588
        //! @name Accessors
586
589
        //@{
587
590
        AutoPtr clone() const { return AutoPtr(clone_()); }
 
591
        long copy(byte* buf, ByteOrder byteOrder) const;
588
592
        /*!
589
593
          @brief Write the comment in a format which can be read by
590
594
          read(const std::string& comment).
591
595
         */
592
596
        std::ostream& write(std::ostream& os) const;
593
 
        //! Return the comment (without a charset="..." prefix)
594
 
        std::string comment() const;
595
 
        //! Return the charset id of the comment
 
597
        /*!
 
598
          @brief Return the comment (without a charset="..." prefix)
 
599
 
 
600
          The comment is decoded to UTF-8. For Exif UNICODE comments, the
 
601
          function makes an attempt to correctly determine the character
 
602
          encoding of the value. Alternatively, the optional \em encoding
 
603
          parameter can be used to specify it.
 
604
 
 
605
          @param encoding Optional argument to specify the character encoding
 
606
              that the comment is encoded in, as an iconv(3) name. Only used
 
607
              for Exif UNICODE comments.
 
608
 
 
609
          @return A string containing the comment converted to UTF-8.
 
610
         */
 
611
        std::string comment(const char* encoding =0) const;
 
612
        /*!
 
613
          @brief Determine the character encoding that was used to encode the
 
614
              UNICODE comment value as an iconv(3) name.
 
615
 
 
616
          If the comment \em c starts with a BOM, the BOM is interpreted and
 
617
          removed from the string.
 
618
 
 
619
          Todo: Implement rules to guess if the comment is UTF-8 encoded.
 
620
         */
 
621
        const char* detectCharset(std::string& c) const;
 
622
        //! Return the Exif charset id of the comment
596
623
        CharsetId charsetId() const;
597
624
        //@}
598
625
 
600
627
        //! Internal virtual copy constructor.
601
628
        EXV_DLLLOCAL virtual CommentValue* clone_() const;
602
629
 
 
630
    public:
 
631
        // DATA
 
632
        ByteOrder byteOrder_;      //!< Byte order of the comment string that was read
 
633
 
603
634
    }; // class CommentValue
604
635
 
605
636
    /*!
1484
1515
    {
1485
1516
        std::istringstream is(buf);
1486
1517
        T tmp;
1487
 
        value_.clear();
 
1518
        ValueList val;
1488
1519
        while (!(is.eof())) {
1489
1520
            is >> tmp;
1490
1521
            if (is.fail()) return 1;
1491
 
            value_.push_back(tmp);
 
1522
            val.push_back(tmp);
1492
1523
        }
 
1524
        value_.swap(val);
1493
1525
        return 0;
1494
1526
    }
1495
1527