本文整理汇总了C++中CStr::Grow方法的典型用法代码示例。如果您正苦于以下问题:C++ CStr::Grow方法的具体用法?C++ CStr::Grow怎么用?C++ CStr::Grow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStr
的用法示例。
在下文中一共展示了CStr::Grow方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: EvalRealPath
void EvalRealPath(const void *mode, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGC("realpath", 1, 1);
CStr src = (*args)[0];
if (!src.Length()) return;
CStr dest;
dest.Grow(MAX_PATH);
#ifdef WIN32
PathCanonicalize(dest.Data(), src.Data());
#else
realpath(src.Data(), dest.Data());
#endif
dest.Grow(strlen(dest.Data()));
out->PutS(dest);
}
示例4: GetRegistryValue
bool GetRegistryValue(HKEY hKey, LPCTSTR szName, CStr &strData)
{
DWORD dwSize = 0, dwType = REG_SZ;
RegQueryValueEx(hKey, szName, NULL, &dwType, NULL, &dwSize);
LPBYTE buf = (LPBYTE) strData.Grow(dwSize + 1).GetBuffer();
if (dwType && (RegQueryValueEx(hKey, szName, NULL, &dwType, buf, &dwSize) == ERROR_SUCCESS))
{
if (dwSize && buf[(int)dwSize-1] == '\0')
strData.Grow(dwSize-1);
else
strData.Grow(dwSize);
return true;
} else {
strData.Grow(0);
}
return false;
}
示例5: EvalPack
void EvalPack(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGM("pack", 2);
CStr templ = (*args)[0];
CStr sarg;
char t;
const char * p = templ;
char *endp = 0;
if (!p) return;
int nlen, plen, i = 1, j;
while (*p) {
switch(*p) {
case 'a':
case 'A':
if (isdigit(p[1])) {
nlen = strtol(p+1, &endp, 0);
p = endp-1;
if (nlen <= 0) nlen =1;
} else
nlen =1;
sarg = (*args)[i++];
plen = sarg.Length();
sarg.Grow(nlen);
if (nlen > plen)
memset(sarg.Data()+plen,(*p == 'a' ? ' ' : '\0'),nlen-plen);
out->PutS(sarg);
case 'l':
case 'L':
t = *p;
if (isdigit(p[1])) {
nlen = strtol(p+1, &endp, 0);
p = endp-1;
if (nlen <= 0) nlen =1;
} else
nlen =1;
for(j = 0; j < nlen; ++j) {
DWORD dw;
sarg = (*args)[i++];
if (t == 'l')
dw = (DWORD) strtoul(sarg.Data(), &endp, 0);
else if (t == 'L')
dw = (DWORD) strtol(sarg.Data(), &endp, 0);
out->PutS((char *)&dw,sizeof(dw));
}
}
++p;
}
}
示例6: EvalBase
void EvalBase(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGC("base", 1, 1);
CStr path = (*args)[0];
if (path){
char *r = strrchr((const char *)path, '.');
if (r) {
*r = '\0';
path.Grow(r - (const char *)path);
}
out->PutS(path);
}
}
示例7: EvalFilePath
void EvalFilePath(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGC("filepath", 1, 1);
CStr path = (*args)[0];
char *b = path.GetBuffer();
if (b) {
char *r = b + path.Length() - 1;
while (r >= b && !(ISPATHSEP(*r))) {
--r;
}
if (r >= b) {
*r = DIRSEP;
++r;
*r = '\0';
path.Grow(r - b);
out->PutS(path);
}
}
}
示例8: ParseCompArg
bool qCtxComp::ParseCompArg(qStr *in, qStrBuf &cur, char c)
{
bool more = true;
int numsp = 0;
char quoted = '\x0';
int qcnt = 0;
int lpc = 0;
CStr tmp;
if (c == '"')
{ quoted = '"'; c = in->GetC(); }
else if (c == T_LC)
{ quoted = T_LC; c = in->GetC(); qcnt = 1; }
do {
if (c == T_ESC) {
c = in->GetC();
if (c != EOF)
tmp << c;
numsp = 0;
} else if (c == '%') {
if (tmp.Length()) {
C_BASE b;
b.bc = BC_OUT;
b.ln = tmp.Length();
b.rn = myRn ? rand()%256 : 0; // 2003-05-21 more encryption
cur.PutS((char *) &b, sizeof(b));
cur.PutS(tmp);
tmp.Grow(0);
}
ParseFunc(in, &cur);
OutFlush(&cur);
numsp = 0;
} else if (quoted) {
if (c == T_LC && quoted == T_LC) {
++qcnt;
} else if (c == '"' && quoted == '"') {
quoted = '\x0';
lpc = 0;
numsp = 0;
} else if ( (c == T_RC) && (quoted == T_LC) && (--qcnt <= 0) ) {
quoted = '\x0';
numsp = 0;
} else {
tmp << c;
}
} else if (lpc) {
if (c == T_RP) {
--lpc;
tmp << c;
numsp = 0;
} else if (c == T_LP) {
++lpc;
tmp << c;
numsp = 0;
} else if (isspace(c)) {
tmp << c;
++numsp;
} else {
numsp = 0;
tmp << c;
}
} else {
if (c == ',') {
if (numsp)
tmp.Grow(tmp.Length() - numsp);
break;
} else if (c == T_LP) {
tmp << c;
++lpc;
numsp = 0;
} else if (c == T_RP) {
if (numsp)
tmp.Grow(tmp.Length() - numsp);
more = false;
break;
} else if (isspace(c)) {
++numsp;
tmp << c;
} else {
numsp = 0;
tmp << c;
}
}
} while (EOF != (c = in->GetC()));
if (tmp.Length()) {
C_BASE b;
b.bc = BC_OUT;
b.ln = tmp.Length();
b.rn = myRn ? rand()%256 : 0; // 2003-05-21 more encryption
cur.PutS((char *) &b, sizeof(b));
cur.PutS(tmp);
tmp.Grow(0);
}
return c == EOF ? false : more;
}
示例9: Decompile
void Decompile(qStr *in, qStr *out)
{
int i, j;
char *p;
C_BASE b;
while (in->GetS((char *) &b, sizeof(b)) == sizeof(b)) {
CStr dt(b.ln);
if (in->GetS(dt.GetBuffer(), b.ln) == b.ln) {
if (b.bc == BC_FUNC) {
C_ARGS v;
C_ARG a;
CStr cur;
p = dt.GetBuffer();
if (b.rn) {
for (j = 0; j < b.ln; ++j)
p[j] = p[j] ^ b.rn;
}
out->PutC('%');
out->PutS(dt);
if (in->GetS((char *) &v, sizeof(v)) == sizeof(v)) {
if (v.cnt > 0)
out->PutC('(');
else
out->PutC('%');
for (i = 0; i < v.cnt; ++i) {
if (in->GetS((char *) &a, sizeof(a)) == sizeof(a)) {
cur.Grow(a.ln);
if (in->GetS(cur.GetBuffer(), a.ln) == (int) a.ln) {
p = cur.GetBuffer();
if (b.rn) {
for (j = 0; j < (int) a.ln; ++j)
p[j] = p[j] ^ b.rn;
}
if (a.at == ARG_CMP) {
qStrReadBuf rTmp(cur);
Decompile(&rTmp, out);
} else {
if (a.at == ARG_QSTR)
out->PutC('\'');
out->PutS(cur);
}
if (i < (v.cnt-1)) {
out->PutC(',');
}
}
}
}
if (v.cnt > 0)
out->PutC(')');
}
} else if (b.bc == BC_OUT) {
out->PutS(dt, b.ln);
}
}
}
}
示例10: RunCompiled
void RunCompiled(qCtx *ctx, qStr *in, qStr *out)
{
int i, j;
char *p;
C_BASE b;
while (in->GetS((char *) &b, sizeof(b)) == sizeof(b) && b.ln > 0) {
CStr dt(b.ln);
if (in->GetS(dt.GetBuffer(), b.ln) == b.ln) {
if (b.bc == BC_FUNC) {
p = dt.GetBuffer();
if (b.rn) {
for (j = 0; j < b.ln; ++j)
p[j] = p[j] ^ b.rn;
}
qObj *obj;
if (ctx->Find(&obj, (const CStr &) dt)) {
C_ARGS v;
C_ARG a;
CStr cur;
qArgAry ary;
char qmode;
if (in->GetS((char *) &v, sizeof(v)) == sizeof(v)) {
char *map = obj->GetQmap();
if (!map || *map == 'A') {
qmode = !map ? '0' : '1';
for (i = 0; i < v.cnt; ++i) {
{
if (in->GetS((char *) &a, sizeof(a)) == sizeof(a)) {
cur.Grow(a.ln);
if (in->GetS(cur.GetBuffer(), a.ln) == (int) a.ln) {
p = cur.GetBuffer();
if (b.rn) {
for (j = 0; j < (int) a.ln; ++j)
p[j] = p[j] ^ b.rn;
}
ary.Add(cur);
ary.SetQuot(i, a.at == ARG_QSTR);
if (!ary.GetQuot(i) && qmode == '0') {
qStrBuf tmp;
if (a.at == ARG_CMP) {
qStrReadBuf rTmp(ary[i]);
RunCompiled(ctx, &rTmp, &tmp);
} else {
qStrReadBuf rTmp(ary[i]);
ctx->Parse(&rTmp, &tmp);
}
ary[i] = tmp;
} else {
if (a.at == ARG_CMP) {
if (qmode != '2') {
qStrBuf tmp;
qStrReadBuf rTmp(ary[i]);
Decompile(&rTmp, &tmp);
ary[i] = tmp;
} else {
ary.SetQuot(i, ARG_CMP);
}
}
}
}
}
}
}
} else {
qmode = (*map == '1' ? '1' : '0');
++map;
for (i = 0; i < v.cnt; ++i) {
{
if (in->GetS((char *) &a, sizeof(a)) == sizeof(a)) {
cur.Grow(a.ln);
if (in->GetS(cur.GetBuffer(), a.ln) == (int) a.ln) {
p = cur.GetBuffer();
if (b.rn) {
for (j = 0; j < (int) a.ln; ++j)
p[j] = p[j] ^ b.rn;
}
ary.Add(cur);
ary.SetQuot(i, a.at == ARG_QSTR);
if (!ary.GetQuot(i) && qmode == '0') {
qStrBuf tmp;
if (a.at == ARG_CMP) {
qStrReadBuf rTmp(ary[i]);
RunCompiled(ctx, &rTmp, &tmp);
} else {
qStrReadBuf rTmp(ary[i]);
ctx->Parse(&rTmp, &tmp);
}
ary[i] = tmp;
} else {
if (a.at == ARG_CMP) {
if (qmode != '2') {
qStrBuf tmp;
qStrReadBuf rTmp(ary[i]);
Decompile(&rTmp, &tmp);
ary[i] = tmp;
} else {
ary.SetQuot(i, ARG_CMP);
}
//.........这里部分代码省略.........