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

style load utility More...

#include "ZFObjectIO.h"

Go to the source code of this file.

Classes

class  ZFStyleList
 see ZFStyleLoad More...
 

Macros

#define ZFStyleLoadErrorCallbackForConsole()
 error callback for ZFStyleLoad
 

Functions

ZFListenerZFStyleLoadErrorCallbackDefault (void)
 default error callback for ZFStyleLoad
 
void ZFStyleLoadErrorCallbackDefault (ZFListener const &v)
 see ZFStyleLoadErrorCallbackDefault
 
void ZFStyleLoadErrorHint (const ZFOutput &output, const ZFArgs &zfargs)
 util for impl to output error hint
 
zfbool ZFStyleLoad (const ZFPathInfo &pathInfo, const ZFListener &errorCallback=(ZFStyleLoadErrorCallbackDefault()))
 util to load multiple styles from directory
 
zfbool ZFStyleLoad (const ZFSerializableData &serializableData, const ZFListener &errorCallback=(ZFStyleLoadErrorCallbackDefault()))
 load multiple style from serializableData
 
zfbool ZFStyleLoad (ZFStyleList *styleList, const ZFListener &errorCallback=(ZFStyleLoadErrorCallbackDefault()))
 see ZFStyleLoad
 

Detailed Description

style load utility

Function Documentation

◆ ZFStyleLoad() [1/2]

zfbool ZFStyleLoad ( const ZFPathInfo & pathInfo,
const ZFListener & errorCallback = (ZFStyleLoadErrorCallbackDefault()) )
extern

util to load multiple styles from directory

pathInfo must points to a directory that contains styles, example:

~/
MyStyle/
button.xml
label.json
image.png
image.xml


all styles are loaded by ZFObjectIOLoad, and ZFPathOfWithoutAllExt would be used as styleKey for ZFStyleSet (~/path1/path2/mybutton.123.xml would result path1/path2/mybutton as styleKey), if two item with same name exists, the later one would override the first one (but which one is later, is not ensured, try to prevent that)

by default, these files or dirs would be ignored:

  • files or dirs whose name start with '.' or '' (e.g. '.ignored.xml')
  • files whose name end with '' (e.g. 'ignored_.xml')

specially, if the loaded object is type of ZFStyleList, all of its contents would be appended to current style, instead of setting ZFStyleList itself as a style value

the errorCallback would be called when anything load failed, param0 would be the error location (ZFPathInfo or ZFSerializableData or zfstring, depends on load method), param1 would be a zfstring contains error hint

◆ ZFStyleLoad() [2/2]

zfbool ZFStyleLoad ( const ZFSerializableData & serializableData,
const ZFListener & errorCallback = (ZFStyleLoadErrorCallbackDefault()) )
extern

load multiple style from serializableData

data should contains:

<Style1 prop="styleKey1" ... />
<Style2 prop="styleKey2" ... />
see ZFStyleLoad
Definition ZFStyleLoad.h:17

the ZFStyleList is a dummy holder to make the serializable data itself serializable