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


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

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


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

示例1: GetProgramDir

TSimpleLemmer::TSimpleLemmer(const Stroka& path) {
    Stroka libPath = path;
    if (path.length() == 0) {
        Stroka prgDir = GetProgramDir();
        if ((prgDir.length() > 1 && prgDir[1] == ':') || (prgDir.length() > 0 && prgDir[0] == '/'))
            libPath = prgDir;
        else
            libPath = GetCwd() + Stroka("/") + prgDir;
        SlashFolderLocal(libPath);
        libPath += Stroka("libmystem_c_binding.so");
        //Cerr << "libPath == " << libPath << Endl;
    }

    Lib.Open(~libPath, RTLD_NOW | RTLD_DEEPBIND | RTLD_NODELETE);

    if (!IsInitialized())
        yexception() << "Can't load lemmer from \"" << path << "\"";
}
开发者ID:johny-nsk,项目名称:tomita-parser,代码行数:18,代码来源:extlemmer.cpp

示例2: resolvepath

bool resolvepath(Stroka &folder, const Stroka &home)
{
    YASSERT(home && home.at(0) == '/');
    if (!folder) {
        return false;
    }
    // may be from windows
    char *ptr = folder.begin();
    while ((ptr = strchr(ptr, '\\')) != 0)
        *ptr = '/';

    if (folder.at(0) == '~') {
        if (folder.length() == 1 || folder.at(1) == '/') {
            folder = GetHomeDir() + (~folder + 1);
        } else {
            char* buf = (char*)alloca(folder.length()+1);
            strcpy(buf, ~folder + 1);
            char* p = strchr(buf, '/');
            if (p)
                *p++ = 0;
            passwd* pw = getpwnam(buf);
            if (pw) {
                folder = pw->pw_dir;
                folder += "/";
                if (p)
                    folder += p;
            } else {
                return false; // unknown user
            }
        }
    }
    int len = folder.length() + home.length() + 1;
    char* path = (char*)alloca(len);
    if (folder.at(0) != '/') {
        strcpy(path, ~home);
        strcpy(strrchr(path, '/')+1, ~folder); // the last char must be '/' if it's a dir
    } else {
        strcpy(path, ~folder);
    }
    len = strlen(path)+1;
    // grabbed from url.cpp
    char *newpath = (char*)alloca(len+2);
    const char **pp = (const char**)alloca(len*sizeof(char*));
    int i = 0;
    for (char* s = path; s;) {
        pp[i++] = s;
        s = strchr(s, '/');
        if (s)
            *s++ = 0;
    }

    for (int j = 1; j < i;) {
        const char*& p = pp[j];
        if (strcmp(p, ".") == 0 || strcmp(p,"") == 0) {
            if (j == i-1) {
                p = "";
                break;
            } else {
                memmove(pp+j, pp+j+1, (i-j-1)*sizeof(p));
                i--;
            }
        } else if (strcmp(p, "..") == 0) {
            if (j == i-1) {
                if (j == 1) {
                    p = "";
                } else {
                    i--;
                    pp[j-1] = "";
                }
                break;
            } else {
                if (j == 1) {
                    memmove(pp+j, pp+j+1, (i-j-1)*sizeof(p));
                    i--;
                } else {
                    memmove(pp+j-1, pp+j+1, (i-j-1)*sizeof(p));
                    i-=2;
                    j--;
                }
            }
        } else
            j++;
    }

    char* s = newpath;
    for (int k = 0; k < i; k++) {
        s = strchr(strcpy(s, pp[k]), 0);
        *s++ = '/';
    }
    *(--s) = 0;
    folder = newpath;
    return true;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:93,代码来源:dirut.cpp


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