summaryrefslogtreecommitdiff
path: root/lib/bytes/parser_example_test.go
AgeCommit message (Collapse)Author
2023-04-13lib/bytes: move unit Test for Read and SkipLine to ExampleShulhan
Using an example not only test the code but also provide example snippet when opened in the godoc.
2023-04-09lib/bytes: add method ReadLine to ParserShulhan
The ReadLine method read until it found new line ('\n') or end of content, ignoring all delimiters. The returned line will not contain '\n'.
2023-04-09lib/bytes: return the number of skipped chars on Skip(Horizontal)SpacesShulhan
2023-04-09lib/bytes: add method Remaining to ParserShulhan
The Remaining method return the copy of un-parsed content.
2023-04-08lib/bytes: add various methods to ParserShulhan
The AddDelimiters method add another delimiters to the current parser. The ReadNoSpace method read the next token by ignoring the leading spaces, even if its one of the delimiter. The returned token will have no trailing spaces. The RemoveDelimiters method remove delimiters delims from current delimiters. The Reset method set all internal state to new content and delimiters. The SetDelimiters method replace the current delimiters with delims. The SkipHorizontalSpaces method skip space (" "), tab ("\t"), carriage return ("\r"), and form feed ("\f") characters; and return the first non-space character or 0 if it reach end-of-content. The SkipSpaces method skip all spaces character (' ', '\f', '\n', '\r', '\t') and return the first non-space character or 0 if it reach end-of-content. The Stop method stop the parser, return the remaining unparsed content and its last position, and then call Reset to reset the internal state back to zero. The UnreadN method unread N characters and return the character its pointed to. If N greater than current position index, it will reset the read pointer index back to zero.