#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"))
{
}
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());
}
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
/* 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)) {
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;
}
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 ()));
}
}
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;
}
}
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 ();