ZFFramework
Loading...
Searching...
No Matches
ZFTextTemplate.h File Reference

text template util More...

Go to the source code of this file.

Functions

zfindex ZFTextTemplateApply (const ZFTextTemplateParam &param, const ZFOutput &output, const zfchar *data, zfindex dataSize=(((zfindex) -1)))
 util method to apply template to plain text
zfindex ZFTextTemplateApply (const ZFTextTemplateParam &param, const ZFOutput &output, const ZFInput &input)
 see ZFTextTemplateApply

Detailed Description

text template util

Function Documentation

◆ ZFTextTemplateApply()

zfindex ZFTextTemplateApply ( const ZFTextTemplateParam & param,
const ZFOutput & output,
const zfchar * data,
zfindex dataSize = (((zfindex) -1)) )
extern

util method to apply template to plain text

data would be applied according to ZFTextTemplateParam, and result would be written to output, return newly size written if success, or zfindexMax() if failed, you may pass an invalid output callback to calculate result size

methods:

  • replace
    replace the content with specified string
    assume we have a <"myKey", "myValue"> map, then the text would be applied like:
    // original:
    this is {ZFTT_R_myKey}, and this is {ZFTT_R_not_set}
    // applied:
    this is myValue, and this is {ZFTT_R_not_set}

    params:
  • enable
    whether to enable text block
    assume we have a <"myCond0", true> map and a <"myCond1", false> map, then the text would be applied like:
    // original:
    aaa {ZFTT_C_myCond0}text in myCond0{ZFTT_CE} bbb
    ccc {ZFTT_C_myCond1}text in myCond1{ZFTT_CE} ddd
    // result:
    aaa text in myCond0 bbb
    ccc ddd

    params:
  • index
    replace the content with specified index value
    the text would be applied like:

    // original:
    this is {ZFTT_I_myKey} item
    this is {ZFTT_I_myKey} item
    // applied:
    this is 0 item
    this is 1 item


    params:


    addition:

    • "{ZFTT_IR_myKey}":
      reset index state for "myKey"