本文整理汇总了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);
}
示例2: PathExists
bool PathExists(const Stroka& path) {
VERIFY(path.find('\0') == Stroka::npos);
return isexist(~path);
}
示例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;
}
示例4: GoodPath
static inline bool GoodPath(const Stroka& path) {
return path.find('/') != Stroka::npos;
}
示例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;
}