当前位置: 首页>>代码示例>>C++>>正文


C++ Dispatcher::addRule方法代码示例

本文整理汇总了C++中Dispatcher::addRule方法的典型用法代码示例。如果您正苦于以下问题:C++ Dispatcher::addRule方法的具体用法?C++ Dispatcher::addRule怎么用?C++ Dispatcher::addRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dispatcher的用法示例。


在下文中一共展示了Dispatcher::addRule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    struct { char* settingsFile; } settings;
    fuse_opt shellOptions[] =
    {
        { "settings=%s", 0, NULL },
        { NULL }
    };
    fuse_args arguments = FUSE_ARGS_INIT(argc, argv);
    if (fuse_opt_parse(&arguments, &settings, shellOptions, NULL) == -1)
    {
        return (EXIT_FAILURE);
    }

    LIBXML_TEST_VERSION
    convertfs_context.cache = 0;
    Dispatcher* dispatcher = new Dispatcher;
    xmlTextReaderPtr reader = xmlReaderForFile(settings.settingsFile, NULL, 0);
    while (xmlTextReaderRead(reader) == 1)
    {
        const xmlChar* name = xmlTextReaderConstName(reader);
        if (!strcmp((const char*)name, "rule"))
        {
            Classificator* classificator = 0;
            Filter* filter = 0;
            const xmlChar* classificatorType = xmlTextReaderGetAttribute(reader, (const xmlChar*)"classificator-type");
            const xmlChar* classificatorData = xmlTextReaderGetAttribute(reader, (const xmlChar*)"classificator-data");
            const xmlChar* filterType = xmlTextReaderGetAttribute(reader, (const xmlChar*)"filter-type");
            const xmlChar* filterData = xmlTextReaderGetAttribute(reader, (const xmlChar*)"filter-data");
            if (!strcmp((const char*)classificatorType, "any"))
            {
                classificator = new AnyClassificator;
            }
            else if (!strcmp((const char*)classificatorType, "ext"))
            {
                classificator = new ExtensionClassificator((const char*)classificatorData);
            }

            if (!strcmp((const char*)filterType, "ignore"))
            {
                filter = new IgnoreFilter;
            }
            else if (!strcmp((const char*)filterType, "windows-names"))
            {
                filter = new WindowsNamesFilter("_");
            }
            else if (!strcmp((const char*)filterType, "command"))
            {
                std::vector<std::string> v;
                std::string s((const char*)filterData);
                boost::algorithm::split(v, s, boost::is_any_of(","));
                filter = new ConvertFilter(v[1], v[0]);
            }

            if (filter && classificator)
            {
                dispatcher->addRule(classificator, filter);
            }
        }
        else if (!strcmp((const char*)name, "source"))
        {
            const xmlChar* directory = xmlTextReaderGetAttribute(reader, (const xmlChar*)"directory");
            convertfs_context.tree = new Tree((const char*)directory, dispatcher);
        }
        else if (!strcmp((const char*)name, "cache"))
        {
            const xmlChar* directory = xmlTextReaderGetAttribute(reader, (const xmlChar*)"directory");
            const xmlChar* enabled = xmlTextReaderGetAttribute(reader, (const xmlChar*)"enabled");
            if (!strcmp((const char*)enabled, "1"))
            {
                convertfs_context.cache = new Cache((const char *)directory);
            }
        }
    }

    fuse_operations operations;
    memset(&operations, 0, sizeof(fuse_operations));
    operations.getattr = convertfs_getattr;
    operations.readdir = convertfs_readdir;
    operations.open    = convertfs_open;
    operations.read    = convertfs_read;
    operations.release = convertfs_release;

    return fuse_main(arguments.argc, arguments.argv, &operations, NULL);
}
开发者ID:themylogin,项目名称:ConvertFS,代码行数:85,代码来源:main.cpp


注:本文中的Dispatcher::addRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。