2016-11-16 10:35:27 +00:00
|
|
|
#include "XmlExporter.h"
|
|
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
#include <boost/property_tree/xml_parser.hpp>
|
2017-03-20 19:52:00 +00:00
|
|
|
#include <boost/version.hpp>
|
2016-11-16 10:35:27 +00:00
|
|
|
#include "exporterTools.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using boost::property_tree::ptree;
|
|
|
|
|
2016-12-29 14:17:45 +00:00
|
|
|
void XmlExporter::exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) {
|
2016-11-16 10:35:27 +00:00
|
|
|
ptree tree;
|
|
|
|
|
|
|
|
// Add metadata
|
|
|
|
tree.put("rhubarbResult.metadata.soundFile", inputFilePath.string());
|
2016-12-29 14:17:45 +00:00
|
|
|
tree.put("rhubarbResult.metadata.duration", formatDuration(animation.getRange().getDuration()));
|
2016-11-16 10:35:27 +00:00
|
|
|
|
|
|
|
// Add mouth cues
|
2016-12-29 14:17:45 +00:00
|
|
|
for (auto& timedShape : dummyShapeIfEmpty(animation, targetShapeSet)) {
|
2016-11-16 10:35:27 +00:00
|
|
|
ptree& mouthCueElement = tree.add("rhubarbResult.mouthCues.mouthCue", timedShape.getValue());
|
|
|
|
mouthCueElement.put("<xmlattr>.start", formatDuration(timedShape.getStart()));
|
|
|
|
mouthCueElement.put("<xmlattr>.end", formatDuration(timedShape.getEnd()));
|
|
|
|
}
|
|
|
|
|
2017-03-20 19:52:00 +00:00
|
|
|
#ifndef BOOST_VERSION //present in version.hpp
|
|
|
|
#error "Could not detect Boost version."
|
|
|
|
#endif
|
|
|
|
|
2016-11-16 10:35:27 +00:00
|
|
|
#if BOOST_VERSION < 105600 // Support legacy syntax
|
|
|
|
using writer_setting = boost::property_tree::xml_writer_settings<char>;
|
|
|
|
#else
|
|
|
|
using writer_setting = boost::property_tree::xml_writer_settings<string>;
|
|
|
|
#endif
|
|
|
|
write_xml(outputStream, tree, writer_setting(' ', 2));
|
|
|
|
}
|