本文整理汇总了C++中ChunkList_t类的典型用法代码示例。如果您正苦于以下问题:C++ ChunkList_t类的具体用法?C++ ChunkList_t怎么用?C++ ChunkList_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChunkList_t类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
chunk_t *chunk_get_prev(chunk_t *cur, nav_t nav)
{
if (cur == NULL)
{
return(NULL);
}
chunk_t *pc = g_cl.GetPrev(cur);
if ((pc == NULL) || (nav == CNAV_ALL))
{
return(pc);
}
if (cur->flags & PCF_IN_PREPROC)
{
/* If in a preproc, return NULL if trying to leave */
if ((pc->flags & PCF_IN_PREPROC) == 0)
{
return(NULL);
}
return(pc);
}
/* Not in a preproc, skip any preproc */
while ((pc != NULL) && (pc->flags & PCF_IN_PREPROC))
{
pc = g_cl.GetPrev(pc);
}
return(pc);
}
示例2: return
chunk_t *chunk_get_prev(chunk_t *cur, scope_e scope)
{
if (cur == nullptr)
{
return(nullptr);
}
chunk_t *pc = g_cl.GetPrev(cur);
if (pc == nullptr || scope == scope_e::ALL)
{
return(pc);
}
if (cur->flags & PCF_IN_PREPROC)
{
// If in a preproc, return NULL if trying to leave
if ((pc->flags & PCF_IN_PREPROC) == 0)
{
return(nullptr);
}
return(pc);
}
// Not in a preproc, skip any preproc
while (pc != nullptr && (pc->flags & PCF_IN_PREPROC))
{
pc = g_cl.GetPrev(pc);
}
return(pc);
}
示例3: chunk_move_after
void chunk_move_after(chunk_t *pc_in, chunk_t *ref)
{
LOG_FUNC_ENTRY();
g_cl.Pop(pc_in);
g_cl.AddAfter(pc_in, ref);
/* HACK: Adjust the original column */
pc_in->column = ref->column + space_col_align(ref, pc_in);
pc_in->orig_col = (UINT32)pc_in->column;
pc_in->orig_col_end = pc_in->orig_col + pc_in->len();
}
示例4: exit
chunk_t *chunk_dup(const chunk_t *pc_in)
{
chunk_t *pc = new chunk_t; /* Allocate a new chunk */
if (pc == NULL)
{
/* @todo clean up properly before crashing */
LOG_FMT(LERR, "Failed to allocate memory\n");
exit(EXIT_FAILURE);
}
/* Copy all fields and then init the entry */
*pc = *pc_in;
g_cl.InitEntry(pc);
return(pc);
}
示例5: exit
chunk_t *chunk_dup(const chunk_t *pc_in)
{
chunk_t *pc = new chunk_t; // Allocate a new chunk
if (pc == nullptr)
{
// @todo clean up properly before crashing
LOG_FMT(LERR, "Failed to allocate memory\n");
exit(EXIT_FAILURE);
}
// Copy all fields and then init the entry
*pc = *pc_in; // TODO: what happens if pc_in == nullptr?
g_cl.InitEntry(pc);
return(pc);
}
示例6: chunk_swap_lines
/* @todo this function needs some cleanup */
void chunk_swap_lines(chunk_t *pc1, chunk_t *pc2)
{
pc1 = chunk_first_on_line(pc1);
pc2 = chunk_first_on_line(pc2);
if ((pc1 == NULL) || (pc2 == NULL) || (pc1 == pc2))
{
return;
}
/**
* Example start:
* ? - start1 - a1 - b1 - nl1 - ? - ref2 - start2 - a2 - b2 - nl2 - ?
* ^- pc1 ^- pc2
*/
chunk_t *ref2 = chunk_get_prev(pc2);
/* Move the line started at pc2 before pc1 */
while ((pc2 != NULL) && !chunk_is_newline(pc2))
{
chunk_t *tmp = chunk_get_next(pc2);
g_cl.Pop(pc2);
g_cl.AddBefore(pc2, pc1);
pc2 = tmp;
}
/**
* Should now be:
* ? - start2 - a2 - b2 - start1 - a1 - b1 - nl1 - ? - ref2 - nl2 - ?
* ^- pc1 ^- pc2
*/
/* Now move the line started at pc1 after ref2 */
while ((pc1 != NULL) && !chunk_is_newline(pc1))
{
chunk_t *tmp = chunk_get_next(pc1);
g_cl.Pop(pc1);
if (ref2 != NULL)
{
g_cl.AddAfter(pc1, ref2);
}
else
{
g_cl.AddHead(pc1);
}
ref2 = pc1;
pc1 = tmp;
}
/**
* Should now be:
* ? - start2 - a2 - b2 - nl1 - ? - ref2 - start1 - a1 - b1 - nl2 - ?
* ^- pc1 ^- pc2
*/
/* pc1 and pc2 should be the newlines for their lines.
* swap the chunks and the nl_count so that the spacing remains the same.
*/
if ((pc1 != NULL) && (pc2 != NULL))
{
size_t nl_count = pc1->nl_count;
pc1->nl_count = pc2->nl_count;
pc2->nl_count = nl_count;
chunk_swap(pc1, pc2);
}
} // chunk_swap_lines
示例7: chunk_swap
void chunk_swap(chunk_t *pc1, chunk_t *pc2)
{
g_cl.Swap(pc1, pc2);
}
示例8: chunk_del
void chunk_del(chunk_t *pc)
{
chunk_log(pc, "chunk_del");
g_cl.Pop(pc);
delete pc;
}