Debian Codegraph @

src/lib/EPUBManifest.cpp

raw
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libepubgen project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #include "EPUBManifest.h"
11
12 #include <cassert>
13
14 #include "EPUBPath.h"
15 #include "EPUBXMLContent.h"
16
17 namespace libepubgen
18 {
19
20 EPUBManifest::EPUBManifest()
21 : m_map()
22 {
23 }
24
25 void EPUBManifest::insert(const EPUBPath &path, const std::string &mimetype, const std::string &id, const std::string &properties)
26 {
27 if (!m_map.insert(MapType_t::value_type(path.relativeTo(EPUBPath("OEBPS/content.opf")).str(), ValueType_t(mimetype, id, properties))).second)
28 {
29 assert(!"duplicate entry!");
30 }
31 }
32
33 void EPUBManifest::writeTo(EPUBXMLContent &xml)
34 {
35 for (MapType_t::const_iterator it = m_map.begin(); m_map.end() != it; ++it)
36 {
37 librevenge::RVNGPropertyList attrs;
38 attrs.insert("href", it->first.c_str());
39 attrs.insert("media-type", std::get<0>(it->second).c_str());
40 attrs.insert("id", std::get<1>(it->second).c_str());
41 const std::string &properties = std::get<2>(it->second);
42 if (!properties.empty())
43 attrs.insert("properties", properties.c_str());
44 xml.insertEmptyElement("item", attrs);
45 }
46 }
47
48 }
49
50 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */