本文整理汇总了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;
}
示例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);
}
示例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");
}
}
示例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);
}
示例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;
}