Hide Font members behind accessors.
authorCarl Hetherington <cth@carlh.net>
Tue, 9 Jun 2015 15:18:00 +0000 (16:18 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 9 Jun 2015 15:18:00 +0000 (16:18 +0100)
src/lib/font.cc
src/lib/font.h
src/lib/writer.cc
src/wx/fonts_dialog.cc
src/wx/hints_dialog.cc
test/srt_subtitle_test.cc

index 5cf30a2aae370704d985fc6fe31c102f0fcfaad3..0e1ad85cdf2bb6a248b6e75d770c442cfbcc2a2b 100644 (file)
@@ -21,8 +21,8 @@
 #include <libxml++/libxml++.h>
 
 Font::Font (cxml::NodePtr node)
-       : id (node->string_child ("Id"))
-       , file (node->optional_string_child ("File"))
+       : _id (node->string_child ("Id"))
+       , _file (node->optional_string_child ("File"))
 {
        
 }
@@ -30,14 +30,14 @@ Font::Font (cxml::NodePtr node)
 void
 Font::as_xml (xmlpp::Node* node)
 {
-       node->add_child("Id")->add_child_text (id);
-       if (file) {
-               node->add_child("File")->add_child_text (file.get().string ());
+       node->add_child("Id")->add_child_text (_id);
+       if (_file) {
+               node->add_child("File")->add_child_text (_file.get().string ());
        }
 }
 
 bool
 operator!= (Font const & a, Font const & b)
 {
-       return (a.id != b.id || a.file != b.file);
+       return (a.id() != b.id() || a.file() != b.file());
 }
index 8021ab5bc662e59bc918a48fdf3bea18631637cd..0dedf7e493f52071b354be8309418df1f6195a83 100644 (file)
 class Font
 {
 public:
-       Font (std::string id_)
-               : id (id_) {}
+       Font (std::string id)
+               : _id (id) {}
 
        Font (cxml::NodePtr node);
 
        void as_xml (xmlpp::Node* node);
-       
+
+       std::string id () const {
+               return _id;
+       }
+
+       boost::optional<boost::filesystem::path> file () const {
+               return _file;
+       }
+
+       void set_file (boost::filesystem::path file) {
+               _file = file;
+       }
+
+private:       
        /** Font ID, used to describe it in the subtitle content */
-       std::string id;
-       boost::optional<boost::filesystem::path> file;
+       std::string _id;
+       boost::optional<boost::filesystem::path> _file;
 };
 
 bool
index 7e47c317ee7ff09f8226b26f04e558168de84f73..289f10c424e3e649fa2cd10a5132e2558f55c863 100644 (file)
@@ -521,7 +521,7 @@ Writer::finish ()
 
                /* Add all the fonts to the subtitle content */
                BOOST_FOREACH (shared_ptr<Font> i, _fonts) {
-                       _subtitle_asset->add_font (i->id, i->file.get_value_or (liberation));
+                       _subtitle_asset->add_font (i->id(), i->file().get_value_or (liberation));
                }
 
                if (dynamic_pointer_cast<dcp::InteropSubtitleAsset> (_subtitle_asset)) {
index 22078dafdcdf7b5078f21cd7dd745cec2ca3285c..aa9fd1540a2b8d67f217aa40c45a98b33abd4e06 100644 (file)
@@ -93,9 +93,9 @@ FontsDialog::setup ()
                wxListItem item;
                item.SetId (n);
                _fonts->InsertItem (item);
-               _fonts->SetItem (n, 0, std_to_wx ((*i)->id));
-               if ((*i)->file) {
-                       _fonts->SetItem (n, 1, (*i)->file.get().leaf().string ());
+               _fonts->SetItem (n, 0, std_to_wx ((*i)->id ()));
+               if ((*i)->file ()) {
+                       _fonts->SetItem (n, 1, (*i)->file().get().leaf().string ());
                }
                ++n;
        }
@@ -129,8 +129,8 @@ FontsDialog::set_file_clicked ()
 
        list<shared_ptr<Font> > fonts = content->fonts ();
        for (list<shared_ptr<Font> >::iterator i = fonts.begin(); i != fonts.end(); ++i) {
-               if ((*i)->id == id) {
-                       (*i)->file = wx_to_std (d->GetPath ());
+               if ((*i)->id() == id) {
+                       (*i)->set_file (wx_to_std (d->GetPath ()));
                }
        }
 
index 83b4ece84ddbe639d201fc971f11855b9bf8040f..d275971437fd508f6332f70b84442c73d60d3cff 100644 (file)
@@ -79,7 +79,7 @@ HintsDialog::film_changed ()
                        shared_ptr<SubtitleContent> s = dynamic_pointer_cast<SubtitleContent> (i);
                        if (s) {
                                BOOST_FOREACH (shared_ptr<Font> j, s->fonts ()) {
-                                       if (j->file && boost::filesystem::file_size (j->file.get ()) >= (640 * 1024)) {
+                                       if (j->file() && boost::filesystem::file_size (j->file().get ()) >= (640 * 1024)) {
                                                big_font_files = true;
                                        }
                                }
index 4497e400086d98b43199f7dce674db497eb6701a..fd9632a31d444b537ab9fe2631158aad3b429460 100644 (file)
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test2)
 
        content->set_use_subtitles (true);
        /* Use test/data/subrip2.srt as if it were a font file  */
-       content->fonts().front()->file = "test/data/subrip2.srt";
+       content->fonts().front()->set_file ("test/data/subrip2.srt");
        
        film->make_dcp ();
        wait_for_jobs ();