/*- * Copyright (c) 2004 Jacques A. Vidrine * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef CELABO_20040211_VUXML_HH #define CELABO_20040211_VUXML_HH #include #if !defined(__unused) #if defined(__GNUC__) #define __unused __attribute__((__unused__)) #else #define __unused #endif #endif namespace vuxml { class Logger { public: static std::ostream &log(); }; #define LOG (vuxml::Logger::log()) typedef std::map Attributes; class except : public std::exception { public: except(const char *s) throw() : what_(s) {} virtual ~except() throw() {} virtual const char *what() const throw() { return what_; } private: const char *what_; }; std::string killspace(const std::string &s); std::string xmlescape(const std::string &s); struct VersionRange { static const char infinity[]; static const char zero[]; VersionRange() : lo_closed(true), hi_closed(true), lo(zero), hi(infinity) {} bool lo_closed; bool hi_closed; std::string lo; std::string hi; bool contains(const std::string &version) const; }; struct AffectedSet { std::vector names; std::vector ranges; }; struct Reference { Reference(const std::string type_, const std::string text_) : type(type_), text(text_) {} std::string type; std::string text; }; class Entry { public: Entry(); ~Entry(); const std::string &vid() const; void setVid(const std::string &vid); const std::string &topic() const; void setTopic(const std::string &text); const std::string &description() const; void setDescription(const std::string &text); void appendDescription(const std::string &text); const std::string &discoveryDate() const; void setDiscoveryDate(const std::string &date); const std::string &entryDate() const; void setEntryDate(const std::string &date); const std::string &modifiedDate() const; void setModifiedDate(const std::string &date); const std::vector &references() const; void addReference(const Reference &reference); void addReference(const std::string &type, const std::string &text); const std::vector &affected() const; void addAffectedSet(); void addAffectedName(const std::string &name); void addAffectedRange(const VersionRange &range); private: std::string vid_; std::string topic_; std::string description_; std::string discovery_; std::string entry_; std::string modified_; std::vector references_; std::vector affected_; }; class EntryProcessor : public std::unary_function { public: EntryProcessor(); virtual ~EntryProcessor(); virtual bool operator()(const Entry &entry) = 0; virtual void start(); virtual void end(); }; extern "C" int version_cmp(const char *, const char *); } #endif