From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- .../Penlight/docs/libraries/pl.stringio.html | 215 +++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.stringio.html (limited to 'Data/Libraries/Penlight/docs/libraries/pl.stringio.html') diff --git a/Data/Libraries/Penlight/docs/libraries/pl.stringio.html b/Data/Libraries/Penlight/docs/libraries/pl.stringio.html new file mode 100644 index 0000000..7505d34 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.stringio.html @@ -0,0 +1,215 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.stringio

+

Reading and writing strings using file-like objects.

+


+ + +
+f = stringio.open(text)
+l1 = f:read()  -- read first line
+n,m = f:read ('*n','*n') -- read two numbers
+for line in f:lines() do print(line) end -- iterate over all lines
+f = stringio.create()
+f:write('hello')
+f:write('dolly')
+assert(f:value(),'hellodolly')
+
+ +

See the Guide.

+ + +

Functions

+ + + + + + + + + +
create ()create a file-like object which can be used to construct a string.
open (s)create a file-like object for reading from a given string.
+ +
+
+ + +

Functions

+ +
+
+ + create () +
+
+ create a file-like object which can be used to construct a string. + The resulting object has an extra value() method for + retrieving the string value. Implements file:write, file:seek, file:lines, + plus an extra writef method which works like utils.printf. + + + + + + +

Usage:

+
    +
    f = create(); f:write('hello, dolly\n'); print(f:value())
    +
+ +
+
+ + open (s) +
+
+ create a file-like object for reading from a given string. + Implements file:read. + + +

Parameters:

+
    +
  • s + string + The input string. +
  • +
+ + + + +

Usage:

+
    +
    fs = open '20 10'; x,y = f:read ('*n','*n'); assert(x == 20 and y == 10)
    +
+ +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0