diff --git a/source/cartastraccia/rss.d b/source/cartastraccia/rss.d index 0c69852..b2235d2 100644 --- a/source/cartastraccia/rss.d +++ b/source/cartastraccia/rss.d @@ -127,6 +127,18 @@ private: +static immutable string selectElementName = " + string elname; + + static if(is(ElementType == RSSChannel)) { + elname = \"channel\"; + static assert(is(Parent == RSS)); + } else if(is(ElementType == RSSItem)) { + elname = \"item\"; + static assert(is(Parent == RSSChannel)); + } else assert(false, \"Invalid ElementType provided\"); +"; + /** * Insert an element (RSSChannel or RSSItem) which has: * - A parent (be it the RSS xml root (RSSChannel @@ -139,15 +151,7 @@ { ElementType newElement; - string elname; - - static if(is(ElementType == RSSChannel)) { - elname = "channel"; - static assert(is(Parent == RSS)); - } else if(is(ElementType == RSSItem)) { - elname = "item"; - static assert(is(Parent == RSSChannel)); - } else assert(false, "Invalid ElementType provided"); + mixin(selectElementName); while(rssRange.front.type != EntityType.elementEnd && rssRange.front.type != EntityType.text @@ -164,10 +168,6 @@ rss = InvalidRSS(name, ""); } - } else if(name.startsWith("atom")){ - - logDebug("Skipping atom link identifier: " ~ name); - } else if(rssRange.front.type == EntityType.text || rssRange.front.type == EntityType.cdata) { @@ -196,9 +196,7 @@ break fill; } - } else { - assert(false, "Invalid ElementType requested"); - } + } else assert(false, "Invalid ElementType requested"); } }