Documentation ¶
Overview ¶
Package tables provides functions for dealing with table-like structures, such as used by 2DA or IDS resource types.
Index ¶
- type Table
- func (t *Table) ClearError()
- func (t *Table) ClearModified()
- func (t *Table) Columns() int
- func (t *Table) DeleteItem(row, col, minCols int) string
- func (t *Table) DeleteRow(rowIndex int)
- func (t *Table) Error() error
- func (t *Table) GetItem(row, col, minCols int) string
- func (t *Table) InsertItem(row, col, minCols int, item string)
- func (t *Table) InsertRow(rowIndex int, items []string)
- func (t *Table) InsertRowBuffer(rowIndex int, buffer []byte)
- func (t *Table) InsertRowString(rowIndex int, line string)
- func (t *Table) Is2DA() bool
- func (t *Table) IsIDS() bool
- func (t *Table) IsModified() bool
- func (t *Table) PutItem(row, col, minCols int, item string)
- func (t *Table) RowColumns(row, minCols int) int
- func (t *Table) Rows(cols int) int
- func (t *Table) Save(w io.Writer, prettify bool)
- func (t *Table) SaveEx(w io.Writer, cmap *charmap.Charmap, prettify bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table contains the necessary information to query or alter table data.
func Load ¶
Load uses the given Reader to load table data from the underlying buffer. The function returns a pointer to the Table object.
This function assumes that input data is encoded in ANSI Windows-1252. Use function Error to check if the Load function returned successfully.
func LoadEx ¶
LoadEx uses the given Reader to load table data from the underlying buffer, using the specified character map for ANSI decoding.
Specify a nil charmap to skip the decoding operation. The function returns a pointer to the Table object. Use function Error to check if the Load function returned successfully.
func (*Table) ClearError ¶
func (t *Table) ClearError()
ClearError clears the error state from the last Table operation. Must be called for subsequent operations to work correctly.
func (*Table) ClearModified ¶
func (t *Table) ClearModified()
ClearModified explicitly marks the Table object as unmodified.
func (*Table) Columns ¶
Columns returns the maximum number of columns available for the table. Operation is skipped if error state is set.
func (*Table) DeleteItem ¶
DeleteItem removes the table item at [row, col] for rows containing minCols or more items and returns the removed item.
As a result the number of columns for this row will decrease by one. Sets t.err if the specified location does not exist. Operation is skipped if error state is set.
func (*Table) DeleteRow ¶
DeleteRow removes the specified row of data. rowIndex must be in range 0 to Rows(0) exclusive. Operation is skipped if error state is set.
func (*Table) Error ¶
Error returns the error state of the most recent operation on Table. Use ClearError function to clear the current error state.
func (*Table) GetItem ¶
GetItem returns the item at [row, col] for rows containing minCols or more items.
Sets t.err and returns empty item if [row, col] doesn't point to a valid location. Operation is skipped if error state is set.
func (*Table) InsertItem ¶
InsertItem inserts a new item with the specified string at [row, col] for rows containing minCols or more items.
Sets t.err and skips insertion if location does not exist or item is empty. Operation is skipped if error state is set.
func (*Table) InsertRow ¶
InsertRow inserts a new table row and fills it with the specified items. No row is inserted if items doesn't contain non-empty items.
rowIndex must be in range 0 to Rows(0) inclusive. Operation is skipped if error state is set.
func (*Table) InsertRowBuffer ¶
InsertRowString inserts a new table row and fills it with the items extracted from the given byte array.
No row is inserted if buffer doesn't contain non-empty items. rowIndex must be in range 0 to Rows(0) inclusive. Operation is skipped if error state is set.
func (*Table) InsertRowString ¶
InsertRowString inserts a new table row and fills it with the items extracted from the given string.
No row is inserted if line doesn't contain non-empty items. rowIndex must be in range 0 to Rows(0) inclusive. Operation is skipped if error state is set.
func (*Table) Is2DA ¶
Is2DA returns true only if the current content conforms to the 2DA table format. Operation is skipped if error state is set.
func (*Table) IsIDS ¶
IsIDS returns true only if the current content conforms to the IDS table format. Operation is skipped if error state is set.
func (*Table) IsModified ¶
IsModified returns whether the current table content has been modified by a previous operation. The return value is only provided for informal purposes. None of the Table functions rely on it.
func (*Table) PutItem ¶
PutItem assigns item to the existing table location [row, col] for rows containing minCols or more items.
Sets t.err if the specified location does not exist or item is empty. Operation is skipped if error state is set. Hint: Use DeleteItem to remove individual items. Use InsertItem to insert a new item.
func (*Table) RowColumns ¶
RowColumns returns the number of columns of the specified row that has minCols or more items. Returns -1 if row doesn't exist. Operation is skipped if error state is set.
func (*Table) Rows ¶
Rows returns the number of rows containing at least "cols" number of columns. Operation is skipped if error state is set.
func (*Table) Save ¶
Save writes the current table content to the specified Writer, encoding text as specified by the Load function.
Does nothing if the Table is in an invalid state (see Error function). Set prettify to ensure that table data is properly aligned.
func (*Table) SaveEx ¶
SaveEx writes the current table content to the specified Writer, using the specified character map for ANSI encoding.
Specify a nil charmap to skip the encoding operation. Does nothing if the Table is in an invalid state (see Error function). Set prettify to ensure that table data is properly aligned.