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


C++ Arg::GetName方法代码示例

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


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

示例1: processMethodBody

int processMethodBody(Method *m, string& buf)
{
    cout << "------Begin processMethodBody------"<< endl;
    map<string, Arg*>::iterator it;
    for (it = m->GetArgMap().begin(); it != m->GetArgMap().end(); it++)
    {
        Arg *arg = it->second;
        string body_str;
        if (arg->GetDir() == "in")
        {
            readTemplateFile("/home/shankar/Dropbox/ASU_Courses/SmartHome/home_automation/smartgateway/codegen/template/smartobject_method_body_dir_in.template", body_str);
        }
        else
        {
            readTemplateFile("/home/shankar/Dropbox/ASU_Courses/SmartHome/home_automation/smartgateway/codegen/template/smartobject_method_body_dir_out.template", body_str);
        }

        std::string::const_iterator start, end;
        boost::regex exp("\\?<(\\w+)>");
        boost::match_results<std::string::const_iterator> what;
        boost::match_flag_type flags = boost::match_default;
        start = body_str.begin();
        end = body_str.end();

        while (regex_search(start, end, what, exp, flags))
        {
            string res = string(what[0].first, what[0].second);
            string command = string(what[1].first, what[1].second);
            cout << "res = ";
            cout << res << endl;
            cout << "command = ";
            cout << command << endl;

            /*
             * Now we have to replace the res with what the command specifies
             * For eg:
             * if res = "?<nocapital>" and command = "nocapital", then
             * 		replace "?<nocapital>" with "lighting".
             * if res = "?<allcapital>" and command = "allcapital", then
             * 		replace "?<allcapital>" with "LIGHTING".
             */
            if (command == "argname")
            {
                body_str.replace((what[0].first - body_str.begin()), res.size(), arg->GetName());
                start = body_str.begin();
            }
            else
            {
                start = what[0].second;
            }

            end = body_str.end();
        }

        buf.append(body_str);
    }
    cout << "------End processMethodBody------"<< endl;

    return 0;
}
开发者ID:shaan420,项目名称:smartgateway,代码行数:60,代码来源:smartobject_codegen.cpp

示例2: processMethodDecl

int processMethodDecl(Method *m, string& buf)
{
    cout << "------Begin processMethodDecl------"<< endl;
    readTemplateFile("/home/shankar/Dropbox/ASU_Courses/SmartHome/home_automation/smartgateway/codegen/template/smartobject_method_decl.template",
                     buf);
    /* buf has the file data */
    std::string::const_iterator start, end;
    boost::regex exp("\\?<(\\w+)>");
    boost::match_results<std::string::const_iterator> what;
    boost::match_flag_type flags = boost::match_default;
    start = buf.begin();
    end = buf.end();

    while (regex_search(start, end, what, exp, flags))
    {
        string res = string(what[0].first, what[0].second);
        string command = string(what[1].first, what[1].second);
        cout << "res = ";
        cout << res << endl;
        cout << "command = ";
        cout << command << endl;
        //start = what[0].second;

        /*
         * Now we have to replace the res with what the command specifies
         * For eg:
         * if res = "?<nocapital>" and command = "nocapital", then
         * 		replace "?<nocapital>" with "lighting".
         * if res = "?<allcapital>" and command = "allcapital", then
         * 		replace "?<allcapital>" with "LIGHTING".
         */
        if (command == "methodname")
        {
            //buf.replace((what[0].first - start), res.size(), m->GetName());
            buf.replace((what[0].first - buf.begin()), res.size(), m->GetName());
            //start = what[0].first + m->GetName().size();
            start = buf.begin();
            //start = what[0].first;
        }
        else if (command == "arglist")
        {
            string arglist_str;
            map<string, Arg*>::iterator it;
            for (it = m->GetArgMap().begin(); it != m->GetArgMap().end(); it++)
            {
                Arg *arg = it->second;
                if (arg->GetDir() == "in")
                {
                    arglist_str = arglist_str + arg->GetType() + " " + arg->GetName() + ",";
                }
                else
                {
                    arglist_str = arglist_str + arg->GetType() + " *" + arg->GetName() + ",";
                }
            }

            cout << what[0].first - buf.begin() << endl;
            buf.replace((what[0].first - buf.begin()), res.size(), arglist_str);
            cout << buf << endl;
            start = buf.begin();
        }
        else
        {
            start = what[0].second;
        }

        end = buf.end();
    }

    cout << buf << endl;

    cout << "------End processMethodDecl------"<< endl;
    return 0;
}
开发者ID:shaan420,项目名称:smartgateway,代码行数:74,代码来源:smartobject_codegen.cpp


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