TParameterFormatter( TTextOrder* textOrder ); TParameterFormatter( const TText& textTemplate, const TTextOrder* textOrder = NIL );
To use the formatter, you call the Format or Scan function, passing in a TFormattableParameterList instance containing values for each parameter.
Step 1:
Setting up
the template
Declare the TParameterFormatter instance and attach a text instance as the template.
TParameterFormatter myParameterFormatter; myParameterFormatter.SetTemplate(TStandardText( "Today, date, there are n files on the disk called name.")); //0123456789012345678901234567890123456789012345678901234
myParameterFormatter.SetParameterType(0, TStandardText("TFormattableTime")); myParameterFormatter.SetParameterType(1, TStandardText("TFormattableNumber")); myParameterFormatter.SetParameterType(2, TStandardText("TFormattableText"));
This example uses formatters that provide default behavior:
TGregorianDateTimeFormatter myDateTimeFormat; TPositionalNumberFormatter myNumberFormat; TSimpleTextFormatter myStringFormat; myParameterFormatter.SetParameterFormat (TTextRange(TTextOffset(7),TTextOffset(11)), 0, myDateFormat); myParameterFormatter.SetParameterFormat (TTextRange(TTextOffset(23),TTextOffset(24)), 1, myNumberFormat); myParameterFormatter.SetParameterFormat (TTextRange(TTextOffset(50),TTextOffset(54)), 2, myStringFormat);
TFormattableParameterList myParameterList; myParameterList.SetParameter(0, TFormattableTime(TTime::Now())); myParameterList.SetParameter(1, TFormattableNumber(25)); myParameterList.SetParameter(2, TFormattableText("Joe Smith's Disk"); TStandardText resultText; TParameterFormatResult formatResult; myParameterFormatter.Format(myParameterList, resultText, formatResult);