consumeWhitespace
Pulls the next run of whitespace characters of the queue.
@discardableResult func consumeWhitespace() -> Bool
<return>
Pulls the next run of whitespace characters of the queue.
@discardableResult func consumeWhitespace() -> Bool
<return>
import SwiftSoup
class TokenQueue
@frozen struct Bool
A value type whose instances are either true
or false
.
init(_ data: String)
Create a new TokenQueue.
static func unescape(_ input: String) -> String
Unescaped a \ escaped string.
func addFirst(_ c: Character)
Add a character to the start of the queue (will be the next character retrieved).
func addFirst(_ seq: String)
Add a string to the start of the queue.
func advance()
Drops the next character off the queue.
func chompBalanced(_ open: Character, _ close: Character) -> String
Pulls a balanced string off the queue. E.g. if queue is “(one (two) three) four”, (,) will return “one (two) three”, and leave “ four” on the queue. Unbalanced openers and closers can quoted (with ’ or “) or escaped (with ). Those escapes will be left in the returned string, which is suitable for regexes (where we need to preserve the escape), but unsuitable for contains text strings; use unescape for that.
func chompTo(_ seq: String) -> String
Pulls a string off the queue (like consumeTo), and then pulls off the matched string (but does not return it).
func chompToIgnoreCase(_ seq: String) -> String
func consume() -> Character
Consume one character off queue.
func consume(_ seq: String) throws
Consumes the supplied sequence of the queue. If the queue does not start with the supplied sequence, will throw an illegal state exception – but you should be running match() against that condition.
Case insensitive.
func consumeAttributeKey() -> String
Consume an attribute key off the queue (letter, digit, -, _, :”)
func consumeCssIdentifier() -> String
Consume a CSS identifier (ID or class) off the queue (letter, digit, -, _) http://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
func consumeElementSelector() -> String
Consume a CSS element selector (tag name, but | instead of : for namespaces (or *| for wildcard namespace), to not conflict with :pseudo selects).
func consumeTagName() -> String
Consume an tag name off the queue (word or :, _, -)
@discardableResult func consumeTo(_ seq: String) -> String
Pulls a string off the queue, up to but exclusive of the match sequence, or to the queue running out.
func consumeToAny(_ seq: String...) -> String
Consumes to the first sequence provided, or to the end of the queue. Leaves the terminator on the queue.
func consumeToAny(_ seq: [String]) -> String
func consumeToIgnoreCase(_ seq: String) -> String
@discardableResult func consumeWord() -> String
Retrieves the next run of word type (letter or digit) off the queue.
func isEmpty() -> Bool
Is the queue empty?
@discardableResult func matchChomp(_ seq: String) -> Bool
Tests if the queue matches the sequence (as with match), and if they do, removes the matched string from the queue.
func matches(_ seq: String) -> Bool
Tests if the next characters on the queue match the sequence. Case insensitive.
func matchesAny(_ seq: Character...) -> Bool
func matchesAny(_ seq: String...) -> Bool
func matchesAny(_ seq: [String]) -> Bool
Tests if the next characters match any of the sequences. Case insensitive.
func matchesCS(_ seq: String) -> Bool
Case sensitive match test.
func matchesStartTag() -> Bool
func matchesWhitespace() -> Bool
Tests if queue starts with a whitespace character.
func matchesWord() -> Bool
Test if the queue matches a word character (letter or digit).
func peek() -> Character
Retrieves but does not remove the first character from the queue.
func remainder() -> String
Consume and return whatever is left on the queue.
func toString() -> String