]> git.lyx.org Git - lyx.git/blobdiff - src/xml.h
Update Win installer for new dictionary links. Untested.
[lyx.git] / src / xml.h
index b3569baa79ec211c094efa8e9645e450b52c3167..346e42d78cd803d9cf99c7a06afd9db3058d9670 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
@@ -31,6 +31,7 @@ namespace xml {
 struct StartTag;
 struct EndTag;
 struct CompTag;
+struct NullTag;
 struct ParTag;
 struct FontTag;
 struct CR;
@@ -67,6 +68,8 @@ public:
        ///
        XMLStream & operator<<(char);
        ///
+       XMLStream & operator<<(xml::NullTag const &);
+       ///
        XMLStream & operator<<(xml::StartTag const &);
        ///
        XMLStream & operator<<(xml::EndTag const &);
@@ -143,6 +146,7 @@ namespace xml {
 docstring escapeChar(char_type c, XMLStream::EscapeSettings e);
 
 /// Escape the given character, if necessary, to an entity.
+/// \param c must be ASCII
 docstring escapeChar(char c, XMLStream::EscapeSettings e);
 
 /// Escape a word instead of a single character
@@ -151,9 +155,6 @@ docstring escapeString(docstring const & raw, XMLStream::EscapeSettings e=XMLStr
 /// cleans \param str for use as an attribute by replacing all non-altnum by "_"
 docstring cleanAttr(docstring const & str);
 
-/// \p c must be ASCII
-docstring escapeChar(char c, XMLStream::EscapeSettings e);
-
 /// replaces illegal characters from ID attributes
 docstring cleanID(docstring const &orig);
 
@@ -198,14 +199,6 @@ struct StartTag
        ///
        virtual FontTag const * asFontTag() const { return nullptr; }
        ///
-       virtual bool operator==(StartTag const & rhs) const
-       { return tag_ == rhs.tag_; }
-       ///
-       virtual bool operator!=(StartTag const & rhs) const
-       { return !(*this == rhs); }
-       ///
-       virtual bool operator==(FontTag const & rhs) const;
-       ///
        docstring tag_;
        ///
        docstring attr_;
@@ -231,12 +224,6 @@ struct EndTag
        /// </tag_>
        virtual docstring writeEndTag() const;
        ///
-       bool operator==(StartTag const & rhs) const
-       { return tag_ == rhs.tag_; }
-       ///
-       bool operator!=(StartTag const & rhs) const
-       { return !(*this == rhs); }
-       ///
        virtual EndFontTag const * asFontTag() const { return nullptr; }
        ///
        docstring tag_;
@@ -290,6 +277,16 @@ struct ParTag : public StartTag
 };
 
 
+/// A special tag that doesn't produce any XML output, but makes the XMLStream behave as it it output some text.
+struct NullTag : public StartTag
+{
+       ///
+       NullTag(): StartTag("NULLTAG", from_utf8(""), true) {}
+       ///
+       ~NullTag() override = default;
+};
+
+
 ///
 enum FontTypes {
        // ranges
@@ -344,8 +341,6 @@ struct FontTag : public StartTag
        ///
        FontTag const * asFontTag() const override { return this; }
        ///
-       bool operator==(StartTag const &) const override;
-       ///
        FontTypes font_type_;
 };
 
@@ -421,6 +416,15 @@ void compTag(XMLStream & xs, const std::string & tag, const docstring & attr, co
 
 } // namespace xml
 
+
+/// Comparison operators for tags. They are defined as free functions, otherwise comparison of casts does not work.
+/// For font tags, do not only compare the XML tag, but also the font type: several fonts can be using the same tag.
+/// In XHTML, <span>; in DocBook, <emphasis>.
+bool operator==(xml::StartTag const & lhs, xml::StartTag const & rhs);
+bool operator==(xml::EndTag const & lhs, xml::StartTag const & rhs);
+bool operator!=(xml::EndTag const & lhs, xml::StartTag const & rhs);
+bool operator!=(xml::StartTag const & lhs, xml::StartTag const & rhs);
+
 } // namespace lyx
 
 #endif // XML_H