dat

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// Comment, if not 0, is the comment character.
	// It is set to pound ('#') by NewReader.
	// Lines beginning with the Comment character without preceding
	// whitespace are ignored.
	// Comment must be a valid rune and must not be \r, \n,
	// or the Unicode replacement character (0xFFFD).
	Comment rune
	// contains filtered or unexported fields
}

A Reader reads records from an OpenFOAM DAT file.

As returned by NewReader, a Reader expects input conforming to the usual, albeit variable, OpenFOAM DAT file format: fields delimited by whitespace, with or without leading whitespace, which is always ignored, and with lines beggining with '#' denoting comments. All parentheses are automatically removed while reading, hence tensors (of any order) will yield their component values as individual fields.

The exported fields can be changed to customize the details before the first call to Read or ReadAll.

The Reader converts all \r\n sequences in its input to plain \n, including in multiline field values, so that the returned data does not depend on which line-ending convention an input file uses.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader that reads from r.

func (*Reader) Read

func (r *Reader) Read() ([]string, error)

Read reads one record (a slice of fields) from r. Read always returns either a non-nil record or a non-nil error, but not both. If there is no data left to be read, Read returns nil, io.EOF.

func (*Reader) ReadAll

func (r *Reader) ReadAll() (records [][]string, err error)

ReadAll reads all the remaining records from r. Each record is a slice of fields. A successful call returns err == nil, not err == io.EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL