4.3 API/FcitxConfig

From Fcitx
Revision as of 20:24, 22 April 2013 by Weng Xuetian (talk | contribs)
Jump to navigation Jump to search

This is only draft, feel free to improve.

Comment

merge argument is very ugly, any idea about how to improve? Weng Xuetian 16:24, 22 April 2013 (EDT)


Draft

Rename FcitxConfigFile -> FcitxConfig


// backend
typedef FcitxConfigDesc* (*FcitxConfigDescGet)(void* arg, const char* name);
typedef FcitxConfig* (*FcitxConfigGet)(void* arg, const char* path, const char* name, boolean merge);
typedef FcitxConfig** (*FcitxConfigGetMulti)(void* arg, const char* path, const char* prefix, const char* suffix, boolean merge);

typedef struct _FcitxConfigBackend {
    void *data;
    FcitxConfigDescGet descGet;
    FcitxConfigGet configGet;
    FcitxConfigGetMulti configGetMulti;
    FcitxDestroyNotify destroyData;
    FcitxCallBack padding1;
    FcitxCallBack padding2;
    FcitxCallBack padding3;
    FcitxCallBack padding4;
    FcitxCallBack padding5;
    FcitxCallBack padding6;
    FcitxCallBack padding7;
    FcitxCallBack padding8;
} FcitxConfigBackend;

// configmanager, keep desc cache, and parse new config
typedef struct _FcitxConfigManager FcitxConfigManager;
FcitxConfigManager* FcitxConfigManagerCreate(FcitxConfigBackend* backend);
boolean FcitxConfigManagerLoad(FcitxConfigManager* manager, const char* path, const char* name, const char* configDescName, boolean merge, FcitxGenericConfig* config);

void FcitxConfigManagerSave(FcitxConfigManager* manager, const char* name, const char* configdesc, FcitxGenericConfig* config);
void FcitxConfigManagerDestroy(FcitxConfigManager* manager);