本文整理汇总了C++中CStr::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CStr::GetBuffer方法的具体用法?C++ CStr::GetBuffer怎么用?C++ CStr::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStr
的用法示例。
在下文中一共展示了CStr::GetBuffer方法的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: 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;
}
示例3: EvalLcase
void EvalLcase(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
if (args->Count() > 0) {
CStr tmp = (*args)[0];
if (tmp)
out->PutS(strlwr(tmp.GetBuffer()), tmp.Length());
}
}
示例4: ProtoParseHosts
void ProtoParseHosts(CStrAry &hosts, CStr &hostStr) {
char *p = hostStr.GetBuffer();
p = strtok(p, ";\n");
while (p) {
if (*p && strchr(p, '.')) {
hosts.Add(p);
}
p = strtok(NULL, ";\n");
}
}
示例5: 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;
}
示例6: Connect
CDbConn CDbPool::Connect(char *dsn)
{
CDbConn conn;
if (!myConnMap.Find(dsn,conn)) {
CStr tmp = dsn;
conn = myLib->Connect(tmp.GetBuffer());
conn.BeginTrans();
myConnMap.Set(dsn,conn);
}
return conn;
}
示例7: EvalDirRemove
void EvalDirRemove(const void *mode, qCtx *ctx, qStr *out, qArgAry *args)
{
VALID_ARGC("rmdir", 1, 1);
CStr path = (*args)[0];
if (path) {
bslash(path.GetBuffer());
#ifdef WIN32
_rmdir(path);
#else
rmdir(path);
#endif
}
}
示例8: WriteCSV
void WriteCSV(const void *mode, bool forceQuoted, qCtx *ctx, qStr *out, qArgAry *args)
{
CStr path = ctx->ParseStr((*args)[0]);
if (path.IsEmpty())
return;
FILE *fp = safe_fopen(ctx, path, (const char *) mode);
if (!fp) {
ctx->ThrowF(out, 601, "Failed to open file for writing. %y", GetLastError());
return;
}
qStrFileO fo(fp, true);
CStr bo;
qStrBuf quot;
qCtxTmp sub(ctx);
sub.MapObj(fp, EvalFileFlush,"flush");
int i;
char *p, *b;
for (i = 1; i < args->Count(); ++i) {
bo = sub.ParseStr((*args)[i]);
quot.Clear();
b = bo.GetBuffer();
if ((p = strchr((const char *)b, '"'))) {
quot.PutC('"');
do {
quot.PutS(b, p - b + 1);
quot.PutS('"');
} while ((p = strchr((const char *)b, '"')));
quot.PutC('"');
fo.PutS(quot);
} else if (forceQuoted || (p = strchr((const char *)b, ','))) {
quot.PutC('"');
quot.PutS(bo);
quot.PutC('"');
fo.PutS(quot);
} else
fo.PutS(bo);
if (i < (args->Count()-1) ) {
fo.PutC(',');
}
}
fo.PutC('\n');
}
示例9:
CDbCol *qObjODBC::GetEvalCol(qCtx *ctx, qArgAry *args)
{
CDbCol *col = 0;
if (args->Count() > 0) {
CStr index = (*args)[0];
index.Trim();
if (!index.IsEmpty()) {
if (isdigit(index[0])) {
col = myStmt.Column(atoi(index)-1);
} else {
strlwr(index.GetBuffer());
col = myStmt.Column((const char *)index);
}
}
}
return col;
}
示例10: HEnum
void qObjHCtx::HEnum(qCtx *ctx, qStr *out, qArgAry *args)
{
// require body argument
if (args->Count() < 1)
return;
// get context
CStr var = (*args)[0];
// read filter
int filter = 0;
if (args->Count() > 2) {
CStr tmp = (*args)[2];
strlwr(tmp.GetBuffer());
if (strchr((const char*)tmp, 'v'))
filter |= HENUM_VALUES;
if (strchr((const char*)tmp, 'k'))
filter |= HENUM_KEYS;
if (strchr((const char*)tmp, 't'))
filter |= HENUM_TREE;
} else
filter = HENUM_KEYS | HENUM_VALUES;
// loop through objects in my map
qCtxTmp tmpCtx(ctx);
LOOPCTX loop;
loop.body = args->GetAt(1);
loop.n = 0;
loop.ctx = &tmpCtx;
loop.out = out;
loop.ctx->MapObj(&loop.key, "key");
loop.ctx->MapObj(&loop.val, "value");
ctx->MapObj(&loop.n, "num");
myHash.Enum(&loop, var, filter, HEnumLoop);
return;
}
示例11: EvalGetAttrValue
void EvalGetAttrValue(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
if (args->Count() > 0) {
CStr tmp = (*args)[0];
if (args->Count() > 1) {
CStr m = (*args)[1];
if (tmp && !m.IsEmpty()) {
char *p = tmp.GetBuffer();
char *n = p;
char *v = 0;
while (*p) {
while (isspace(*p))
++p;
if (*p == '=') {
*p++ = '\0';
while (isspace(*p))
++p;
v = p;
while (*p) {
if (*p == ';') {
*p = '\0';
if (!stricmp(m, n)) {
out->PutS(v);
return;
}
while (isspace(*++p));
n = p;
v = NULL;
break;
}
++p;
}
} else if (*p == ';')
n = p + 1;
++p;
}
if (v && *v && n && *n && !stricmp(m, n)) {
out->PutS(v);
return;
}
}
}
}
}
示例12: EvalSqlQ
void EvalSqlQ(const void *data, qCtx *ctx, qStr *out, qArgAry *args)
{
CStr val = (*args)[0];
char *p = val.GetBuffer();
CStr quo(val.Length() * 2 + 2);
char *v = quo.GetBuffer();
*v++ = '\'';
if (p) {
while (*p) {
if (*p == '\'')
*v++ = '\'';
*v++ = *p;
++p;
}
}
*v++ = '\'';
quo.Grow(v-(const char *)quo);
out->PutS(quo);
}
示例13: 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);
}
}
}
示例14: OutFunc
void qCtxComp::OutFunc(qStr *out, CStr &name, qArgAry *ary)
{
int i, j;
char *p;
C_BASE b;
b.bc = BC_FUNC;
b.rn = myRn ? rand()%256 : 0;
b.ln = name.Length();
out->PutS((char *)&b, sizeof(b));
p = name.GetBuffer();
if (b.rn) {
for (j = 0; j < b.ln; ++j)
p[j] = p[j] ^ b.rn;
}
out->PutS(name);
C_ARGS v;
v.cnt = ary->Count();
out->PutS((char *)&v, sizeof(v));
C_ARG a;
for (i = 0; i < ary->Count(); ++i){
a.ln = ary->GetAt(i).Length();
a.at = ary->GetQuot(i);
out->PutS((char *)&a, sizeof(a));
p = ary->GetAt(i).GetBuffer();
if (b.rn) {
for (j = 0; j < (int) a.ln; ++j)
p[j] = p[j] ^ b.rn;
}
out->PutS(ary->GetAt(i));
}
}
示例15: EvalSmtpMail
void qObjProto::EvalSmtpMail(qCtx *ctx, qStr *out, qArgAry *args)
{
if (args->Count() >= 4) {
qMailOpts qmop;
qmop.host = (*args)[0];
qmop.smtp = qmop.host;
qmop.user = (*args)[1].GetBuffer();
qmop.from = (*args)[2];
qmop.subj = (*args)[4];
qmop.subj = ReplaceStr(qmop.subj, "\n", "");
qmop.subj = ReplaceStr(qmop.subj, "\r", "");
qmop.from = ReplaceStr(qmop.from, "\n", "");
qmop.from = ReplaceStr(qmop.from, "\r", "");
qmop.host = ReplaceStr(qmop.host, "\n", "");
qmop.host = ReplaceStr(qmop.host, "\r", "");
qmop.body.Add("'" << (*args)[5]);
if (qsUnreg)
qmop.unreg = true;
int i = 6;
while (args->GetAt(i)) {
qmop.body.Add((*args)[i++]);
}
// FIX QMAIL LACK OF MULTIPLE -TO- HEADERS!
CStr rcpt = (*args)[3];
ReplaceStr(rcpt, "\n", "");
ReplaceStr(rcpt, "\r", "");
char * rx = rcpt.GetBuffer();
char * tok = rx;
char * p = strchr(tok, ';');
if (p) *p = '\0';
while (tok) {
while (isspace(*tok))
++tok;
if (*tok) {
qmop.rcpt = tok;
qmop.to = tok;
try {
int errVal = qsmtp(&qmop);
if (errVal)
ctx->ThrowF(out, errVal+600, "Mail error #%d.", errVal);
} catch (CEx ex) {
ctx->Throw(out, ex.id+600, ex.msg);
}
}
if (p) {
tok = p + 1;
p = strchr(tok, ';');
if (p) *p = '\0';
} else
tok = NULL;
}
} else {
ctx->Throw(out, 655, "USAGE: %smtp-mail(host, user, from, to, subj, body...)");
}
return;
}