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


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

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


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

示例1: FillDocInfo

void CDocListRetrieverFromDisc::FillDocInfo(SDocumentAttribtes& attrs)
{
    Stroka strFilePath = m_SmartFileFind.GetFoundFilePath(m_iCurPath);

    Stroka strURL;
    if (strFilePath == m_strSearchDir) {
        TStringBuf left, right;
        PathHelper::Split(strFilePath, left, right);
        strURL = ToString(right);
    } else
        strURL = strFilePath.substr(m_strSearchDir.size());

    if (strURL.empty())
        ythrow yexception() << "Can't build url for file \"" << strFilePath
                              << "\" with searchdir \"" << m_strSearchDir << "\".";

    TransformBackSlash(strURL);

    attrs.m_strUrl = strURL;

    Stroka strTime;
    if (stroka(m_strLTM) == "file") {
        CTime lw_time = m_SmartFileFind.GetFoundFileInfo(m_iCurPath).m_LastWriteTime;
        strTime = lw_time.Format("%d.%m.%Y %H:%M:%S");
    }

    if (strTime.empty())
        strTime = m_strStartTime;

    attrs.m_strTitle = CharToWide(strTime);
    attrs.m_strSource = strURL;
    attrs.m_strTitle = CharToWide(attrs.m_strSource);     // ??? rewriting
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:33,代码来源:doclistretrieverfromdisc.cpp

示例2: cutFirstSlash

static Stroka cutFirstSlash(const Stroka& fileName) {
    if (fileName[0] == '/') {
        return fileName.substr(1);
    } else {
        return fileName;
    }
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:7,代码来源:main.cpp

示例3: GetInterviewFio

Wtroka CProcessor::GetInterviewFio(Stroka strUrl) const
{
    ymap<Stroka, Wtroka>::const_iterator it = InterviewUrl2Fio.find(strUrl);
    if (it != InterviewUrl2Fio.end())
        return it->second;
    static const Stroka kHTTP = "http://";
    if (strUrl.has_prefix(kHTTP)) {
        strUrl = strUrl.substr(kHTTP.size());
        return GetInterviewFio(strUrl);
    }
    return Wtroka();
}
开发者ID:leotop,项目名称:tomita-parser,代码行数:12,代码来源:processor.cpp

示例4: GetBaseName

Stroka GetBaseName(const Stroka& path) {
    size_t lastSlash = path.find_last_of(LOCSLASH_C);
    return lastSlash == Stroka::npos ? path : path.substr(lastSlash + 1);
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:4,代码来源:dirut.cpp

示例5: 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

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