Instance Methodhummingbird 2.3.0HummingbirdCore
read(untilString:throwOnOverflow:skipToEnd:)
Read from buffer until we hit a string. By default the position after this is of the beginning of the string we were checking for
HBParser.swift:228@discardableResult mutating func read(untilString: String, throwOnOverflow: Bool = true, skipToEnd: Bool = false) throws -> Parser
Parameters
- untilString
String to check for
- throwOnOverflow
Throw errors if we hit the end of the buffer
- skipToEnd
Should we set the position to after the found string
Returns
String read from buffer
Throws
.overflow, .emptyString
Other members in extension
Types
Typealiases
Type members
init(String
) init?(some Collection<UInt8>, validateUTF8: Bool
) Create a Parser object
Instance members
var count: Int
Return contents of parser as a string
var string: String
Return contents of parser as a string
func advance(
) throws Move forward one character
func advance(by: Int
) throws Move forward so many character
func character(
) throws -> Unicode.Scalar Return current character
func current(
) -> Unicode.Scalar Return the character at the current position
func makeIterator(
) -> Iterator func moveToEnd(
) Move parser to end of string
func moveToStart(
) Move parser to beginning of string
func percentDecode(
) -> String? percent decode UTF8
func reachedEnd(
) -> Bool Return whether we have reached the end of the buffer
func read(String
) throws -> Bool Compare characters at current position against provided string. If the characters are the same as string provided advance past string
func read(Set<Unicode.Scalar>
) throws -> Bool Read the current character and check if it is in a set of characters If character test returns true then move forward 1
func read(Unicode.Scalar
) throws -> Bool Read the current character and return if it is as intended. If character test returns true then move forward 1
func read(count: Int
) throws -> Parser Read next so many characters from buffer
func read(until: (Unicode.Scalar) -> Bool, throwOnOverflow: Bool
) throws -> Parser Read from buffer until we hit a character that returns true for supplied closure. Position after this is of the character we were checking for
func read(until: Set<Unicode.Scalar>, throwOnOverflow: Bool
) throws -> Parser Read from buffer until we hit a character in supplied set. Position after this is of the character we were checking for
func read(until: KeyPath<Unicode.Scalar, Bool>, throwOnOverflow: Bool
) throws -> Parser Read from buffer until we hit a character where supplied KeyPath is true. Position after this is of the character we were checking for
func read(until: Unicode.Scalar, throwOnOverflow: Bool
) throws -> Parser Read from buffer until we hit a character. Position after this is of the character we were checking for
func read(while: (Unicode.Scalar) -> Bool
) -> Parser Read while character returns true for supplied closure
func read(while: Set<Unicode.Scalar>
) -> Parser Read while character at current position is in supplied set
func read(while: KeyPath<Unicode.Scalar, Bool>
) -> Parser Read while character returns true for supplied KeyPath
func read(while: Unicode.Scalar
) -> Int Read while character at current position is the one supplied
func readUntilTheEnd(
) -> Parser Read from buffer from current position until the end of the buffer
func retreat(
) throws Move backwards one character
func retreat(by: Int
) throws Move back so many characters
func split(separator: Unicode.Scalar
) -> [Parser] Split parser into sections separated by character
func unsafeAdvance(
) func unsafeAdvance(by: Int
)