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


C++ Stroka::find方法代码示例

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


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

示例1: SlashFolderLocal

void SlashFolderLocal(Stroka &folder)
{
    if (!folder)
        return;
#ifdef _win32_
    size_t pos;
    while ((pos = folder.find('/')) != Stroka::npos)
        folder.replace(pos, 1, LOCSLASH_S);
#endif
    if (folder[+folder-1] != LOCSLASH_C)
        folder.append(LOCSLASH_S);
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:12,代码来源:dirut.cpp

示例2: PathExists

bool PathExists(const Stroka& path) {
    VERIFY(path.find('\0') == Stroka::npos);
    return isexist(~path);
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:4,代码来源:dirut.cpp

示例3: main

int main(int argc, char** argv) {
    Opt2 opt(argc, argv, "rxcpulma:z:qo:", IntRange(1, 999999), "hexdump=x,cat=c,plain=p,unpack=u,list=l,md5=m,recursive=r,quiet=q,prepend=z,append=a,output=o");
    const bool hexdump   = opt.Has('x', "- produce hexdump");
    const bool cat       = opt.Has('c', "- do not store keys (file names), just cat uncompressed files");
    const bool doNotZip  = opt.Has('p', "- do not use compression");
    const bool unpack    = opt.Has('u', "- unpack archive in current dir");
    const bool list      = opt.Has('l', "- list files in archive");
    const bool listMd5   = opt.Has('m', "- list files in archive with md5");
    const bool recursive = opt.Has('r', "- read all files under each directory, recursively");
    Quiet                = opt.Has('q', "- do not output progress on stderr.");
    Stroka prepend = opt.Arg('z', "<PREFIX> - prepend string to output", 0);
    Stroka append  = opt.Arg('a', "<SUFFIX> - append string to output", 0);
    const Stroka outputf = opt.Arg('o', "<FILE> - output to file instead stdout", 0);
    opt.AutoUsageErr("<file>..."); // "Files or directories to archive."

    SubstGlobal(append, "\\n", "\n");
    SubstGlobal(prepend, "\\n", "\n");

    yvector<TRec> recs;
    for (size_t i = 0; i != opt.Pos.size(); ++i) {
        Stroka path = opt.Pos[i];
        size_t off = 0;
#ifdef _win_
        if (path[0] > 0 && isalpha(path[0]) && path[1] == ':')
            off = 2; // skip drive letter ("d:")
#endif // _win_
        const size_t pos = path.find(':', off);
        TRec cur;
        cur.Path = path.substr(0, pos);
        if (pos != Stroka::npos)
            cur.Prefix = path.substr(pos + 1);
        cur.Recursive = recursive;
        cur.Fix();
        recs.push_back(cur);
    }

    try {
        if (listMd5) {
            for (yvector<TRec>::const_iterator it = recs.begin(); it != recs.end(); ++it) {
                ListArchiveMd5(it->Path);
            }
        } else if (list) {
            for (yvector<TRec>::const_iterator it = recs.begin(); it != recs.end(); ++it) {
                ListArchive(it->Path);
            }
        } else if (unpack) {
            for (yvector<TRec>::const_iterator it = recs.begin(); it != recs.end(); ++it) {
                UnpackArchive(it->Path);
            }
        } else {
            TAutoPtr<TOutputStream> outf(OpenOutput(outputf));
            TOutputStream* out = outf.Get();
            THolder<TOutputStream> hexout;

            if (hexdump) {
                hexout.Reset(new THexOutput(out));
                out = hexout.Get();
            }

            outf->Write(~prepend, +prepend);

            if (cat) {
                for (yvector<TRec>::const_iterator it = recs.begin(); it != recs.end(); ++it) {
                    it->Recurse(*out);
                }
            } else {
                TArchiveWriter w(out, !doNotZip);
                for (yvector<TRec>::const_iterator it = recs.begin(); it != recs.end(); ++it) {
                    it->Recurse(w);
                }
                w.Finish();
            }

            outf->Write(~append, +append);

            try {
                out->Finish();
            } catch (...) {
            }
        }
    } catch (...) {
        Cerr << CurrentExceptionMessage() << Endl;
        return 1;
    }

    return 0;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:87,代码来源:main.cpp

示例4: GoodPath

static inline bool GoodPath(const Stroka& path) {
    return path.find('/') != Stroka::npos;
}
开发者ID:Mirocow,项目名称:balancer,代码行数:3,代码来源:execpath.cpp

示例5: main

int main(int argc, char** argv) {
    Opt2 opt(argc, argv, "rxa:z:q", IntRange(1, 999999), "hexdump=x,recursive=r,quiet=q,prepend=z,append=a");
    bool hexdump         = opt.Has('x', "- produce hexdump");
    const bool recursive = opt.Has('r', "- read all files under each directory, recursively");
    Quiet                = opt.Has('q', "- do not output progress on stderr.");
    const Stroka prepend = opt.Arg('z', "<PREFIX> - prepend string to output verbatim", 0);
    const Stroka append  = opt.Arg('a', "<SUFFIX> - append string to output verbatim", 0);
    opt.AutoUsageErr("<file>..."); // "Files or directories to archive."

    yvector<TRec> recs;
    for (size_t i = 0; i != opt.Pos.size(); ++i) {
        Stroka path = opt.Pos[i];
        size_t off = 0;
#ifdef _win_
        if (path[0] > 0 && isalpha(path[0]) && path[1] == ':')
            off = 2; // skip drive letter ("d:")
#endif // _win_
        const size_t pos = path.find(':', off);
        TRec cur;
        cur.Path = path.substr(0, pos);
        if (pos != Stroka::npos)
            cur.Prefix = path.substr(pos + 1);
        cur.Recursive = recursive;
        cur.Fix();
        recs.push_back(cur);
    }

    try {
        TAutoPtr<TOutputStream> outf(OpenOutput(""));
        TOutputStream* out = outf.Get();
        THolder<TOutputStream> hexout;

        if (hexdump) {
            hexout.Reset(new THexOutput(out));
            out = hexout.Get();
        }

        outf->Write(~prepend, +prepend);

        TArchiveWriter w(out);

        for (yvector<TRec>::const_iterator it = recs.begin(); it != recs.end(); ++it) {
            const TRec& rec = *it;

            if (IsDir(rec.Path)) {
                it->Recurse(w);
            } else {
                Append(w, it->Path, it->Prefix + "/" + GetFile(it->Path));
            }
        }

        w.Finish();
        outf->Write(~append, +append);
        out->Finish();
    } catch (...) {
        Cerr << CurrentExceptionMessage() << Endl;

        return 1;
    }

    return 0;
}
开发者ID:Mirocow,项目名称:balancer,代码行数:62,代码来源:main.cpp


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