Tweaks: don't use shared_ptr for dcp::SubtitleString; SubtitleContent::write_xml...
[libdcp.git] / src / subtitle_content.h
index 410c5934a23cb1a4b96f07a2a95f2583a9d586bb..c00c3f310a650197e3abf502c1d3327b14156d40 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "content.h"
 #include "dcp_time.h"
+#include "subtitle_string.h"
 #include <libcxml/cxml.h>
 
 namespace dcp
@@ -34,12 +35,19 @@ class Subtitle;
 class LoadFont;
 
 /** @class SubtitleContent
- *  @brief A representation of an XML file containing subtitles.
+ *  @brief A representation of an XML or MXF file containing subtitles.
+ *
+ *  XXX: perhaps this should inhert from MXF, or there should be different
+ *  classes for XML and MXF subs.
  */
 class SubtitleContent : public Content
 {
 public:
-       SubtitleContent (boost::filesystem::path file);
+       /** Construct a SubtitleContent.
+        *  @param file Filename.
+        *  @param mxf true if the file is an MXF file, false for XML.
+        */
+       SubtitleContent (boost::filesystem::path file, bool mxf);
        SubtitleContent (Fraction edit_rate, std::string movie_title, std::string language);
 
        bool equals (
@@ -48,7 +56,7 @@ public:
                boost::function<void (NoteType, std::string)> note
                ) const {
                /* XXX */
-               note (ERROR, "subtitle content not compared yet");
+               note (DCP_ERROR, "subtitle content not compared yet");
                return true;
        }
 
@@ -56,14 +64,14 @@ public:
                return _language;
        }
 
-       std::list<boost::shared_ptr<SubtitleString> > subtitles_at (Time t) const;
-       std::list<boost::shared_ptr<SubtitleString> > const & subtitles () const {
+       std::list<SubtitleString> subtitles_at (Time t) const;
+       std::list<SubtitleString> const & subtitles () const {
                return _subtitles;
        }
 
-       void add (boost::shared_ptr<SubtitleString>);
+       void add (SubtitleString);
 
-       void write_xml () const;
+       void write_xml (boost::filesystem::path) const;
        Glib::ustring xml_as_string () const;
 
 protected:
@@ -98,13 +106,13 @@ private:
                ParseState& parse_state
                );
 
-       std::string _movie_title;
+       boost::optional<std::string> _movie_title;
        /* strangely, this is sometimes a string */
        std::string _reel_number;
        std::string _language;
        std::list<boost::shared_ptr<LoadFont> > _load_font_nodes;
 
-       std::list<boost::shared_ptr<SubtitleString> > _subtitles;
+       std::list<SubtitleString> _subtitles;
        bool _need_sort;
 };