4 // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 #include "addon_manager.hpp"
30 AddonManager& adm = AddonManager::get_instance();
37 AddonManager& adm = AddonManager::get_instance();
42 Addon::parse(const lisp::Lisp& lisp)
45 lisp.get("kind", kind);
46 lisp.get("title", title);
47 lisp.get("author", author);
48 lisp.get("license", license);
49 lisp.get("http-url", http_url);
50 lisp.get("file", file);
52 } catch(std::exception& e) {
53 std::stringstream msg;
54 msg << "Problem when parsing addoninfo: " << e.what();
55 throw std::runtime_error(msg.str());
60 Addon::parse(std::string fname)
64 const lisp::Lisp* root = parser.parse(fname);
65 const lisp::Lisp* addon = root->get_lisp("supertux-addoninfo");
66 if(!addon) throw std::runtime_error("file is not a supertux-addoninfo file.");
68 } catch(std::exception& e) {
69 std::stringstream msg;
70 msg << "Problem when reading addoninfo '" << fname << "': " << e.what();
71 throw std::runtime_error(msg.str());
76 Addon::write(lisp::Writer& writer) const
78 writer.start_list("supertux-addoninfo");
79 if (kind != "") writer.write_string("kind", kind);
80 if (title != "") writer.write_string("title", title);
81 if (author != "") writer.write_string("author", author);
82 if (license != "") writer.write_string("license", license);
83 if (http_url != "") writer.write_string("http-url", http_url);
84 if (file != "") writer.write_string("file", file);
85 if (md5 != "") writer.write_string("md5", md5);
86 writer.end_list("supertux-addoninfo");
90 Addon::write(std::string fname) const
92 lisp::Writer writer(fname);
97 Addon::equals(const Addon& addon2) const
99 if ((this->md5 == "") || (addon2.md5 == "")) return (this->title == addon2.title);
100 return (this->md5 == addon2.md5);