本文整理汇总了C++中TStrings::GetText方法的典型用法代码示例。如果您正苦于以下问题:C++ TStrings::GetText方法的具体用法?C++ TStrings::GetText怎么用?C++ TStrings::GetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStrings
的用法示例。
在下文中一共展示了TStrings::GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getlog
static void _std getlog(log_header *log, void *extptr) {
getloginfo *pli = (getloginfo*)extptr;
int puretext = (pli->flags&(LOGTF_DATE|LOGTF_TIME|LOGTF_LEVEL))==0;
if (puretext) {
spstr ltext;
while (log->offset) {
if ((log->flags&LOGIF_USED)!=0 && ((pli->flags&LOGTF_LEVEL)==0 ||
(pli->flags&LOGTF_LEVELMASK)>=(log->flags&LOGIF_LEVELMASK)))
{
ltext+=(char*)(log+1);
}
log+=log->offset;
}
if (pli->flags&LOGTF_DOSTEXT) ltext.replace("\n","\r\n");
// make copy a bit faster
pli->rc = (char*)malloc(ltext.length()+1);
memcpy(pli->rc, ltext(), ltext.length());
pli->rc[ltext.length()] = 0;
} else {
TStrings lst;
struct tm dt;
u32t pdtme = 0;
time_t ptme;
while (log->offset) {
if ((log->flags&LOGIF_USED)!=0 && ((pli->flags&LOGTF_LEVEL)==0 ||
(pli->flags&LOGTF_LEVELMASK)>=(log->flags&LOGIF_LEVELMASK)))
{
if (pdtme!=log->dostime) {
dostimetotm(pdtme=log->dostime,&dt);
ptme = mktime(&dt);
}
spstr estr, astr;
if (pli->flags&LOGTF_DATE)
estr.sprintf("%02d.%02d.%02d ",dt.tm_mday,dt.tm_mon+1,dt.tm_year-100);
if (pli->flags&LOGTF_TIME) {
int sec = dt.tm_sec;
if (log->flags&LOGIF_SECOND) sec++;
astr.sprintf("%02d:%02d:%02d ",dt.tm_hour, dt.tm_min, sec);
estr+=astr;
}
if (pli->flags&LOGTF_LEVEL) {
if (pli->flags&LOGTF_FLAGS)
astr.sprintf("[%c%d%c] ",log->flags&LOGIF_REALMODE?'r':' ',
log->flags&LOGIF_LEVELMASK,log->flags&LOGIF_DELAY?'d':' ');
else
astr.sprintf("[%d] ",log->flags&LOGIF_LEVELMASK);
estr+=astr;
}
estr+=(char*)(log+1);
if (estr.lastchar()=='\n') estr.dellast();
lst.AddObject(estr,ptme);
}
log+=log->offset;
}
int ii,jj;
const char *eol = pli->flags&LOGTF_DOSTEXT?"\r\n":"\n";
log_it(2, "%d lines of log queried\n", lst.Count());
for (ii=1;ii<lst.Count();ii++)
// we`re can`t fill entire log for 3 seconds
if (lst.Objects(ii-1)-lst.Objects(ii)>3) break;
// re-order cyclic added lines
if (ii<lst.Count()) {
spstr t1 = lst.GetTextToStr(eol,ii),
t2 = lst.GetTextToStr(eol,0,ii);
pli->rc = (char*)malloc(t1.length()+t2.length()+1);
memcpy(pli->rc, t1(), t1.length());
memcpy(pli->rc+t1.length(), t2(), t2.length()+1);
} else
pli->rc = lst.GetText(eol);
}
}
示例2:
char* _std str_gettostr(str_list*list, char *separator) {
TStrings lst;
str_getstrs(list,lst);
return lst.GetText(separator?separator:"");
}