uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
A high-level guide to the key classes in the uCalc library and how they interact to provide parsing, evaluation, and transformation capabilities.
The uCalc library is more than just a collection of functions; it's a structured ecosystem of interconnected objects. Understanding this object model is key to leveraging the full power of the library, from high-performance expression evaluation to complex text transformation. This guide provides a high-level map of the core classes and their relationships.
uCalc and ItemAt the center of everything are two fundamental concepts:
uCalc instance. Whether it's a variable, a function, an operator, a data type, or even a transformer rule, it is represented internally as an Item. This unified model simplifies introspection and management.This subsystem is responsible for evaluating mathematical and logical expressions.
Parse operation. It represents a pre-compiled, reusable execution plan, which is the key to the "Parse-Once, Evaluate-Many" performance pattern.Callback object, which it uses to get arguments and return a value to the engine.This subsystem provides powerful, token-aware find-and-replace capabilities.
Transformer breaks raw text into meaningful tokens (words, numbers, symbols).Transformer. You create rules with methods like FromTo and Pattern.Find or Transform operation. Each individual Match object contains the text, position, and the Rule that generated it.StringBuilder, lightweight Transformer, and list processor all in one. It operates using a "live view" model, where modifications to a substring directly affect the parent.The following diagram illustrates the primary relationships and ownership within the object model:
┌─────────────────┐ │ uCalc │ (The Engine/Context) └─────────────────┘ │ ┌─────────────────┴─────────────────┐ │ (Owns/Manages) │ ┌──────▼──────┐ ┌────────────┐ ┌──────▼─────┐ │ Items │ │ DataTypes │ │ Tokens │ (Symbol Tables) └─────────────┘ └────────────┘ └────────────┘ │┌────────┴─────────┐│ (Creates) │▼ ▼ ▼┌────────────┐ ┌─────────────┐ ┌────────────┐│ Expression │ │ Transformer │ │ uCalc.String │└────────────┘ └─────────────┘ └────────────┘ │ │ │ (Evaluates) │ (Owns) │ │ ▼ ▼┌──────────┐ ┌─────────┐│ Callback │ │ Rules │└──────────┘ └─────────┘ │ │ (Produces) │ ▼ ┌─────────┐ │ Matches │ └─────────┘ID: 31
using uCalcSoftware;
var uc = new uCalc();
var VariableX = uc.DefineVariable("x");
var Expression = "x^2 * 10"; // Replace this with your expression
Console.WriteLine("--- Efficient: Parse() once, then Evaluate() in a loop ---");
var ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x++) {
VariableX.Value(x);
Console.WriteLine(ParsedExpr.Evaluate());
}
ParsedExpr.Release();
VariableX.Release();
--- Efficient: Parse() once, then Evaluate() in a loop ---
10
40
90
160
250
360
490
640
810
1000 using uCalcSoftware; var uc = new uCalc(); var VariableX = uc.DefineVariable("x"); var Expression = "x^2 * 10"; // Replace this with your expression Console.WriteLine("--- Efficient: Parse() once, then Evaluate() in a loop ---"); var ParsedExpr = uc.Parse(Expression); for (double x = 1; x <= 10; x++) { VariableX.Value(x); Console.WriteLine(ParsedExpr.Evaluate()); } ParsedExpr.Release(); VariableX.Release();
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto VariableX = uc.DefineVariable("x");
auto Expression = "x^2 * 10"; // Replace this with your expression
cout << "--- Efficient: Parse() once, then Evaluate() in a loop ---" << endl;
auto ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x++) {
VariableX.Value(x);
cout << ParsedExpr.Evaluate() << endl;
}
ParsedExpr.Release();
VariableX.Release();
}
--- Efficient: Parse() once, then Evaluate() in a loop ---
10
40
90
160
250
360
490
640
810
1000 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto VariableX = uc.DefineVariable("x"); auto Expression = "x^2 * 10"; // Replace this with your expression cout << "--- Efficient: Parse() once, then Evaluate() in a loop ---" << endl; auto ParsedExpr = uc.Parse(Expression); for (double x = 1; x <= 10; x++) { VariableX.Value(x); cout << ParsedExpr.Evaluate() << endl; } ParsedExpr.Release(); VariableX.Release(); }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim VariableX = uc.DefineVariable("x")
Dim Expression = "x^2 * 10" '// Replace this with your expression
Console.WriteLine("--- Efficient: Parse() once, then Evaluate() in a loop ---")
Dim ParsedExpr = uc.Parse(Expression)
For x As Double = 1 To 10
VariableX.Value(x)
Console.WriteLine(ParsedExpr.Evaluate())
Next
ParsedExpr.Release()
VariableX.Release()
End Sub
End Module
--- Efficient: Parse() once, then Evaluate() in a loop ---
10
40
90
160
250
360
490
640
810
1000 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim VariableX = uc.DefineVariable("x") Dim Expression = "x^2 * 10" '// Replace this with your expression Console.WriteLine("--- Efficient: Parse() once, then Evaluate() in a loop ---") Dim ParsedExpr = uc.Parse(Expression) For x As Double = 1 To 10 VariableX.Value(x) Console.WriteLine(ParsedExpr.Evaluate()) Next ParsedExpr.Release() VariableX.Release() End Sub End Module
ID: 1335
using uCalcSoftware;
var uc = new uCalc();
// 1. The uCalc instance (uc) is the factory
// 2. Create a Transformer from the instance
using (var t = new uCalc.Transformer(uc)) {
// 3. Define a Rule on the transformer
t.FromTo("apple", "FRUIT");
// 4. Process text and get the result
Console.WriteLine(t.Transform("An apple a day."));
};
An FRUIT a day. using uCalcSoftware; var uc = new uCalc(); // 1. The uCalc instance (uc) is the factory // 2. Create a Transformer from the instance using (var t = new uCalc.Transformer(uc)) { // 3. Define a Rule on the transformer t.FromTo("apple", "FRUIT"); // 4. Process text and get the result Console.WriteLine(t.Transform("An apple a day.")); };
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// 1. The uCalc instance (uc) is the factory
// 2. Create a Transformer from the instance
{
uCalc::Transformer t(uc);
t.Owned(); // Causes t to be released when it goes out of scope
// 3. Define a Rule on the transformer
t.FromTo("apple", "FRUIT");
// 4. Process text and get the result
cout << t.Transform("An apple a day.") << endl;
};
}
An FRUIT a day. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // 1. The uCalc instance (uc) is the factory // 2. Create a Transformer from the instance { uCalc::Transformer t(uc); t.Owned(); // Causes t to be released when it goes out of scope // 3. Define a Rule on the transformer t.FromTo("apple", "FRUIT"); // 4. Process text and get the result cout << t.Transform("An apple a day.") << endl; }; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// 1. The uCalc instance (uc) is the factory
'// 2. Create a Transformer from the instance
Using t As New uCalc.Transformer(uc)
'// 3. Define a Rule on the transformer
t.FromTo("apple", "FRUIT")
'// 4. Process text and get the result
Console.WriteLine(t.Transform("An apple a day."))
End Using
End Sub
End Module
An FRUIT a day. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// 1. The uCalc instance (uc) is the factory '// 2. Create a Transformer from the instance Using t As New uCalc.Transformer(uc) '// 3. Define a Rule on the transformer t.FromTo("apple", "FRUIT") '// 4. Process text and get the result Console.WriteLine(t.Transform("An apple a day.")) End Using End Sub End Module
ID: 1336
using uCalcSoftware;
var uc = new uCalc();
// 1. Create a uCalc.String with a parent uCalc instance
using (var s = new uCalc.String(uc, "The user is .")) {
// 2. Use the fluent, token-aware API
s.After("is").Between("<", ">").ToUpper();
// 3. The original string is modified in-place
Console.WriteLine(s);
};
The user is <ADMIN>. using uCalcSoftware; var uc = new uCalc(); // 1. Create a uCalc.String with a parent uCalc instance using (var s = new uCalc.String(uc, "The user is <admin>.")) { // 2. Use the fluent, token-aware API s.After("is").Between("<", ">").ToUpper(); // 3. The original string is modified in-place Console.WriteLine(s); };
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// 1. Create a uCalc.String with a parent uCalc instance
{
uCalc::String s(uc, "The user is .");
s.Owned(); // Causes s to be released when it goes out of scope
// 2. Use the fluent, token-aware API
s.After("is").Between("<", ">").ToUpper();
// 3. The original string is modified in-place
cout << s << endl;
};
}
The user is <ADMIN>. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // 1. Create a uCalc.String with a parent uCalc instance { uCalc::String s(uc, "The user is <admin>."); s.Owned(); // Causes s to be released when it goes out of scope // 2. Use the fluent, token-aware API s.After("is").Between("<", ">").ToUpper(); // 3. The original string is modified in-place cout << s << endl; }; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// 1. Create a uCalc.String with a parent uCalc instance
Using s As New uCalc.String(uc, "The user is .")
'// 2. Use the fluent, token-aware API
s.After("is").Between("<", ">").ToUpper()
'// 3. The original string is modified in-place
Console.WriteLine(s)
End Using
End Sub
End Module
The user is <ADMIN>. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// 1. Create a uCalc.String with a parent uCalc instance Using s As New uCalc.String(uc, "The user is <admin>.") '// 2. Use the fluent, token-aware API s.After("is").Between("<", ">").ToUpper() '// 3. The original string is modified in-place Console.WriteLine(s) End Using End Sub End Module