Table of Contents

Class TomlPrimitiveValue

Namespace
RStein.TOML
Assembly
RStein.TOML.dll

Represents a TOML primitive value (string, integer, float, boolean, or datetime).

public class TomlPrimitiveValue : TomlValue, IEnumerable<TomlToken>, IEnumerable, IEquatable<TomlPrimitiveValue>
Inheritance
TomlPrimitiveValue
Implements
Inherited Members

Examples

// Create primitive values
var stringValue = new TomlPrimitiveValue("hello");
var intValue = new TomlPrimitiveValue(42);
var boolValue = new TomlPrimitiveValue(true);

// Use implicit casts for convenient access
string str = (string?)stringValue ?? "default";
int num = ((int?)intValue) ?? 0;

Remarks

TomlPrimitiveValue is the container for all simple TOML value types. It provides implicit cast operators to common .NET types for convenient conversion (string, int, long, bool, DateTime, double, decimal, etc.).

Constructors

TomlPrimitiveValue(bool)

Initializes a new instance of the TomlPrimitiveValue class with a boolean value.

public TomlPrimitiveValue(bool value)

Parameters

value bool

The boolean value.

TomlPrimitiveValue(byte)

Initializes a new instance of the TomlPrimitiveValue class with an 8-bit unsigned integer value.

public TomlPrimitiveValue(byte value)

Parameters

value byte

The byte value.

TomlPrimitiveValue(DateTime)

Initializes a new instance of the TomlPrimitiveValue class with a datetime value.

public TomlPrimitiveValue(DateTime value)

Parameters

value DateTime

The datetime value (stored as offset datetime).

TomlPrimitiveValue(decimal)

Initializes a new instance of the TomlPrimitiveValue class with a decimal value.

public TomlPrimitiveValue(decimal value)

Parameters

value decimal

The decimal value.

TomlPrimitiveValue(double)

Initializes a new instance of the TomlPrimitiveValue class with a double-precision floating-point value.

public TomlPrimitiveValue(double value)

Parameters

value double

The double value.

TomlPrimitiveValue(Guid)

Initializes a new instance of the TomlPrimitiveValue class with a GUID value.

public TomlPrimitiveValue(Guid value)

Parameters

value Guid

The GUID value (stored as a string).

TomlPrimitiveValue(short)

Initializes a new instance of the TomlPrimitiveValue class with a 16-bit integer value.

public TomlPrimitiveValue(short value)

Parameters

value short

The short integer value.

TomlPrimitiveValue(int)

Initializes a new instance of the TomlPrimitiveValue class with a 32-bit integer value.

public TomlPrimitiveValue(int value)

Parameters

value int

The integer value.

TomlPrimitiveValue(long)

Initializes a new instance of the TomlPrimitiveValue class with a 64-bit integer value.

public TomlPrimitiveValue(long value)

Parameters

value long

The long integer value.

TomlPrimitiveValue(sbyte)

Initializes a new instance of the TomlPrimitiveValue class with an 8-bit signed integer value.

public TomlPrimitiveValue(sbyte value)

Parameters

value sbyte

The signed byte value.

TomlPrimitiveValue(float)

Initializes a new instance of the TomlPrimitiveValue class with a single-precision floating-point value.

public TomlPrimitiveValue(float value)

Parameters

value float

The float value.

TomlPrimitiveValue(string)

Initializes a new instance of the TomlPrimitiveValue class with a string value.

public TomlPrimitiveValue(string value)

Parameters

value string

The string value.

TomlPrimitiveValue(string, TomlValueType)

Initializes a new instance of the TomlPrimitiveValue class with a string value and explicit type.

public TomlPrimitiveValue(string value, TomlValueType type)

Parameters

value string

The string value representation.

type TomlValueType

The TOML value type.

Fields

BIN_NUMBER_PREFIX

Prefix for binary number literals (e.g., 0b1101).

public const string BIN_NUMBER_PREFIX = "0b"

Field Value

string

FALSE_VALUE_LITERAL

TOML literal for the boolean value false.

public const string FALSE_VALUE_LITERAL = "false"

Field Value

string

OCT_NUMBER_PREFIX

Prefix for octal number literals (e.g., 0o17).

public const string OCT_NUMBER_PREFIX = "0o"

Field Value

string

SPECIAL_FLOAT_INF_LITERAL

TOML special float literal representing positive or negative infinity (inf).

public const string SPECIAL_FLOAT_INF_LITERAL = "inf"

Field Value

string

SPECIAL_FLOAT_MINUS_INF_LITERAL

TOML special float literal representing negative infinity (-inf).

public const string SPECIAL_FLOAT_MINUS_INF_LITERAL = "-inf"

Field Value

string

SPECIAL_FLOAT_NAN_LITERAL

TOML special float literal representing Not-a-Number (nan).

public const string SPECIAL_FLOAT_NAN_LITERAL = "nan"

Field Value

string

SPECIAL_FLOAT_PLUS_INF_LITERAL

TOML special float literal representing positive infinity (+inf).

public const string SPECIAL_FLOAT_PLUS_INF_LITERAL = "+inf"

Field Value

string

TRUE_VALUE_LITERAL

TOML literal for the boolean value true.

public const string TRUE_VALUE_LITERAL = "true"

Field Value

string

Properties

Type

Gets the TOML type of the Value.

public TomlValueType Type { get; }

Property Value

TomlValueType

Value

Gets raw (string) value.

public string Value { get; }

Property Value

string

Methods

Equals(TomlPrimitiveValue?)

public bool Equals(TomlPrimitiveValue? other)

Parameters

other TomlPrimitiveValue

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string