diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-18 22:53:12 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-18 22:53:12 +0100 |
| commit | 2c11132af71aefb81f9e201403b1f3b9b005d0c0 (patch) | |
| tree | 054e89a5c20f04d705ca54a474bf1bd4cfc575df /src/pkl.cc | |
| parent | 8e4f704c6624c42093306918a8904e2159bde141 (diff) | |
Add some more access to PKL.
Diffstat (limited to 'src/pkl.cc')
| -rw-r--r-- | src/pkl.cc | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -42,6 +42,7 @@ using std::string; using std::shared_ptr; +using std::make_shared; using boost::optional; using namespace dcp; @@ -68,15 +69,15 @@ PKL::PKL (boost::filesystem::path file) _issuer = pkl.string_child ("Issuer"); _creator = pkl.string_child ("Creator"); - BOOST_FOREACH (cxml::ConstNodePtr i, pkl.node_child("AssetList")->node_children("Asset")) { - _asset_list.push_back (shared_ptr<Asset> (new Asset (i))); + for (auto i: pkl.node_child("AssetList")->node_children("Asset")) { + _asset_list.push_back (make_shared<Asset>(i)); } } void PKL::add_asset (std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type) { - _asset_list.push_back (shared_ptr<Asset> (new Asset (id, annotation_text, hash, size, type))); + _asset_list.push_back (make_shared<Asset>(id, annotation_text, hash, size, type)); } void @@ -98,16 +99,16 @@ PKL::write (boost::filesystem::path file, shared_ptr<const CertificateChain> sig pkl->add_child("Issuer")->add_child_text (_issuer); pkl->add_child("Creator")->add_child_text (_creator); - xmlpp::Element* asset_list = pkl->add_child("AssetList"); - BOOST_FOREACH (shared_ptr<Asset> i, _asset_list) { - xmlpp::Element* asset = asset_list->add_child("Asset"); + auto asset_list = pkl->add_child("AssetList"); + for (auto i: _asset_list) { + auto asset = asset_list->add_child("Asset"); asset->add_child("Id")->add_child_text ("urn:uuid:" + i->id()); - if (i->annotation_text) { - asset->add_child("AnnotationText")->add_child_text (*i->annotation_text); + if (i->annotation_text()) { + asset->add_child("AnnotationText")->add_child_text (*i->annotation_text()); } - asset->add_child("Hash")->add_child_text (i->hash); - asset->add_child("Size")->add_child_text (raw_convert<string> (i->size)); - asset->add_child("Type")->add_child_text (i->type); + asset->add_child("Hash")->add_child_text (i->hash()); + asset->add_child("Size")->add_child_text (raw_convert<string>(i->size())); + asset->add_child("Type")->add_child_text (i->type()); } indent (pkl, 0); @@ -123,23 +124,23 @@ PKL::write (boost::filesystem::path file, shared_ptr<const CertificateChain> sig optional<string> PKL::hash (string id) const { - BOOST_FOREACH (shared_ptr<Asset> i, _asset_list) { + for (auto i: _asset_list) { if (i->id() == id) { - return i->hash; + return i->hash(); } } - return optional<string>(); + return {}; } optional<string> PKL::type (string id) const { - BOOST_FOREACH (shared_ptr<Asset> i, _asset_list) { + for (auto i: _asset_list) { if (i->id() == id) { - return i->type; + return i->type(); } } - return optional<string>(); + return {}; } |
