skipToEntityType

Skips entities until the given EntityType is reached.

If multiple EntityTypes are given, then any one of them counts as a match.

The current entity is skipped regardless of whether it is the given EntityType.

This is essentially a slightly optimized equivalent to

if(!range.empty())
{
    range.popFront();
    range = range.find!((a, b) => a.type == b.type)(entityTypes);
}
R
skipToEntityType
(
R
)
if (
isInstanceOf!(EntityRange, R)
)

Return Value

Type: R

The given range with its front now at the first entity which matched one of the given EntityTypes or an empty range if none were found.

Throws

XMLParsingException on invalid XML.

Examples

auto xml = "<root>\n" ~
           "    <!-- blah blah blah -->\n" ~
           "    <foo>nothing to say</foo>\n" ~
           "</root>";

auto range = parseXML(xml);
assert(range.front.type == EntityType.elementStart);
assert(range.front.name == "root");

range = range.skipToEntityType(EntityType.elementStart,
                               EntityType.elementEmpty);
assert(range.front.type == EntityType.elementStart);
assert(range.front.name == "foo");

assert(range.skipToEntityType(EntityType.comment).empty);

// skipToEntityType will work on an empty range but will always
// return an empty range.
assert(range.takeNone().skipToEntityType(EntityType.comment).empty);

Meta