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


C++ Strings::insert方法代码示例

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


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

示例1: while

// Find all strings
StringFinder::Strings
StringFinder::findAllStrings(MemoryMap::ConstConstraints where) const {
    Strings retval;
    while (Sawyer::Optional<String> string = findString(where)) {
        retval.insert(string->address(), *string);
        where = where.atOrAfter(string->address() + string->nBytes());
    }
    return retval;
}
开发者ID:Sciumo,项目名称:rose,代码行数:10,代码来源:BinaryString.C

示例2: init

void PluginRegistry::init()
{
    // for each directory
    for( Strings::const_iterator i = _directories.begin();
         i != _directories.end(); ++i )
    {
        const std::string& dir = *i;
        LBLOG( LOG_PLUGIN ) << "Searching plugins in " << dir << std::endl;

#ifdef _WIN32
        Strings files = lunchbox::searchDirectory( dir, "EqualizerCompressor*.dll");
        const char DIRSEP = '\\';
#elif defined (Darwin)
        Strings files = lunchbox::searchDirectory( dir,
                                               "libEqualizerCompressor*.dylib");
        Strings oldFiles = lunchbox::searchDirectory( dir,
                                                  "libeqCompressor*.dylib" );
        files.insert( files.end(), oldFiles.begin(), oldFiles.end( ));
        const char DIRSEP = '/';
#else
        Strings files = lunchbox::searchDirectory( dir,
                                               "libEqualizerCompressor*.so" );
        Strings oldFiles = lunchbox::searchDirectory( dir, "libeqCompressor*.so" );
        files.insert( files.end(), oldFiles.begin(), oldFiles.end( ));
        const char DIRSEP = '/';
#endif
        
        // for each file found in the directory
        for( Strings::const_iterator j = files.begin(); j != files.end(); ++j )
        {
            // build path + name of library
            const std::string libraryName =
                dir.empty() ? *j : dir + DIRSEP + *j;
            addPlugin( libraryName );
        }
    }

    for( Plugins::const_iterator i = _plugins.begin(); i != _plugins.end(); ++i)
    {
        Plugin* plugin = *i;
        plugin->initChildren();
    }
}
开发者ID:aoighost,项目名称:Equalizer,代码行数:43,代码来源:pluginRegistry.cpp

示例3: runLINK


//.........这里部分代码省略.........
        {
            lnkfilename = FileName::forceExt(global.params.exefile, "lnk");
            File flnk(lnkfilename);
            flnk.setbuffer(p, plen);
            flnk.ref = 1;
            if (flnk.write())
                error(Loc(), "error writing file %s", lnkfilename);
            if (strlen(lnkfilename) < plen)
                sprintf(p, "@%s", lnkfilename);
        }

        const char *linkcmd = getenv("LINKCMD");
        if (!linkcmd)
            linkcmd = "link";
        int status = executecmd(linkcmd, p);
        if (lnkfilename)
        {
            remove(lnkfilename);
            FileName::free(lnkfilename);
        }
        return status;
    }
#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
    pid_t childpid;
    int status;

    // Build argv[]
    Strings argv;

    const char *cc = getenv("CC");
    if (!cc)
        cc = "gcc";
    argv.push(cc);
    argv.insert(1, global.params.objfiles);

#if __APPLE__
    // If we are on Mac OS X and linking a dynamic library,
    // add the "-dynamiclib" flag
    if (global.params.dll)
        argv.push("-dynamiclib");
#elif __linux__ || __FreeBSD__ || __OpenBSD__ || __sun
    if (global.params.dll)
        argv.push("-shared");
#endif

    // None of that a.out stuff. Use explicit exe file name, or
    // generate one from name of first source file.
    argv.push("-o");
    if (global.params.exefile)
    {
        argv.push(global.params.exefile);
    }
    else if (global.params.run)
    {
#if 1
        char name[L_tmpnam + 14 + 1];
        strcpy(name, P_tmpdir);
        strcat(name, "/dmd_runXXXXXX");
        int fd = mkstemp(name);
        if (fd == -1)
        {   error(Loc(), "error creating temporary file");
            return 1;
        }
        else
            close(fd);
        global.params.exefile = mem.strdup(name);
开发者ID:monarchdodra,项目名称:dmd,代码行数:67,代码来源:link.c

示例4: runLINK


//.........这里部分代码省略.........
        {
            lnkfilename = FileName::forceExt(global.params.exefile, "lnk");
            File flnk(lnkfilename);
            flnk.setbuffer(p, plen);
            flnk.ref = 1;
            if (flnk.write())
                error(0, "error writing file %s", lnkfilename);
            if (lnkfilename->len() < plen)
                sprintf(p, "@%s", lnkfilename->toChars());
        }

        char *linkcmd = getenv("LINKCMD");
        if (!linkcmd)
            linkcmd = "link";
        int status = executecmd(linkcmd, p, 1);
        if (lnkfilename)
        {
            remove(lnkfilename->toChars());
            delete lnkfilename;
        }
        return status;
    }
