X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Flib%2Fcolour_conversion.cc;fp=src%2Flib%2Fcolour_conversion.cc;h=f1e6258122fbf3cebb7638be85e38ecedb4f8705;hb=6d95d9689831a74fade32038a808f206c03d8aa2;hp=bd1b47cb1ad43a067bf912c929d144c003eb171f;hpb=3ffd0163026be24e5373e0674c3301ed37546e44;p=dcpomatic.git diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index bd1b47cb1..f1e625812 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -151,41 +151,40 @@ ColourConversion::from_xml (cxml::NodePtr node, int version) } void -ColourConversion::as_xml (xmlpp::Node* node) const +ColourConversion::as_xml(xmlpp::Element* element) const { - auto in_node = node->add_child ("InputTransferFunction"); + auto in_node = cxml::add_child(element, "InputTransferFunction"); if (dynamic_pointer_cast (_in)) { auto tf = dynamic_pointer_cast (_in); - in_node->add_child("Type")->add_child_text ("Gamma"); - in_node->add_child("Gamma")->add_child_text (raw_convert (tf->gamma ())); + cxml::add_text_child(in_node, "Type", "Gamma"); + cxml::add_text_child(in_node, "Gamma", raw_convert(tf->gamma())); } else if (dynamic_pointer_cast (_in)) { auto tf = dynamic_pointer_cast (_in); - in_node->add_child("Type")->add_child_text ("ModifiedGamma"); - in_node->add_child("Power")->add_child_text (raw_convert (tf->power ())); - in_node->add_child("Threshold")->add_child_text (raw_convert (tf->threshold ())); - in_node->add_child("A")->add_child_text (raw_convert (tf->A ())); - in_node->add_child("B")->add_child_text (raw_convert (tf->B ())); - } else if (dynamic_pointer_cast (_in)) { - in_node->add_child("Type")->add_child_text ("SGamut3"); + cxml::add_text_child(in_node, "Type", "ModifiedGamma"); + cxml::add_text_child(in_node, "Power", raw_convert(tf->power ())); + cxml::add_text_child(in_node, "Threshold", raw_convert(tf->threshold ())); + cxml::add_text_child(in_node, "A", raw_convert(tf->A())); + cxml::add_text_child(in_node, "B", raw_convert(tf->B())); + } else if (dynamic_pointer_cast(_in)) { + cxml::add_text_child(in_node, "Type", "SGamut3"); } - node->add_child("YUVToRGB")->add_child_text (raw_convert (static_cast (_yuv_to_rgb))); - node->add_child("RedX")->add_child_text (raw_convert (_red.x)); - node->add_child("RedY")->add_child_text (raw_convert (_red.y)); - node->add_child("GreenX")->add_child_text (raw_convert (_green.x)); - node->add_child("GreenY")->add_child_text (raw_convert (_green.y)); - node->add_child("BlueX")->add_child_text (raw_convert (_blue.x)); - node->add_child("BlueY")->add_child_text (raw_convert (_blue.y)); - node->add_child("WhiteX")->add_child_text (raw_convert (_white.x)); - node->add_child("WhiteY")->add_child_text (raw_convert (_white.y)); + cxml::add_text_child(element, "YUVToRGB", raw_convert(static_cast(_yuv_to_rgb))); + cxml::add_text_child(element, "RedX", raw_convert(_red.x)); + cxml::add_text_child(element, "RedY", raw_convert(_red.y)); + cxml::add_text_child(element, "GreenX", raw_convert(_green.x)); + cxml::add_text_child(element, "GreenY", raw_convert(_green.y)); + cxml::add_text_child(element, "BlueX", raw_convert(_blue.x)); + cxml::add_text_child(element, "BlueY", raw_convert(_blue.y)); + cxml::add_text_child(element, "WhiteX", raw_convert(_white.x)); + cxml::add_text_child(element, "WhiteY", raw_convert(_white.y)); if (_adjusted_white) { - node->add_child("AdjustedWhiteX")->add_child_text (raw_convert (_adjusted_white.get().x)); - node->add_child("AdjustedWhiteY")->add_child_text (raw_convert (_adjusted_white.get().y)); + cxml::add_text_child(element, "AdjustedWhiteX", raw_convert(_adjusted_white.get().x)); + cxml::add_text_child(element, "AdjustedWhiteY", raw_convert(_adjusted_white.get().y)); } - if (dynamic_pointer_cast (_out)) { - shared_ptr gf = dynamic_pointer_cast (_out); - node->add_child("OutputGamma")->add_child_text (raw_convert (gf->gamma ())); + if (auto gf = dynamic_pointer_cast(_out)) { + cxml::add_text_child(element, "OutputGamma", raw_convert(gf->gamma())); } }