#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IPA.Config.Data
{
///
/// A representing a piece of text. The only reason this is not named
/// String is so that it doesn't conflict with .
///
public sealed class Text : Value
{
///
/// Constructs an empty object.
///
[Obsolete("Use the String constructor.")]
public Text()
{
Value = null!;
}
///
/// Constructs a object containing the provided value.
///
/// The value to construct with.
public Text(string value)
{
Value = value;
}
///
/// The actual value of this object.
///
public string Value { get; init; }
///
/// Converts this into a human-readable format.
///
/// a quoted, unescaped string form of
public override string ToString() => $"\"{Value}\"";
}
///
/// A representing an integer. This may hold a 's
/// worth of data.
///
public sealed class Integer : Value
{
///
/// Constructs an empty object.
///
[Obsolete("Use the long constructor.")]
public Integer()
{
Value = 0;
}
///
/// Constructs a object containing the provided value.
///
/// The value to construct with.
public Integer(long value)
{
Value = value;
}
///
/// The actual value of the object.
///
public long Value { get; set; }
///
/// Coerces this into a .
///
/// a representing the closest approximation of
public FloatingPoint AsFloat() => Float(Value);
///
/// Converts this into a human-readable format.
///
/// the result of Value.ToString()
public override string ToString() => Value.ToString();
}
///
/// A representing a floating point value. This may hold a
/// 's worth of data.
///
public sealed class FloatingPoint : Value
{
///
/// Constructs an empty object.
///
[Obsolete("Use the long constructor.")]
public FloatingPoint()
{
Value = 0;
}
///
/// Constructs a object containing the provided value.
///
/// The value to construct with.
public FloatingPoint(decimal value)
{
Value = value;
}
///
/// The actual value fo this object.
///
public decimal Value { get; set; }
///
/// Coerces this into an .
///
/// a representing the closest approximation of
public Integer AsInteger() => Integer((long)Value);
///
/// Converts this into a human-readable format.
///
/// the result of Value.ToString()
public override string ToString() => Value.ToString();
}
///
/// A representing a boolean value.
///
public sealed class Boolean : Value
{
///
/// Constructs an empty object.
///
[Obsolete("Use the long constructor.")]
public Boolean()
{
Value = false;
}
///
/// Constructs a object containing the provided value.
///
/// The value to construct with.
public Boolean(bool value)
{
Value = value;
}
///
/// The actual value fo this object.
///
public bool Value { get; set; }
///
/// Converts this into a human-readable format.
///
/// the result of Value.ToString().ToLower()
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase",
Justification = "ToLower is the desired display value.")]
public override string ToString() => Value.ToString().ToLower(System.Globalization.CultureInfo.InvariantCulture);
}
}