aboutsummaryrefslogtreecommitdiff
path: root/core/strings/reader.odin
diff options
context:
space:
mode:
authorLucas Perlind <perlindluca@gmail.com>2023-04-03 08:33:24 +1000
committerLucas Perlind <perlindluca@gmail.com>2023-04-03 08:44:14 +1000
commit67e6f571925a07d25b5b3bef2ecb22a30afb6508 (patch)
treeb12a01775f35d2aaec40265092f91b4fbd0430c9 /core/strings/reader.odin
parent6ff0cc0b400524232cdce44f5b2a68b399ba4adc (diff)
Small improvements strings documentation
* Use new 'Returns:' and 'Inputs:' keywords used by the website generator * Make order item order resemble website, i.e. 'Returns:' comes before 'Example:' * Add a few missing input items * Add a few missing return items
Diffstat (limited to 'core/strings/reader.odin')
-rw-r--r--core/strings/reader.odin54
1 files changed, 27 insertions, 27 deletions
diff --git a/core/strings/reader.odin b/core/strings/reader.odin
index 917092ad6..715e57ada 100644
--- a/core/strings/reader.odin
+++ b/core/strings/reader.odin
@@ -16,7 +16,7 @@ Reader :: struct {
/*
Initializes a string Reader with the provided string
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- s: The input string to be read
*/
@@ -28,10 +28,10 @@ reader_init :: proc(r: ^Reader, s: string) {
/*
Converts a Reader into an `io.Stream`
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
-**Returns**
+Returns:
An io.Stream for the given Reader
*/
reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) {
@@ -42,11 +42,11 @@ reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) {
/*
Initializes a string Reader and returns an `io.Reader` for the given string
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- s: The input string to be read
-**Returns**
+Returns:
An io.Reader for the given string
*/
to_reader :: proc(r: ^Reader, s: string) -> io.Reader {
@@ -57,11 +57,11 @@ to_reader :: proc(r: ^Reader, s: string) -> io.Reader {
/*
Initializes a string Reader and returns an `io.Reader_At` for the given string
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- s: The input string to be read
-**Returns**
+Returns:
An `io.Reader_At` for the given string
*/
to_reader_at :: proc(r: ^Reader, s: string) -> io.Reader_At {
@@ -72,10 +72,10 @@ to_reader_at :: proc(r: ^Reader, s: string) -> io.Reader_At {
/*
Returns the remaining length of the Reader
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
-**Returns**
+Returns:
The remaining length of the Reader
*/
reader_length :: proc(r: ^Reader) -> int {
@@ -87,10 +87,10 @@ reader_length :: proc(r: ^Reader) -> int {
/*
Returns the length of the string stored in the Reader
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
-**Returns**
+Returns:
The length of the string stored in the Reader
*/
reader_size :: proc(r: ^Reader) -> i64 {
@@ -99,11 +99,11 @@ reader_size :: proc(r: ^Reader) -> i64 {
/*
Reads len(p) bytes from the Reader's string and copies into the provided slice.
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- p: A byte slice to copy data into
-**Returns**
+Returns:
- n: The number of bytes read
- err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success.
*/
@@ -119,12 +119,12 @@ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
/*
Reads len(p) bytes from the Reader's string and copies into the provided slice, at the specified offset from the current index.
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- p: A byte slice to copy data into
- off: The offset from which to read
-**Returns**
+Returns:
- n: The number of bytes read
- err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success.
*/
@@ -144,10 +144,10 @@ reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Erro
/*
Reads and returns a single byte from the Reader's string
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
-**Returns**
+Returns:
- The byte read from the Reader
- err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success.
*/
@@ -163,10 +163,10 @@ reader_read_byte :: proc(r: ^Reader) -> (byte, io.Error) {
/*
Decrements the Reader's index (i) by 1
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
-**Returns**
+Returns:
An `io.Error` if `r.i <= 0` (`.Invalid_Unread`), otherwise `nil` denotes success.
*/
reader_unread_byte :: proc(r: ^Reader) -> io.Error {
@@ -180,10 +180,10 @@ reader_unread_byte :: proc(r: ^Reader) -> io.Error {
/*
Reads and returns a single rune and its `size` from the Reader's string
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
-**Returns**
+Returns:
- rr: The rune read from the Reader
- size: The size of the rune in bytes
- err: An `io.Error` if an error occurs while reading
@@ -205,12 +205,12 @@ reader_read_rune :: proc(r: ^Reader) -> (rr: rune, size: int, err: io.Error) {
/*
Decrements the Reader's index (i) by the size of the last read rune
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
WARNING: May only be used once and after a valid `read_rune` call
-**Returns**
+Returns:
An `io.Error` if an error occurs while unreading (`.Invalid_Unread`), else `nil` denotes success.
*/
reader_unread_rune :: proc(r: ^Reader) -> io.Error {
@@ -227,12 +227,12 @@ reader_unread_rune :: proc(r: ^Reader) -> io.Error {
/*
Seeks the Reader's index to a new position
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- offset: The new offset position
- whence: The reference point for the new position (`.Start`, `.Current`, or `.End`)
-**Returns**
+Returns:
- The absolute offset after seeking
- err: An `io.Error` if an error occurs while seeking (`.Invalid_Whence`, `.Invalid_Offset`)
*/
@@ -259,13 +259,13 @@ reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (i64, io.E
/*
Writes the remaining content of the Reader's string into the provided `io.Writer`
-**Inputs**
+Inputs:
- r: A pointer to a Reader struct
- w: The io.Writer to write the remaining content into
WARNING: Panics if writer writes more bytes than remainig length of string.
-**Returns**
+Returns:
- n: The number of bytes written
- err: An io.Error if an error occurs while writing (`.Short_Write`)
*/