Show / Hide Table of Contents

Class Table

A very basic data table storing columns and rows of string information controlled by a simple schema. Source data can be loaded from a CSV-like file with the following format:

  • Dash starts a comment schema: id,*name (defines two columns, first called 'id' and second called 'name', * means this is the primary key) 0, Apples (0, Apples populates the two columns defined by schema, with an 'id' of "0" and 'name' of "Apples") 1, Oranges (and so on) Schema must be defined before first data row. Column names in schema must all be unique, at least one must be the key. Column values are always stored as strings. Key column value must be unique in every row. Can use spaces in values, but not commas (separating character only). Lookups are done by keys or by indices.
Inheritance
Object
Table
Namespace: DaggerfallWorkshop.Utility
Assembly: Assembly-CSharp.dll
Syntax
public class Table

Constructors

| Improve this Doc View Source

Table()

Default constructor.

Declaration
public Table()
| Improve this Doc View Source

Table(String)

Load constructor.

Declaration
public Table(string text)
Parameters
Type Name Description
String text

Text of data file.

| Improve this Doc View Source

Table(String[])

Load constructor.

Declaration
public Table(string[] lines)
Parameters
Type Name Description
String[] lines

String array of lines in data file.

Properties

| Improve this Doc View Source

ColumnCount

Declaration
public int ColumnCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

RowCount

Declaration
public int RowCount { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

AddIntoTable(String[])

Adds extra rows to a data table from an array lines.

Declaration
public void AddIntoTable(string[] lines)
Parameters
Type Name Description
String[] lines
| Improve this Doc View Source

GetColumnIndex(String)

Gets column index by name.

Declaration
public int GetColumnIndex(string columnName)
Parameters
Type Name Description
String columnName

Column name.

Returns
Type Description
Int32

Column index.

| Improve this Doc View Source

GetColumnName(Int32)

Gets column name by index.

Declaration
public string GetColumnName(int index)
Parameters
Type Name Description
Int32 index

Index of column.

Returns
Type Description
String

Name of column, or empty string.

| Improve this Doc View Source

GetInt(String, String)

Try to get value as int.

Declaration
public int GetInt(string columnName, string key)
Parameters
Type Name Description
String columnName
String key
Returns
Type Description
Int32
| Improve this Doc View Source

GetKeyForValue(String, String)

Declaration
public string GetKeyForValue(string columnName, string value)
Parameters
Type Name Description
String columnName
String value
Returns
Type Description
String
| Improve this Doc View Source

GetRow(Int32)

Gets a row array by index.

Declaration
public string[] GetRow(int index)
Parameters
Type Name Description
Int32 index

Index of row.

Returns
Type Description
String[]

String array for row, or empty array if row not found.

| Improve this Doc View Source

GetRow(String)

Gets a row array by key value.

Declaration
public string[] GetRow(string key)
Parameters
Type Name Description
String key

Key value.

Returns
Type Description
String[]

String array for row, or empty array if row not found.

| Improve this Doc View Source

GetRowIndex(String)

Gets index of row by key value.

Declaration
public int GetRowIndex(string key)
Parameters
Type Name Description
String key

Key value.

Returns
Type Description
Int32

Index of row, or -1 if not found.

| Improve this Doc View Source

GetValue(String, Int32)

Gets specified value from column.

Declaration
public string GetValue(string columnName, int index)
Parameters
Type Name Description
String columnName

Column name.

Int32 index

Index of row.

Returns
Type Description
String

Value as string.

| Improve this Doc View Source

GetValue(String, String)

Gets specified value from column.

Declaration
public string GetValue(string columnName, string key)
Parameters
Type Name Description
String columnName

Column name.

String key

Key value.

Returns
Type Description
String

Value as string.

| Improve this Doc View Source

HasColumn(String)

Checks if column name exists in table.

Declaration
public bool HasColumn(string columnName)
Parameters
Type Name Description
String columnName

Column name.

Returns
Type Description
Boolean

True if column exists.

| Improve this Doc View Source

HasValue(String)

Checks if a key value is present in table.

Declaration
public bool HasValue(string key)
Parameters
Type Name Description
String key

Key value.

Returns
Type Description
Boolean

True if key value present.

| Improve this Doc View Source

SetRow(String[])

Sets row data back to table. Key value must not be changed as this is used to set back correct row. Any other value can be changed as needed.

Declaration
public bool SetRow(string[] row)
Parameters
Type Name Description
String[] row

Row array.

Returns
Type Description
Boolean

True if row set.

| Improve this Doc View Source

SetValue(String, String, String)

Sets specified value in column.

Declaration
public void SetValue(string columnName, string key, string value)
Parameters
Type Name Description
String columnName

Column name.

String key

Key value.

String value

Value to set.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX