AssetMap::AssetMap (string file)
: XMLFile (file, "AssetMap")
{
- id = string_node ("Id");
- creator = string_node ("Creator");
- volume_count = int64_node ("VolumeCount");
- issue_date = string_node ("IssueDate");
- issuer = string_node ("Issuer");
- assets = sub_nodes<AssetMapAsset> ("AssetList", "Asset");
+ id = string_child ("Id");
+ creator = string_child ("Creator");
+ volume_count = int64_child ("VolumeCount");
+ issue_date = string_child ("IssueDate");
+ issuer = string_child ("Issuer");
+ assets = type_grand_children<AssetMapAsset> ("AssetList", "Asset");
}
AssetMapAsset::AssetMapAsset (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_node ("Id");
- packing_list = optional_string_node ("PackingList");
- chunks = sub_nodes<Chunk> ("ChunkList", "Chunk");
+ id = string_child ("Id");
+ packing_list = optional_string_child ("PackingList");
+ chunks = type_grand_children<Chunk> ("ChunkList", "Chunk");
}
Chunk::Chunk (xmlpp::Node const * node)
: XMLNode (node)
{
- path = string_node ("Path");
+ path = string_child ("Path");
string const prefix = "file://";
path = path.substr (prefix.length());
}
- volume_index = optional_int64_node ("VolumeIndex");
- offset = optional_int64_node ("Offset");
- length = optional_int64_node ("Length");
+ volume_index = optional_int64_child ("VolumeIndex");
+ offset = optional_int64_child ("Offset");
+ length = optional_int64_child ("Length");
}
shared_ptr<AssetMapAsset>
CPLFile::CPLFile (string file)
: XMLFile (file, "CompositionPlaylist")
{
- id = string_node ("Id");
- annotation_text = optional_string_node ("AnnotationText");
- issue_date = string_node ("IssueDate");
- creator = optional_string_node ("Creator");
- content_title_text = string_node ("ContentTitleText");
- content_kind = kind_node ("ContentKind");
- content_version = optional_sub_node<ContentVersion> ("ContentVersion");
- ignore_node ("RatingList");
- reels = sub_nodes<CPLReel> ("ReelList", "Reel");
-
- ignore_node ("Issuer");
- ignore_node ("Signer");
- ignore_node ("Signature");
+ id = string_child ("Id");
+ annotation_text = optional_string_child ("AnnotationText");
+ issue_date = string_child ("IssueDate");
+ creator = optional_string_child ("Creator");
+ content_title_text = string_child ("ContentTitleText");
+ content_kind = kind_child ("ContentKind");
+ content_version = optional_type_child<ContentVersion> ("ContentVersion");
+ ignore_child ("RatingList");
+ reels = type_grand_children<CPLReel> ("ReelList", "Reel");
+
+ ignore_child ("Issuer");
+ ignore_child ("Signer");
+ ignore_child ("Signature");
done ();
}
ContentVersion::ContentVersion (xmlpp::Node const * node)
: XMLNode (node)
{
- id = optional_string_node ("Id");
- label_text = string_node ("LabelText");
+ id = optional_string_child ("Id");
+ label_text = string_child ("LabelText");
done ();
}
CPLReel::CPLReel (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_node ("Id");
- asset_list = sub_node<CPLAssetList> ("AssetList");
+ id = string_child ("Id");
+ asset_list = type_child<CPLAssetList> ("AssetList");
- ignore_node ("AnnotationText");
+ ignore_child ("AnnotationText");
done ();
}
CPLAssetList::CPLAssetList (xmlpp::Node const * node)
: XMLNode (node)
{
- main_picture = optional_sub_node<MainPicture> ("MainPicture");
- main_stereoscopic_picture = optional_sub_node<MainStereoscopicPicture> ("MainStereoscopicPicture");
- main_sound = optional_sub_node<MainSound> ("MainSound");
- main_subtitle = optional_sub_node<MainSubtitle> ("MainSubtitle");
+ main_picture = optional_type_child<MainPicture> ("MainPicture");
+ main_stereoscopic_picture = optional_type_child<MainStereoscopicPicture> ("MainStereoscopicPicture");
+ main_sound = optional_type_child<MainSound> ("MainSound");
+ main_subtitle = optional_type_child<MainSubtitle> ("MainSubtitle");
done ();
}
Picture::Picture (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_node ("Id");
- annotation_text = optional_string_node ("AnnotationText");
- edit_rate = fraction_node ("EditRate");
- intrinsic_duration = int64_node ("IntrinsicDuration");
- entry_point = int64_node ("EntryPoint");
- duration = int64_node ("Duration");
- frame_rate = fraction_node ("FrameRate");
+ id = string_child ("Id");
+ annotation_text = optional_string_child ("AnnotationText");
+ edit_rate = fraction_child ("EditRate");
+ intrinsic_duration = int64_child ("IntrinsicDuration");
+ entry_point = int64_child ("EntryPoint");
+ duration = int64_child ("Duration");
+ frame_rate = fraction_child ("FrameRate");
try {
- screen_aspect_ratio = fraction_node ("ScreenAspectRatio");
+ screen_aspect_ratio = fraction_child ("ScreenAspectRatio");
} catch (XMLError& e) {
/* Maybe it's not a fraction */
}
try {
- float f = float_node ("ScreenAspectRatio");
+ float f = float_child ("ScreenAspectRatio");
screen_aspect_ratio = Fraction (f * 1000, 1000);
} catch (bad_cast& e) {
}
- ignore_node ("Hash");
+ ignore_child ("Hash");
done ();
}
MainSound::MainSound (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_node ("Id");
- annotation_text = optional_string_node ("AnnotationText");
- edit_rate = fraction_node ("EditRate");
- intrinsic_duration = int64_node ("IntrinsicDuration");
- entry_point = int64_node ("EntryPoint");
- duration = int64_node ("Duration");
-
- ignore_node ("Hash");
- ignore_node ("Language");
+ id = string_child ("Id");
+ annotation_text = optional_string_child ("AnnotationText");
+ edit_rate = fraction_child ("EditRate");
+ intrinsic_duration = int64_child ("IntrinsicDuration");
+ entry_point = int64_child ("EntryPoint");
+ duration = int64_child ("Duration");
+
+ ignore_child ("Hash");
+ ignore_child ("Language");
done ();
}
MainSubtitle::MainSubtitle (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_node ("Id");
- annotation_text = optional_string_node ("AnnotationText");
- edit_rate = fraction_node ("EditRate");
- intrinsic_duration = int64_node ("IntrinsicDuration");
- entry_point = int64_node ("EntryPoint");
- duration = int64_node ("Duration");
-
- ignore_node ("Hash");
- ignore_node ("Language");
+ id = string_child ("Id");
+ annotation_text = optional_string_child ("AnnotationText");
+ edit_rate = fraction_child ("EditRate");
+ intrinsic_duration = int64_child ("IntrinsicDuration");
+ entry_point = int64_child ("EntryPoint");
+ duration = int64_child ("Duration");
+
+ ignore_child ("Hash");
+ ignore_child ("Language");
done ();
}
PKLFile::PKLFile (string file)
: XMLFile (file, "PackingList")
{
- id = string_node ("Id");
- annotation_text = string_node ("AnnotationText");
- issue_date = string_node ("IssueDate");
- issuer = string_node ("Issuer");
- creator = string_node ("Creator");
- assets = sub_nodes<PKLAsset> ("AssetList", "Asset");
+ id = string_child ("Id");
+ annotation_text = string_child ("AnnotationText");
+ issue_date = string_child ("IssueDate");
+ issuer = string_child ("Issuer");
+ creator = string_child ("Creator");
+ assets = type_grand_children<PKLAsset> ("AssetList", "Asset");
}
PKLAsset::PKLAsset (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_node ("Id");
- annotation_text = optional_string_node ("AnnotationText");
- hash = string_node ("Hash");
- size = int64_node ("Size");
- type = string_node ("Type");
- original_file_name = optional_string_node ("OriginalFileName");
+ id = string_child ("Id");
+ annotation_text = optional_string_child ("AnnotationText");
+ hash = string_child ("Hash");
+ size = int64_child ("Size");
+ type = string_child ("Type");
+ original_file_name = optional_string_child ("OriginalFileName");
}
: Asset (directory, xml)
, XMLFile (path().string(), "DCSubtitle")
{
- _subtitle_id = string_node ("SubtitleID");
- _movie_title = string_node ("MovieTitle");
- _reel_number = int64_node ("ReelNumber");
- _language = string_node ("Language");
+ _subtitle_id = string_child ("SubtitleID");
+ _movie_title = string_child ("MovieTitle");
+ _reel_number = int64_child ("ReelNumber");
+ _language = string_child ("Language");
- ignore_node ("LoadFont");
+ ignore_child ("LoadFont");
- list<shared_ptr<FontNode> > font_nodes = sub_nodes<FontNode> ("Font");
- _load_font_nodes = sub_nodes<LoadFontNode> ("LoadFont");
+ list<shared_ptr<FontNode> > font_nodes = type_children<FontNode> ("Font");
+ _load_font_nodes = type_children<LoadFontNode> ("LoadFont");
/* Now make Subtitle objects to represent the raw XML nodes
in a sane way.
throw DCPReadError ("unknown subtitle effect type");
}
effect_color = optional_color_attribute ("EffectColor");
- subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle");
- font_nodes = sub_nodes<FontNode> ("Font");
- text_nodes = sub_nodes<TextNode> ("Text");
+ subtitle_nodes = type_children<SubtitleNode> ("Subtitle");
+ font_nodes = type_children<FontNode> ("Font");
+ text_nodes = type_children<TextNode> ("Text");
}
FontNode::FontNode (list<shared_ptr<FontNode> > const & font_nodes)
{
in = time_attribute ("TimeIn");
out = time_attribute ("TimeOut");
- font_nodes = sub_nodes<FontNode> ("Font");
- text_nodes = sub_nodes<TextNode> ("Text");
+ font_nodes = type_children<FontNode> ("Font");
+ text_nodes = type_children<TextNode> ("Text");
fade_up_time = fade_time ("FadeUpTime");
fade_down_time = fade_time ("FadeDownTime");
}
v_align = BOTTOM;
}
- font_nodes = sub_nodes<FontNode> ("Font");
+ font_nodes = type_children<FontNode> ("Font");
}
list<shared_ptr<Subtitle> >
}
xmlpp::Node *
-XMLNode::xml_node (string name)
+XMLNode::node_child (string name)
{
- list<xmlpp::Node*> n = xml_nodes (name);
+ list<xmlpp::Node*> n = node_children (name);
if (n.size() > 1) {
throw XMLError ("duplicate XML tag " + name);
} else if (n.empty ()) {
}
list<xmlpp::Node*>
-XMLNode::xml_nodes (string name)
+XMLNode::node_children (string name)
{
/* XXX: using find / get_path should work here, but I can't follow
how get_path works.
}
string
-XMLNode::string_node (string name)
+XMLNode::string_child (string name)
{
- return XMLNode (xml_node (name)).content ();
+ return XMLNode (node_child (name)).content ();
}
string
-XMLNode::optional_string_node (string name)
+XMLNode::optional_string_child (string name)
{
- list<xmlpp::Node*> nodes = xml_nodes (name);
+ list<xmlpp::Node*> nodes = node_children (name);
if (nodes.size() > 2) {
throw XMLError ("duplicate XML tag " + name);
}
return "";
}
- return string_node (name);
+ return string_child (name);
}
ContentKind
-XMLNode::kind_node (string name)
+XMLNode::kind_child (string name)
{
- return content_kind_from_string (string_node (name));
+ return content_kind_from_string (string_child (name));
}
Fraction
-XMLNode::fraction_node (string name)
+XMLNode::fraction_child (string name)
{
- return Fraction (string_node (name));
+ return Fraction (string_child (name));
}
int64_t
-XMLNode::int64_node (string name)
+XMLNode::int64_child (string name)
{
- string s = string_node (name);
+ string s = string_child (name);
erase_all (s, " ");
return lexical_cast<int64_t> (s);
}
int64_t
-XMLNode::optional_int64_node (string name)
+XMLNode::optional_int64_child (string name)
{
- list<xmlpp::Node*> nodes = xml_nodes (name);
+ list<xmlpp::Node*> nodes = node_children (name);
if (nodes.size() > 2) {
throw XMLError ("duplicate XML tag " + name);
}
return 0;
}
- return int64_node (name);
+ return int64_child (name);
}
float
-XMLNode::float_node (string name)
+XMLNode::float_child (string name)
{
- return lexical_cast<float> (string_node (name));
+ cout << "float node of " << string_child(name) << " for " << name << "\n";
+ return lexical_cast<float> (string_child (name));
}
void
-XMLNode::ignore_node (string name)
+XMLNode::ignore_child (string name)
{
_taken.push_back (name);
}
XMLNode (xmlpp::Node const * node);
protected:
- std::string string_node (std::string);
- std::string optional_string_node (std::string);
- ContentKind kind_node (std::string);
- Fraction fraction_node (std::string);
- int64_t int64_node (std::string);
- int64_t optional_int64_node (std::string);
- float float_node (std::string);
- void ignore_node (std::string);
+ std::string string_child (std::string);
+ std::string optional_string_child (std::string);
+ ContentKind kind_child (std::string);
+ Fraction fraction_child (std::string);
+ int64_t int64_child (std::string);
+ int64_t optional_int64_child (std::string);
+ float float_child (std::string);
+ void ignore_child (std::string);
void done ();
Time time_attribute (std::string);
std::string content ();
template <class T>
- boost::shared_ptr<T> sub_node (std::string name) {
- return boost::shared_ptr<T> (new T (xml_node (name)));
+ boost::shared_ptr<T> type_child (std::string name) {
+ return boost::shared_ptr<T> (new T (node_child (name)));
}
template <class T>
- boost::shared_ptr<T> optional_sub_node (std::string name) {
- std::list<xmlpp::Node*> n = xml_nodes (name);
+ boost::shared_ptr<T> optional_type_child (std::string name) {
+ std::list<xmlpp::Node*> n = node_children (name);
if (n.size() > 1) {
throw XMLError ("duplicate XML tag");
} else if (n.empty ()) {
}
template <class T>
- std::list<boost::shared_ptr<T> > sub_nodes (std::string name) {
- std::list<xmlpp::Node*> n = xml_nodes (name);
+ std::list<boost::shared_ptr<T> > type_children (std::string name) {
+ std::list<xmlpp::Node*> n = node_children (name);
std::list<boost::shared_ptr<T> > r;
for (typename std::list<xmlpp::Node*>::iterator i = n.begin(); i != n.end(); ++i) {
r.push_back (boost::shared_ptr<T> (new T (*i)));
}
template <class T>
- std::list<boost::shared_ptr<T> > sub_nodes (std::string name, std::string sub) {
- XMLNode p (xml_node (name));
- return p.sub_nodes<T> (sub);
+ std::list<boost::shared_ptr<T> > type_grand_children (std::string name, std::string sub) {
+ XMLNode p (node_child (name));
+ return p.type_children<T> (sub);
}
xmlpp::Node const * _node;
private:
- xmlpp::Node* xml_node (std::string);
- std::list<xmlpp::Node*> xml_nodes (std::string);
+ xmlpp::Node* node_child (std::string);
+ std::list<xmlpp::Node*> node_children (std::string);
std::list<Glib::ustring> _taken;
};