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


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

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


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

示例1: ut_real

int ut_real(Stroka args, bool err_exp, const char *A_exp, int b_exp, bool a_exp, const char *p1_exp, const char *p2_exp) {
    char *argv[32];
    int argc = sf(' ', argv, args.begin());
    Opt2 opt(argc, argv, ut_optspec, 2, "option-1=A,option-2=a,");
    const char *A = opt.Arg('A', "<qqq> - blah");
    int         b = opt.Int('b', "<rrr> - blah", 2);
    bool        a = opt.Has('a', "- blah");
    /*const char *C = */opt.Arg('C', "<ccc> - blah", 0);

    if (opt_ut_verbose)
        opt.AutoUsage("");
    if (opt.HasErrors != err_exp)
        return 1;
    if (err_exp)
        return false;
    if (!A && A_exp || A && !A_exp || A && A_exp && strcmp(A, A_exp))
        return 2;
    if (b != b_exp)
        return 3;
    if (a != a_exp)
        return 4;
    if (strcmp(opt.Pos[0], p1_exp))
        return 5;
    if (strcmp(opt.Pos[1], p2_exp))
        return 6;
    return false;
}
开发者ID:Mirocow,项目名称:balancer,代码行数:27,代码来源:opt2.cpp

示例2: TestIconv

static void TestIconv(const Stroka& utf8, const Stroka& other, ECharset enc) {
    Wtroka wide0 = CharToWide(utf8, CODES_UTF8);
    Wtroka wide1 = CharToWide(other, enc);

    UNIT_ASSERT(wide0 == wide1);

    Stroka temp = WideToChar(wide0, CODES_UTF8);
    UNIT_ASSERT(temp == utf8);

    temp = WideToChar(wide0, enc);
    UNIT_ASSERT(temp == other);

    temp = Recode(enc, CODES_UTF8, other);
    UNIT_ASSERT(temp == utf8);

    temp = Recode(CODES_UTF8, enc, utf8);
    UNIT_ASSERT(temp == other);

    size_t read = 0;
    size_t written = 0;

    RECODE_RESULT res = RecodeToUnicode(enc, other.c_str(), wide1.begin(), other.size(), wide1.size(), read, written);
    UNIT_ASSERT(res == RECODE_OK);
    UNIT_ASSERT(read == other.size());
    UNIT_ASSERT(written == wide1.size());
    UNIT_ASSERT(wide0 == wide1);

    res = RecodeFromUnicode(enc, wide0.c_str(), temp.begin(), wide0.size(), temp.size(), read, written);
    UNIT_ASSERT(res == RECODE_OK);
    UNIT_ASSERT(read == wide0.size());
    UNIT_ASSERT(written == other.size());
    UNIT_ASSERT(temp == other);
}
开发者ID:Mirocow,项目名称:balancer,代码行数:33,代码来源:iconv_ut.cpp

示例3: catch

 inline void TestRaise1() {
     try {
         Throw2DontMove();
         UNIT_ASSERT(false);
     } catch (...) {
         Stroka err = CurrentExceptionMessage();
         char *ptr = err.begin();
         while ((ptr = strchr(ptr, '\\')) != 0)
             *ptr = '/';
         UNIT_ASSERT_VALUES_EQUAL(err, "util/generic/yexception_ut.cpp:8: 1 qw 12.1");
     }
 }
开发者ID:Mirocow,项目名称:balancer,代码行数:12,代码来源:yexception_ut.cpp

示例4: Stroka

static inline Stroka GetFile(const Stroka& s) {
    const char* e = s.end();
    const char* b = s.begin();
    const char* c = e - 1;

    while (c != b && !IsDelim(*c)) {
        --c;
    }

    if (c != e && IsDelim(*c)) {
        ++c;
    }

    return Stroka(c, e - c);
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:15,代码来源:main.cpp

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