本文整理汇总了C++中UAS_Pointer::insert_item方法的典型用法代码示例。如果您正苦于以下问题:C++ UAS_Pointer::insert_item方法的具体用法?C++ UAS_Pointer::insert_item怎么用?C++ UAS_Pointer::insert_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UAS_Pointer
的用法示例。
在下文中一共展示了UAS_Pointer::insert_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: out
//.........这里部分代码省略.........
// convert kwics to textrun
string textrbstr;
if (parseout == NULL && kwics) {
ostringstream textrunbuf;
for (int i = 0; i < n_kwics; i++)
textrunbuf << kwics[i].offset << '\t' << kwics[i].length << '\n';
textrbstr = textrunbuf.str();
parseout = (char*)textrbstr.c_str();
}
else if (parseout == NULL)
{
return matches;
}
#ifdef DEBUG
fprintf(stderr, "(DEBUG) byte offset and length\n%s", parseout);
#endif
istringstream textruns(parseout);
char linebuf[128];
while (textruns.get(linebuf, 128, '\n')) {
char newline;
textruns.get(newline);
assert( newline == '\n');
char* off_str = linebuf;
char* len_str = strchr(linebuf, '\t');
assert( len_str && *len_str == '\t' );
*len_str++ = '\0';
int mode = True;
const char* cursor = (const char*)text;
assert( *cursor == ShiftIn || *cursor == ShiftOut );
int off = atoi(off_str);
int vcc = 0;
while (off > 0) {
int scanned = 0;
if (*cursor == '\n' || *cursor == '\t' || *cursor == ' ' ||
*cursor == 0x0D || (unsigned char)*cursor == 0xA0) {
scanned++;
}
else if (*cursor == ShiftIn || *cursor == ShiftOut) {
if (*cursor == ShiftIn)
mode = True;
else
mode = False;
scanned++;
}
else {
scanned = mblen(cursor, MB_CUR_MAX);
vcc++;
/* skip one byte in case of failure */
if (scanned < 0)
scanned = 1;
}
off -= scanned;
cursor += scanned;
}
if (mode == False)
continue;
assert( off == 0 );
int len = atoi(len_str);
// remove leading white-spaces
for (; len && (*cursor == ' ' || *cursor == '\t' ||
*cursor == '\n'|| *cursor == 0x0D); cursor++, len--);
// remove trailing white-spaces
if (len > 0) {
for (const char* p = cursor + len - 1;
*p==' ' || *p=='\t' || *p=='\n' || *p==0x0D; p--, len--);
}
if (len == 0)
continue;
int vlen = 0;
for (; len > 0; vlen++) {
int scanned = mblen(cursor, MB_CUR_MAX);
assert( scanned >= 0 );
len -= scanned;
cursor += scanned;
}
UAS_Pointer<UAS_TextRun> textrun = new UAS_TextRun(vcc, vlen);
matches->insert_item(textrun);
}
return matches;
}