Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ToBooleanLiteral.cs
1
using
System.Numerics;
2
using
Waher.Content
;
3
using
Waher.Content.Semantic.Model.Literals
;
4
using
Waher.Script.Abstraction.Elements
;
5
using
Waher.Script.Model
;
6
7
namespace
Waher.Script.Persistence.SPARQL.Functions.TypeConversion
8
{
12
public
class
ToBooleanLiteral
:
SemanticConversionFunction
13
{
17
public
ToBooleanLiteral
()
18
: base()
19
{
20
}
21
29
public
ToBooleanLiteral
(
ScriptNode
Argument
,
int
Start
,
int
Length
,
Expression
Expression
)
30
: base(
Argument
,
Start
,
Length
,
Expression
)
31
{
32
}
33
42
public
override
ScriptNode
CreateFunction
(
ScriptNode
Argument
,
int
Start
,
int
Length
,
Expression
Expression
)
43
{
44
return
new
ToBooleanLiteral
(
Argument
,
Start
,
Length
,
Expression
);
45
}
46
50
public
override
string
FunctionName
=>
BooleanLiteral
.
TypeUri
;
51
57
public
override
IElement
Convert
(
object
Value)
58
{
59
if
(Value is
bool
b)
60
return
new
BooleanLiteral
(b);
61
else
if
(Value is
string
s)
62
{
63
if
(
CommonTypes
.
TryParse
(s, out b))
64
return
new
BooleanLiteral
(b);
65
}
66
else
if
(Value is
double
d)
67
return
new
BooleanLiteral
(d != 0);
68
else
if
(Value is Complex z)
69
return
new
BooleanLiteral
(z != Complex.Zero);
70
71
b = System.Convert.ToBoolean(Value);
72
return
new
BooleanLiteral
(b);
73
}
74
}
75
}
Waher.Content.CommonTypes
Helps with parsing of commong data types.
Definition:
CommonTypes.cs:13
Waher.Content.CommonTypes.TryParse
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Definition:
CommonTypes.cs:46
Waher.Content.Semantic.Model.Literals.BooleanLiteral
Represents a bool literal.
Definition:
BooleanLiteral.cs:11
Waher.Content.Semantic.Model.Literals.BooleanLiteral.TypeUri
const string TypeUri
http://www.w3.org/2001/XMLSchema#boolean
Definition:
BooleanLiteral.cs:42
Waher.Script.Expression
Class managing a script expression.
Definition:
Expression.cs:39
Waher.Script.Model.FunctionOneVariable.Argument
ScriptNode Argument
Function argument.
Definition:
FunctionOneVariable.cs:33
Waher.Script.Model.ScriptNode
Base class for all nodes in a parsed script tree.
Definition:
ScriptNode.cs:69
Waher.Script.Model.ScriptNode.Length
int Length
Length of expression covered by node.
Definition:
ScriptNode.cs:101
Waher.Script.Model.ScriptNode.Start
int Start
Start position in script expression.
Definition:
ScriptNode.cs:92
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.SemanticConversionFunction
Abstract base class for semantic conversion functions.
Definition:
SemanticConversionFunction.cs:12
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToBooleanLiteral
Converts a value to a boolean literal.
Definition:
ToBooleanLiteral.cs:13
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToBooleanLiteral.CreateFunction
override ScriptNode CreateFunction(ScriptNode Argument, int Start, int Length, Expression Expression)
Creates a function node.
Definition:
ToBooleanLiteral.cs:42
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToBooleanLiteral.ToBooleanLiteral
ToBooleanLiteral()
Converts a value to a boolean literal.
Definition:
ToBooleanLiteral.cs:17
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToBooleanLiteral.FunctionName
override string FunctionName
Name of the function
Definition:
ToBooleanLiteral.cs:50
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToBooleanLiteral.Convert
override IElement Convert(object Value)
Converts an object to the desired type.
Definition:
ToBooleanLiteral.cs:57
Waher.Script.Persistence.SPARQL.Functions.TypeConversion.ToBooleanLiteral.ToBooleanLiteral
ToBooleanLiteral(ScriptNode Argument, int Start, int Length, Expression Expression)
Converts a value to a boolean literal.
Definition:
ToBooleanLiteral.cs:29
Waher.Script.Abstraction.Elements.IElement
Basic interface for all types of elements.
Definition:
IElement.cs:20
Waher.Content.Semantic.Model.Literals
Definition:
Base64Literal.cs:6
Waher.Content
Definition:
Array.cs:6
Waher.Script.Abstraction.Elements
Definition:
AbelianGroupElement.cs:5
Waher.Script.Model
Definition:
BinaryBooleanOperator.cs:8
Waher.Script.Persistence.SPARQL.Functions.TypeConversion
Definition:
SemanticConversionFunction.cs:7
IoTGateway
Script
Waher.Script.Persistence
SPARQL
Functions
TypeConversion
ToBooleanLiteral.cs
Generated by
1.9.5