welcome to ZFFramework, a cross-platform and powerful application framework in C++
everything here starts with "ZF", which stands for "Zero Framework"
- it's not a traditional framework, can be loaded like a dynamic library, plug and play
- designed to be able to run at any platform that supplies C++03 compatible implementation
Homepage:
-
Online docs: http://ZFFramework.com
-
Github repo: https://github.com/ZFFramework/ZFFramework
-
history version: ZFFrameworkDist
this piece of code shows how to show a hello world on UI and log output
#include "ZFUIWidget.h" // for common UI module
ZFMAIN_ENTRY() { // app starts from here
// show a hello world to log output
ZFLog() << "hello wolrd";
// show a window (full screen by default)
zfobj<ZFUIWindow> window;
window->show();
// show a hello world as a text view
zfobj<ZFUITextView> textView;
window->child(textView)->c_alignTop()->c_margin(40);
textView->text("hello world");
// button and click (as observer)
zfobj<ZFUIButtonBasic> button;
window->child(button)->c_alignBottom()->c_margin(40);
button->label()->text("click me");
button->onClick([](const ZFArgs &zfargs) {
ZFUIButtonBasic *button = zfargs.sender();
ZFLogTrim() << "button clicked: " << button;
});
}
this piece of code shows equivalent lua code to use ZFFramework, all the lua bindings are automatically done by reflection!
ZFLog('hello world')
local window = ZFUIWindow()
window:show()
local textView = ZFUITextView.ClassData():newInstance()
window:child(textView):alignTop():margin(40)
textView:text('hello wolrd')
local button = ZFClass.classForName('ZFUIButtonBasic'):newInstance()
window:child(button):alignBottom():margin(40)
button:label():text('click me')
button:onClick(function (zfargs)
ZFLog('button clicked: %s', zfargs:sender())
end)
both lua and cpp can dynamic register class and method, even for existing class
#include "ZFLua.h"
ZFMAIN_ENTRY() {
ZFDynamic()
.classBegin("MyBaseView", "ZFUIView")
.method("void", "testFunc", ZFMP()
.mp("zfstring", "testParam0")
, [](const ZFArgs &zfargs) {
ZFLogTrim() << zfargs.ownerMethod() << " called, param0: " << zfargs.param0();
})
.classEnd();
ZFLuaExecute(
"ZFDynamic()\n"
" :classBegin('MyChildView', 'MyBaseView')\n"
" :method('void', 'testFunc', ZFMP()\n"
" :mp('zfstring', 'testParam0')\n"
" , function(zfargs)\n"
" zfargs:callSuper()\n"
" ZFLogTrim('%s called, param0: %s', zfargs:ownerMethod(), zfargs:param0())\n"
" end)\n"
" :classEnd()\n"
"\n"
"local myView = MyChildView()\n"
"myView:testFunc('luaParam0')\n"
);
zfauto obj = ZFClass::classForName("MyChildView")->newInstance();
obj->invoke("testFunc", zfobj<v_zfstring>("cppParam0"));
ZFMethodAlias(ZFMethodForName("MyChildView", "testFunc"), "testAliased");
ZFLuaExecute(
"local myView = MyChildView()\n"
"myView:testAliased('luaParam0')\n"
);
}
ZFDynamic()
:classBegin('MyObj', 'ZFStyle')
:property('zfstring', 'myProp')
:classEnd()
:classBegin('MyContainer', 'ZFStyle')
:property('MyObj', 'myObj', MyObj())
:property('ZFArray', 'myObjArr', ZFArray())
:property('ZFMap', 'myObjMap', ZFMap())
:classEnd()
local obj = MyContainer()
obj:myObj():myProp('123')
obj:myObjArr()
:add(MyObj():myProp('456'))
:add(MyObj():myProp('789'))
obj:myObjMap()
:set('456', MyObj():myProp('456'))
:set('789', MyObj():myProp('789'))
ZFObjectToXml(ZFOutputForConsole(), obj)
ZFObjectToJson(ZFOutputForConsole(), obj)
example: chain http and zip file, and R/W contents in the zip file just like normal local file
#include "ZFCore.h"
ZFMAIN_ENTRY() {
// before
ZFPathInfoTreePrint(ZFPathInfo("res:"));
ZFResExtPathAdd("ZFCompress:http:http://192.168.xxx.xxx/xxx.zip|");
// after
ZFPathInfoTreePrint(ZFPathInfo("res:"));
ZFInputRead(ZFLogTrim(), ZFInputForRes("path/in/zip/file.txt"));
}
- Download necessary files
- Setup set up necessary environment for ZFFramework
- Tutorial quick tutorial to code with ZFFramework
- FAQ
-
for the core modlue:
- C++03 compatible compiler (require templates, no boost/RTTI/exceptions required)
- STL containers (require: map/unordered_map/vector/deque/list), or supply custom wrapper
-
for the implementation module:
- depends on the actual platform implementation
-
minimum requirement
-
powerful reflection, serialzation, styleable logic
- for how powerful ZFFramework is, you may refer to Feature page
- automatic lua binding, no extra bind code or config are necessary
- automatic serialization
- enhanced global event observer and event filter
-
fully modularization, "core + protocol + dynamic implementation" design
support any platform if you are able to supply a native C++ implementation, most of implementation can be replaced easily and dynamically, all implementation is required only if its owner module being used
-
easy to communicate with native code
even to embed UI elements and native UI elements with each other
ZFFramework is under MIT license, feel free to copy or modify or use it
-
project home page: http://ZFFramework.com
-
repo: https://github.com/ZFFramework/ZFFramework
Issues or Pull Request are welcome
if you like my work, buy me a coffee?