[Swift-devel] readData
Ben Clifford
benc at hawaga.org.uk
Wed Oct 10 05:23:16 CDT 2007
Mihael added the below language construct to the language the other day.
This might be useful where the csv_mapper was being used before to read in
non-file data.
Its in the SVN.
Mihael Hategan wrote:
There's a new function: readData. It's not an @function, so don't use it
that way because it won't work (it needs to know what variable it
assigns to, so that it knows how to interpret the contents of the
file).
It can read primitive things, arrays of primitive things, structs and
arrays of structs.
It can either take a file or a string as a parameter, although I
recommend the former since it can deal with data dependencies.
For example usage, see tests/language-behaviour/readData.swift.
Here's a short preview:
type circle {
int x;
int y;
float r;
string name;
}
circle ca[];
ca = readData("readData.circleArray.in");
readData.circleArray.in:
x y r name
1 1 5 CircleOne
2 2 7 CircleTwo
It doesn't deal with spaces in strings in the CSV format for now, but
it's a start.
Mihael
--
More information about the Swift-devel
mailing list