本文整理汇总了C++中CStr::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ CStr::Length方法的具体用法?C++ CStr::Length怎么用?C++ CStr::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStr
的用法示例。
在下文中一共展示了CStr::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _ScanDir
bool _ScanDir(CStr path, int mask, CStr body, qCtx *ctx, qStr *out, DIRSTATE &st)
{
BOOL bMore;
HANDLE hFind;
BOOL showdot = false;
// truncate trailing slashes
char *b = path.GetBuffer();
if (!b || !*b) return false;
char *p = path+path.Length() - 1;
while (p >= b && ISDIRSEP(*p))
--p;
if (p-b+1 > 0) {
if (*p == ':') {
showdot = true;
if (!ISDIRSEP(p[1])) {
path << '.';
b = path.GetBuffer();
p = path+path.Length() - 1;
} else
++p;
}
st.path = path;
// truncate path to parent
while (p >= b && !ISPATHSEP(*p))
--p;
if (p >= b) {
st.path.Grow(p-b+1);
} else {
st.path.Grow(0);
}
} else {
st.path = path;
}
// read all entries in the directory
WIN32_FIND_DATA *r = &st.data;
hFind = FindFirstFile(path, r);
bMore = (hFind != (HANDLE) -1);
while (bMore &&!st.bquit) {
if ((mask & r->dwFileAttributes)
&& !(r->cFileName[0]=='.'&&r->cFileName[1]=='\0')
) {
ctx->Parse(body, out);
} else if (showdot && r->cFileName[0]=='.'&&r->cFileName[1]=='\0') {
ctx->Parse(body, out);
}
bMore = FindNextFile(hFind, r);
}
FindClose(hFind);
return true;
} // dir_scan
示例2: EvalTrim
void EvalTrim(const void *data, qCtx *ctx, qStr *out, qArgAry *args) {
VALID_ARGC("trim", 1, 2);
if (args->Count() > 1) {
CStr str = (*args)[0];
if (str.IsEmpty())
return;
CStr toks = (*args)[1];
if (toks.Length() == 0)
out->PutS(str);
else if (toks.Length() == 1)
out->PutS(str.Trim(*toks));
else {
const char *b, *p = str;
size_t i = strspn(p,toks);
b = p += i;
p += str.Length() - 1 - i;
while(p >= b && strchr(toks.Data(), *p))
--p;
++p;
out->PutS(b, p - b);
}
} else
out->PutS((*args)[0].Trim());
}
示例3: EvalCsvQuote
void EvalCsvQuote(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
if (args->Count() > 0) {
CStr s = (*args)[0];
char *bi = s.SafeP();
const char *pi = bi;
while (*pi) {
if (*pi == '\"' || *pi == ',') {
CStr o(s.Length()*2 + 2);
char *po = o.SafeP();
*po++ = '\"';
memcpy(po, s.Data(), pi-bi);
CsvQuoteQ(pi, po);
*po++ = '\"';
o.Grow(po - o.Data());
out->PutS(o,o.Length());
return;
}
++pi;
}
out->PutS(s,s.Length());
}
}
示例4: EvalRTrim
void EvalRTrim(const void *data, qCtx *ctx, qStr *out, qArgAry *args) {
VALID_ARGC("ltrim", 1, 2);
if (args->Count() > 1) {
CStr str = (*args)[0];
if (str.IsEmpty())
return;
CStr toks = (*args)[1];
if (toks.Length() == 0)
out->PutS(str);
else if (toks.Length() == 1)
out->PutS(str.RTrim(*toks));
else {
const char *p, *b = str;
p = b + str.Length() - 1;
while(p >= b && strchr((const char *)toks, *p))
--p;
++p;
out->PutS(b, p - b);
}
} else
out->PutS((*args)[0].RTrim());
}
示例5: ReplaceStrI
CStr ReplaceStrI(CStr in, CStr from, CStr to)
{
char *p;
int fl = from.Length(), tl = to.Length(), il = in.Length();
if (fl <= 0 || fl > il)
return in;
if (fl == tl) {
char *i = in.SafeP();
char *b = i;
while ((p = stristr(i, (il-(i-b)), from, fl))) {
memcpy(p, to.Data(), tl);
i = p + fl;
}
return in;
} else {
CStr res;
char *i = in.SafeP();
while ((p = stristr(i, il-(i-in.Data()), from, fl))) {
res.Append(i, p - i);
if (tl > 0)
res << to;
i = p + fl;
}
if (i != in.Data()) {
res.Append(i, il - (i - in.Data()));
return res;
} else {
return in;
}
}
}
示例6: B64_decode
CStr B64_decode(CStr strin)
{
if (!strin.IsEmpty()) {
CStr strout((int) strin.Length());
int len = B64_decode(strin, strout.GetBuffer(), strin.Length());
if (len < 0) len = 0;
return strout.Grow(len);
} else
return strin;
}
示例7: EVP_decrypt
CStr EVP_decrypt(CStr passw, CStr strin, const char *cipher)
{
int len = strin.Length();
if (len > 0 && passw.Length() > 0) {
strin.Grow(len + EVP_MAX_IV_LENGTH);
return strin.Grow(
EVP_decrypt(passw.SafeP(), passw.Length(), strin.GetBuffer(), len, cipher)
);
} else
return strin;
}
示例8: EvalRight
void EvalRight(const void *data, qCtx *ctx, qStr *out, qArgAry *args) {
if (args->Count() >= 2) {
CStr tmp = (*args)[0];
int index = ParseInt((*args)[1]);
if (index > 0) {
if (index < tmp.Length()) {
out->PutS(tmp + tmp.Length() - index, index);
} else {
out->PutS(tmp);
}
}
}
}
示例9: EvalXin
// set search
void EvalXin(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
CStr str = (*args)[0];
CStr cur;
int len = str.Length(), i;
for (i = 1; i < args->Count(); ++i) {
cur = (*args)[i];
if (cur.Length() == len && !strncmp(str, cur, len)) {
out->PutN(i);
return;
}
}
}
示例10: EvalExpand
// expand an unexpanded (quoted) macro
void EvalExpand(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGC("expand", 0, 1);
CStr val = (*args)[0];
if (val.Length() > 0) {
if (val.Length() > 4 &&
val.Data()[0] == CMAGIC_V1[0] && val.Data()[1] == CMAGIC_V1[1] &&
val.Data()[2] == CMAGIC_V1[2] && val.Data()[3] == CMAGIC_V1[3]) {
qStrReadBuf tmp(val.Data()+4,val.Length()-4);
RunCompiled(ctx, &tmp, out);
} else {
ctx->Parse(val, out);
}
}
}
示例11: EvalFileName
void EvalFileName(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGC("filename", 1, 1);
CStr path = (*args)[0];
if (path) {
const char *b = path;
const char *r = b + path.Length() - 1;
while (r >= b && !(ISPATHSEP(*r))) {
--r;
}
++r;
out->PutS(r, path.Length() - (r - b));
}
}
示例12: GetFullHostName
CStr CIpAddress::GetFullHostName()
{_STT();
CStr sDomain = GetDomainName();
if ( sDomain.Length() )
return GetHostName() << oexT( "." ) << sDomain;
return GetHostName();
}
示例13: SmxQuote
CStr SmxQuote(CStr in) {
CStr r;
const char *p, *b = in;
const char *e = in.Length() + (p = b);
bool quot = false;
while (p < e) {
if (*p == '\'' || *p == '%' || *p == '\"' || *p == ',' || *p == '\\' || *p ==')' || *p == '(' || *p == 0 || *p == EOF || isspace(*p)) {
quot = true;
r = "\"" << CStr(b,p-b);
while (p < e) {
if (*p == '"' || *p =='\\' || *p =='(' || *p ==')') {
r << '\\';
r << *p++;
} else if (*p == '%') {
r << '%';
r << '%';
++p;
} else {
r << *p++;
}
}
r << '"';
break;
} else
++p;
}
if (quot)
return r;
else
return in;
}
示例14: EvalGDefine
void EvalGDefine(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGM("gdefine", 1);
CStr name;
qObj *obj = CreateDef(ctx, out, args, name);
if (!name.Length()) {
if (obj)
obj->Free();
return;
}
if (obj)
if (ctx->GetEnv() && ctx->GetEnv()->GetSessionCtx()) {
ctx->MapObjTop(obj, name, ctx->GetEnv()->GetSessionCtx());
} else {
ctx->MapObjTop(obj, name, NULL);
}
else
if (ctx->GetEnv() && ctx->GetEnv()->GetSessionCtx()) {
ctx->DelObjTop(name, ctx->GetEnv()->GetSessionCtx());
} else {
ctx->DelObjTop(name, NULL);
}
}
示例15: SetError
bool SetError(int nResult, bool bFree = true) {
if (!myErrRes
&& !SQL_SUCCEEDED(nResult)) {
myErrBuf.Grow(1024);
myErrState.Grow(6);
SQLSMALLINT tlen = 0;
if (!SQLGetDiagRec(myType, myHandle, 1, (SQLCHAR*) myErrState.GetBuffer(), &myErrCode, (SQLCHAR*) (myErrBuf.GetBuffer())+8, myErrBuf.Length()-8, &tlen)) {
myErrBuf[0] = '(';
memcpy(myErrBuf+1, (const char *)myErrState, 5);
myErrBuf[6] = ')';
myErrBuf[7] = ' ';
myErrBuf.Grow(min(tlen+8,myErrBuf.Length()-8));
myErrRes = nResult;
} else {
myErrState = "00000";
myErrBuf = "(00000) No error.";
myErrRes = nResult;
}
if (bFree) {
SQLFreeHandle(myType, myHandle);
myHandle = 0;
}
return false;
}
return true;
}