SmartTableBinding.h

How a column name becomes a read of a property or a call to a function.

Source/SmartTables/Public/SmartTableBinding.h

A column names a field and something has to turn that name into a read. These do it once per class, and hand back a binding every cell in that column reuses. Resolving it per cell would be the same reflection lookup a million times over.

Namespace
SmartTable
Members
24

Public functions 13

ResolveBinding
SMARTTABLES_API FBinding ResolveBinding( const UStruct * Struct, FName Name )

Finds Name on Struct, by property first and then by function.

It falls back to FProperty::GetAuthoredName, because the fields of a Blueprint struct carry an id on disk, such as Distance_3_ABC123. The engine's own DataTable helpers match the same way. Without it a table over a Blueprint row struct resolves nothing and every cell is blank.

FName compares upper and lower case alike. A case typo in a binding name still resolves.

GetBindableNames
SMARTTABLES_API TArray< FName > GetBindableNames( const UStruct * Struct )

Every name a column could bind to on this struct: its properties, and the functions that can be bound. It fills the Details panel dropdown, and DescribeBindableNames turns the same list into the one string a warning needs.

DescribeBindableNames
SMARTTABLES_API FString DescribeBindableNames( const UStruct * Struct )

The same names as one string, which is the only shape a warning needs them in.

ShouldWarnForUnresolvedBinding
SMARTTABLES_API bool ShouldWarnForUnresolvedBinding( const FSmartTableColumn & Column, const FBinding & Value )

Whether a column whose value binding did not resolve is worth a warning.

A column that draws a widget and never named a binding has nothing to resolve: a button, an icon, a row action. Warning about those means every table logs. A BindingName that was named and failed still warns.

The rule lives here and not in each model, so both models refuse the same column the same way. What they then say still differs, and is meant to: a class has functions and an ExpectedItemClass to point at, and a row struct has neither.

ShouldWarnForUnresolvedSortBinding
SMARTTABLES_API bool ShouldWarnForUnresolvedSortBinding( const FSmartTableColumn & Column, const FBinding & Sort )

Whether an unresolved sort binding is worth a word.

Only when one was named. GetSortBinding falls back to the value binding while SortBindingName is empty, which is the normal case, and the rule above already covers that failure.

SortBindingName is the one binding with no dropdown, so free text is usually where a typo lands. The failure then shows nothing at all: the column draws its values from the value binding, and the header arrow still flips. Only the rows never move.

ReadAsText
SMARTTABLES_API FText ReadAsText( const FBinding & Binding, UObject * Item, const FSmartTableColumn & Column )

Reads the bound member as the text a cell draws, using MaxFractionalDigits for a numeric one.

ReadAsSortKey
SMARTTABLES_API FSmartTableSortKey ReadAsSortKey( const FBinding & Binding, UObject * Item )

Reads the bound member as a key that can be put in order: numeric for numbers and true or false values, text for the rest.

A FUNCTION binding whose return type is already FSmartTableSortKey passes straight through, which is how a column says it has no answer for a row. A property binding is always turned into a key, whatever it holds, so that route cannot pass one through.

ReadStructAsText
SMARTTABLES_API FText ReadStructAsText( const FBinding & Binding, const void * RowData, const FSmartTableColumn & Column )

The same reads against plain struct memory: a DataTable row, which has properties and nothing to call. A binding that resolved to a function has nothing to run here and reads as empty.

ReadStructAsSortKey
SMARTTABLES_API FSmartTableSortKey ReadStructAsSortKey( const FBinding & Binding, const void * RowData )
Classify
SMARTTABLES_API EBoundKind Classify( const FProperty * Property )

The kind of one property, and the ONE place the order of the tests lives.

The order carries a rule. A TEnumAsByte is an FNumericProperty that happens to hold an enum, so asking is it numeric first turns a five value column into a box asking for the number 3. Everything that needs the kind comes here, and the order is settled once.

EditorFor
SMARTTABLES_API ESmartTableCellEditor EditorFor( const FBinding & Binding )

Which editor the value of this binding can be typed into, if any.

None for anything a built-in cell should not offer to edit: a function, which has nothing to write back to, an enum, an object reference, and anything that did not resolve at all.

WriteAsText
SMARTTABLES_API bool WriteAsText( const FBinding & Binding, UObject * Item, const FText & Value )

Writes text back into the bound member. False when the value could not be used.

It refuses and never rounds down. Text that is not a whole number is a typo, and storing part of it would leave the table holding something other than what is on screen. The cell puts the old value back, which is the only answer that needs no widget.

An int32 member takes no dot at all, a bare trailing one with it. The engine's own numeric test passes a dot whatever the member is, so this is asked here and not left to it.

WriteStructAsText
SMARTTABLES_API bool WriteStructAsText( const FBinding & Binding, void * RowData, const FText & Value )

EBoundKind enum

What a bound property counts as. Unsupported is every kind the table cannot read.

Values 8

UnsupportedUnsupported
Unsupported
TextText
Text
StringString
String
NameName
Name
BoolBool
Bool
EnumEnum
Enum
NumberNumber
Number
ObjectObject
Object

FBinding struct

The binding of one column, resolved against one class, once.

A name resolves to a property, or to a BlueprintPure function that needs no input. The second half is what saves a worked out column from needing a model: Distance may be no property at all, and GetDistance is then an ordinary node on the item.

Resolved per class, cached, and never per cell. Ten thousand rows must not cost ten thousand name lookups to draw one column.

Public functions 1

IsValid
bool IsValid() const

Public variables 2

Property
TWeakFieldPtr< FProperty > Property
Function
TWeakObjectPtr< UFunction > Function

Next: SmartTableColumnSchema.h