Ferreteria/v0.6/clade/Sys/Data/Things/Array/aux/Tuple
Jump to navigation
Jump to search
| ||||||||||||||
About
- Purpose: a single data item from a request - a name and optional values, effectively a sort of string-tuple
- Replaces DataPair; fka Piece
- Rules: does not handle encoding/decoding; this is just the abstract/native representation of the data
Status
History
- 2023-10-19 Started as a kind of rethinking of / replacement for Kiosk\DataPair.
- 2023-10-22 Removing the Seq field (tentatively), because we don't always know it at construction time.
- 2024-07-30 moved from [WFe]
Sys\Kiosk\Aux\Request⇒ [WFe]Data\Mem\Array\Aux - 2025-04-29 moved from [WFe]
Data\Mem\Array\Aux⇒ [WFe]Sys\Data\Things\Array\aux - 2023-11-16 [status] xTODO:
This should probably be renamed cPair or cDyad. Might belong in Data\Mem\Array, also.See "Naming". - 2025-11-20 [status] Seems like this ought to descend from QStr, removing the necessity for
Value(),ValueNz(),HasValue()... - 2025-11-21
- reworked slightly to descend from QStr. Works slitely gooder now.
- renamed
Piece⇒Tuple
Code
interface iTuple extends BaseIface {
// ACCESS
function Name() : string;
function AddExtra(string $s);
// ++ DIAGNOSTICS ++ // - to be moved to Viewer() (...except why bother?)
function DumpLine() : string;
function DumpLines() : string;
// -- DIAGNOSTICS -- //
}
class cTuple extends BaseClass implements iTuple {
public function __construct(protected string $sName, string $sValue=NULL) {
$this->SetItNz($sValue);
}
// ++ ACCESS ++ //
public function Name() : string { return $this->sName; }
// ALIAS
public function Value() : string { return $this->GetIt(); }
// If no explicit value, key is default value:
public function ValueNz() : string { return $this->GetItNz($this->Name()); }
private $arXt=[];
public function AddExtra(string $s) { $this->arXt[] = $s; }
public function GetExtras() : array { return $this->arXt; }
// -- ACCESS -- //
// ++ DIAGNOSTICS ++ //
public function DumpLine() : string {
$oScrn = self::Screen();
$sName = $this->Name();
$sValue = $this->Value(); // TODO: allow for NULL value
$ftName = $oScrn->BoldIt($sName);
$ftValue = $oScrn->BoldIt($sValue);
return "[$ftName]:[$ftValue]";
}
public function DumpLines() : string {
$oScrn = self::Screen();
$sName = $this->Name();
$sValue = $this->Value();
$ftName = $oScrn->BoldIt('Name').": [$sName]";
$ftValue = $oScrn->BoldIt('Value').": [$sValue]";
$oList = $oScrn->NewList();
$oList->AddLine($ftName);
$oList->AddLine($ftValue);
return $oList->Render();
}
// -- DIAGNOSTICS -- //
}