From 05ebe3b38342ba38ad0f1c418058d5100ca776ab Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 21 Jan 2023 21:43:21 -0500 Subject: Fix FBM session cancel, fix plugin log file names --- lib/Utils/src/ERRNO.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib/Utils/src/ERRNO.cs') diff --git a/lib/Utils/src/ERRNO.cs b/lib/Utils/src/ERRNO.cs index 972aa49..03ebd17 100644 --- a/lib/Utils/src/ERRNO.cs +++ b/lib/Utils/src/ERRNO.cs @@ -123,15 +123,37 @@ namespace VNLib.Utils public readonly override bool Equals(object? obj) => obj is ERRNO other && Equals(other); public readonly override int GetHashCode() => ErrorCode.GetHashCode(); + /// + /// Attempts to parse the value of the character sequence as a new error code + /// + /// The character sequence value to parse + /// The value + /// True if the value was successfully parsed, false othwerwise + public static bool TryParse(ReadOnlySpan value, out ERRNO result) + { + result = 0; + if (nint.TryParse(value, out nint res)) + { + result = new ERRNO(res); + return true; + } + return false; + } + /// /// The integer error value of the current instance in radix 10 /// - /// + /// The radix 10 formatted error code public readonly override string ToString() { //Return the string of the error code number return ErrorCode.ToString(); } + /// + /// Formats the internal nint error code as a string in specified format + /// + /// The format to use + /// The formatted error code public readonly string ToString(string format) { //Return the string of the error code number @@ -143,6 +165,7 @@ namespace VNLib.Utils { return ErrorCode.TryFormat(destination, out charsWritten, format, provider); } + /// public readonly string ToString(string format, IFormatProvider formatProvider) { -- cgit