#elif linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
    pid_t childpid;
    int status;

    // Build argv[]
    Strings argv;

    const char *cc = getenv("CC");
    if (!cc)
        cc = "gcc";
    argv.push((char *)cc);
    argv.insert(1, global.params.objfiles);

#if __APPLE__
    // If we are on Mac OS X and linking a dynamic library,
    // add the "-dynamiclib" flag
    if (global.params.dll)
        argv.push((char *) "-dynamiclib");
#elif linux || __FreeBSD__ || __OpenBSD__ || __sun
    if (global.params.dll)
        argv.push((char *) "-shared");
#endif

    // None of that a.out stuff. Use explicit exe file name, or
    // generate one from name of first source file.
    argv.push((char *)"-o");
    if (global.params.exefile)
    {
        if (global.params.dll)
            global.params.exefile = FileName::forceExt(global.params.exefile, global.dll_ext)->toChars();
        argv.push(global.params.exefile);
    }
    else
    {   // Generate exe file name from first obj name
        char *n = (*global.params.objfiles)[0];
        char *e;
        char *ex;

        n = FileName::name(n);
        e = FileName::ext(n);
        if (e)
        {
            e--;                        // back up over '.'
            ex = (char *)mem.malloc(e - n + 1);
开发者ID:shoo,项目名称:dmd,代码行数:67,代码来源:link.c

示例5: of

int
main(int argc, char *argv[]) {
    using namespace Sawyer::CommandLine;
    typedef std::vector<std::string> Strings;

    // Usage:
    //    translator --command=CMD NAMES [-- SWITCHES...]         -- runs: CMD SWITCHES NAMES
    //    translator NAMES -- SWITCHES                        -- runs ROSE on SWITCHES NAMES
    // NAMES are always de-escaped and created
    Parser p;
    std::string cmd;
    p.with(Switch("command").argument("cmd", anyParser(cmd)));
    Strings args = p.parse(argc, argv).apply().unreachedArgs();

    // Expand the "+SOMETHING+" escapes in all arguments.
    typedef Sawyer::Container::Map<std::string, std::string> Translations;
    Translations map;
    map.insert("+PLUS+",        "+");
    map.insert("+SPACE+",       " ");
    map.insert("+DOLLAR+",      "$");
    map.insert("+STAR+",        "*");
    map.insert("+HASH+",        "#");
    map.insert("+SQUOTE+",      "'");
    map.insert("+DQUOTE+",      "\"");
    map.insert("+DOT+",         ".");
    map.insert("+SLASH+",       "/");
    map.insert("+BSLASH+",      "\\");
    for (Strings::iterator arg = args.begin(); arg != args.end(); ++arg) {
        std::string translated;
        for (size_t i=0; i<arg->size(); ++i) {
            size_t endPlus;
            if ((*arg)[i] == '+' && (endPlus=arg->find('+', i+1)) != std::string::npos) {
                std::string token = arg->substr(i, endPlus+1-i);
                translated += map.getOrElse(token, token);
                i = endPlus;
            } else {
                translated += (*arg)[i];
            }
        }
        *arg = translated;
    }

    // If there's a '--' argument, then create a stub C source file for each argument before the '--', move them all to the
    // end, and remove the '--'. I.e., if the arguments are "a b -- c d" then create files "a" and "b" and then rearrange the
    // arguments to read "c d a b".  If there's no "--", then create source files for all the arguments but don't rearrange
    // anything.
    Strings::iterator doubleHyphen = std::find(args.begin(), args.end(), "--");
    for (Strings::iterator arg = args.begin(); arg != doubleHyphen; ++arg) {
        std::ofstream of(arg->c_str());
        ASSERT_require(!of.bad());
        of <<"int main() {}\n";
    }
    if (doubleHyphen != args.end()) {
        Strings tmp(args.begin(), doubleHyphen);
        tmp.insert(tmp.begin(), ++doubleHyphen, args.end());
        args = tmp;
    }

    // Either the ROSE translator or some other command
    if (cmd.empty()) {
        std::cout <<"translator args are:";
        BOOST_FOREACH (const std::string &arg, args)
            std::cout <<" \"" <<StringUtility::cEscape(arg) <<"\"";
        std::cout <<"\n";
        
        args.insert(args.begin(), argv[0]);
        SgProject *project = frontend(args);
        ASSERT_not_null(project);
        exit(backend(project));
    }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:70,代码来源:translator.C


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