feat: Add function defs to DataStream DSL

This commit is contained in:
John Colvin committed 2025-11-15 12:42:39 -05:00
1 parent 0550078de0
commit 03294ffe37
55 files changed
+3332 -259

No files matched your search

@@ -94,6 +94,47 @@ namespace BCG {
return BlueDataUtility.get_row_datetime_value(r, col_no, err_value);
}
public static bool? GetBool(this IBlueRow r, int colNo) =>
GetBool(r[colNo]);
public static bool? GetBool(this IBlueRow r, string colName) =>
GetBool(r[colName]);
public static bool? GetBool(object obj) {
if (obj is bool b) {
return b;
}
if (obj is string s) {
if (bool.TryParse(s, out b)) {
return b;
}
return s.ToLower() switch {
"y" or "yes" or "on" or "1" => true,
"n" or "no" or "off" or "0" => false,
_ => throw new ArgumentException("", nameof(obj)),
};
}
if (obj is int i32) {
return i32 > 0;
}
if (obj is long i64) {
return i64 > 0;
}
if (obj is uint u32) {
return u32 > 0;
}
if (obj is ulong u64) {
return u64 > 0;
}
if (obj is short i16) {
return i16 > 0;
}
if (obj is ushort u16) {
return u16 > 0;
}
return null;
}
public static double? GetFloat64(this IBlueRow r, int colNo) =>
GetFloat64(r[colNo]);