本文整理汇总了C++中dump_node函数的典型用法代码示例。如果您正苦于以下问题:C++ dump_node函数的具体用法?C++ dump_node怎么用?C++ dump_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dump_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump_node
bool dump_node(TAP_state_t *state, userp_ident_t *root, int lev) {
if (!root) return false;
userp_ident_t *next= userp_ident_by_name_right(root);
if (next) dump_node(state, next, lev+1);
TAP_NOTE("%*s(%c) %s", lev*4, "", root->name_tree_node.color? 'R':'B', root->name);
next= userp_ident_by_name_left(root);
if (next) dump_node(state, next, lev+1);
return true;
}
示例2: dump_node
void dump_node( struct xmlNode *node )
{
if( node == 0 )
{
return;
}
printf( "Node:%s Attr:", node->name );
dump_attr( node->attr_list );
putc( '\n', stdout );
dump_node( node->children );
dump_node( node->sibling );
}
示例3: main
int main( int argc, char **argv )
{
FILE *fp = 0;
if( argc < 2 )
{
fprintf( stderr, "Usage : %s filename.\n", argv[0] );
exit( -1 );
}
fp = fopen( argv[1], "r" );
if( fp == 0 )
{
fprintf( stderr, "Unable to open %s.\n", argv[1] );
exit( -1 );
}
{
struct xmlDocument *doc = xmldoc_new( fp );
xml_seterrorfn( error_log );
xml_parse( doc );
dump_node( doc->root );
xmldoc_free( doc );
}
fclose( fp );
return 0;
}
示例4: dump_node
void dump_node(Node *n, bool same_line, int padding, MappedSubstring orig) {
int delta = 0;
if (!same_line) {
for (int i = 0; i < padding; ++i) {
std::cout << " ";
}
}
if (!orig.empty()) {
auto s = haystack.find(orig.ref_str);
for (int i = orig.l; i <= orig.r && i <= s->second.length(); ++i) {
std::cout << s->second[i];
}
std::cout << "-";
delta = orig.r - orig.l + 2;
if (orig.r == std::numeric_limits<int>::max()) {
delta = s->second.length() - orig.l + 2;
}
}
same_line = true;
for (auto t_it : n->g) {
dump_node(t_it.second.tgt, same_line, padding + delta, t_it.second.sub);
same_line = false;
}
if (same_line) {
std::cout << "##" << std::endl;
}
}
示例5: dump_vector
void
dump_vector(int indent, Vector *vec)
{
for (int i = 0; i < vec->length; i++) {
dump_node(indent, (Node *)vector_get(vec, i));
}
}
示例6: c_genericize
void
c_genericize (tree fndecl)
{
FILE *dump_orig;
int local_dump_flags;
struct cgraph_node *cgn;
/* Dump the C-specific tree IR. */
dump_orig = dump_begin (TDI_original, &local_dump_flags);
if (dump_orig)
{
fprintf (dump_orig, "\n;; Function %s",
lang_hooks.decl_printable_name (fndecl, 2));
fprintf (dump_orig, " (%s)\n",
(!DECL_ASSEMBLER_NAME_SET_P (fndecl) ? "null"
: IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl))));
fprintf (dump_orig, ";; enabled by -%s\n", dump_flag_name (TDI_original));
fprintf (dump_orig, "\n");
if (local_dump_flags & TDF_RAW)
dump_node (DECL_SAVED_TREE (fndecl),
TDF_SLIM | local_dump_flags, dump_orig);
else
print_c_tree (dump_orig, DECL_SAVED_TREE (fndecl));
fprintf (dump_orig, "\n");
dump_end (TDI_original, dump_orig);
}
/* Dump all nested functions now. */
cgn = cgraph_node (fndecl);
for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested)
c_genericize (cgn->decl);
}
示例7: open_file
static svn_error_t *
open_file(const char *path,
void *parent_baton,
svn_revnum_t ancestor_revision,
apr_pool_t *pool,
void **file_baton)
{
struct dir_baton *pb = parent_baton;
struct edit_baton *eb = pb->edit_baton;
const char *cmp_path = NULL;
svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;
/* If the parent directory has explicit comparison path and rev,
record the same for this one. */
if (ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev))
{
cmp_path = svn_relpath_join(pb->cmp_path,
svn_relpath_basename(path, pool), pool);
cmp_rev = pb->cmp_rev;
}
SVN_ERR(dump_node(eb, path,
svn_node_file, svn_node_action_change,
FALSE, cmp_path, cmp_rev, pool));
*file_baton = NULL; /* muhahahaha again */
return SVN_NO_ERROR;
}
示例8: close_directory
static svn_error_t *
close_directory(void *dir_baton,
apr_pool_t *pool)
{
struct dir_baton *db = dir_baton;
struct edit_baton *eb = db->edit_baton;
apr_hash_index_t *hi;
apr_pool_t *subpool = svn_pool_create(pool);
for (hi = apr_hash_first(pool, db->deleted_entries);
hi;
hi = apr_hash_next(hi))
{
const void *key;
const char *path;
apr_hash_this(hi, &key, NULL, NULL);
path = key;
svn_pool_clear(subpool);
/* By sending 'svn_node_unknown', the Node-kind: header simply won't
be written out. No big deal at all, really. The loader
shouldn't care. */
SVN_ERR(dump_node(eb, path,
svn_node_unknown, svn_node_action_delete,
FALSE, NULL, SVN_INVALID_REVNUM, subpool));
}
svn_pool_destroy(subpool);
return SVN_NO_ERROR;
}
示例9: add_file
static svn_error_t *
add_file(const char *path,
void *parent_baton,
const char *copyfrom_path,
svn_revnum_t copyfrom_rev,
apr_pool_t *pool,
void **file_baton)
{
struct dir_baton *pb = parent_baton;
struct edit_baton *eb = pb->edit_baton;
void *val;
svn_boolean_t is_copy = FALSE;
/* This might be a replacement -- is the path already deleted? */
val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);
/* Detect add-with-history. */
is_copy = ARE_VALID_COPY_ARGS(copyfrom_path, copyfrom_rev);
/* Dump the node. */
SVN_ERR(dump_node(eb, path,
svn_node_file,
val ? svn_node_action_replace : svn_node_action_add,
is_copy,
is_copy ? copyfrom_path : NULL,
is_copy ? copyfrom_rev : SVN_INVALID_REVNUM,
pool));
if (val)
/* delete the path, it's now been dumped. */
apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING, NULL);
*file_baton = NULL; /* muhahahaha */
return SVN_NO_ERROR;
}
示例10: dump_node
void dump_node(const node_t *node, const char *path)
{
node_t *child;
char *path_new;
int i;
assert (node && path); /* path could point to an empty string but never NULL */
if (!(path_new = (char *)malloc(strlen(path) + 2))) {
return;
}
sprintf(path_new, "%s%c", path, node->c);
if (node->cnt) {
printf("%s : %d\n", path_new, node->cnt);
}
for (i = 0; i < AVAILABLE_CHARS; i++) {
if (!(child = node->children[i])) {
continue;
}
dump_node(child, path_new);
}
free(path_new);
}
示例11: setlocale
char *store_restart_layout(void) {
setlocale(LC_NUMERIC, "C");
yajl_gen gen = yajl_gen_alloc(NULL);
dump_node(gen, croot, true);
setlocale(LC_NUMERIC, "");
const unsigned char *payload;
size_t length;
y(get_buf, &payload, &length);
/* create a temporary file if one hasn't been specified, or just
* resolve the tildes in the specified path */
char *filename;
if (config.restart_state_path == NULL) {
filename = get_process_filename("restart-state");
if (!filename)
return NULL;
} else {
filename = resolve_tilde(config.restart_state_path);
}
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd == -1) {
perror("open()");
free(filename);
return NULL;
}
size_t written = 0;
while (written < length) {
int n = write(fd, payload + written, length - written);
/* TODO: correct error-handling */
if (n == -1) {
perror("write()");
free(filename);
close(fd);
return NULL;
}
if (n == 0) {
DLOG("write == 0?\n");
free(filename);
close(fd);
return NULL;
}
written += n;
DLOG("written: %zd of %zd\n", written, length);
}
close(fd);
if (length > 0) {
DLOG("layout: %.*s\n", (int)length, payload);
}
y(free);
return filename;
}
示例12: dump_node
static void
dump_node(struct npr_rbtree_node *n, int depth)
{
if (n) {
dump_node(n->left, depth+1);
for (int di=0; di<depth; di++) {
printf(" ");
}
if (n->color == BLACK) {
printf("{B, %d,%d}\n", (int)n->key, (int)n->v);
} else {
printf("{R, %d,%d}\n", (int)n->key, (int)n->v);
}
dump_node(n->right, depth+1);
}
}
示例13: dump_trie
void dump_trie(Trie *v, int detail)
{
int i;
dump_node(v, detail);
for (i = 0; i < v->nchildren; i++)
dump_trie(&v->children[i], detail);
}
示例14: dump_path
void dump_path(Trie *v, int detail)
{
int depth = v->depth, i;
Trie *path[MAX_DEPTH];
while (v != NULL) {
path[v->depth] = v;
v = v->parent;
}
for (i = 0; i < depth; i++) {
if (path[i]->nrules <= 16)
dump_node(path[i], detail);
else
dump_node(path[i], 0);
}
}
示例15: dump
/*
Print the created AST to stdout, mostly for debugging purposes
*/
void dump(file_contents contents) {
{
linked_iter iterator = ll_iter_head(contents.imports);
while(ll_iter_has_next(&iterator)) {
import_declaration *import = ll_iter_next(&iterator);
printf("IMPORT: %s\n", evaluate(import->name));
}
}
{
linked_iter iterator = ll_iter_head(contents.enums);
while(ll_iter_has_next(&iterator)) {
enum_declaration *dec = ll_iter_next(&iterator);
printf("ENUM: %s\n", evaluate(dec->name));
linked_iter items = ll_iter_head(dec->options);
while(ll_iter_has_next(&items)) {
statement *option = ll_iter_next(&items);
printf("\tOPTION: %s\n", evaluate(option->data));
}
}
}
{
linked_iter iterator = ll_iter_head(contents.structs);
while(ll_iter_has_next(&iterator)) {
struct_declaration *current = ll_iter_next(&iterator);
printf("STRUCT: %s\n", evaluate(current->name));
linked_iter iterator = ll_iter_head(current->members);
while(ll_iter_has_next(&iterator)) {
struct_member *member = ll_iter_next(&iterator);
printf("\tMEMBER: NAME: %s | TYPE: %s\n", evaluate(member->name), evaluate(member->type));
}
}
}
{
linked_iter iterator = ll_iter_head(contents.functions);
while(ll_iter_has_next(&iterator)) {
func_declaration *current = ll_iter_next(&iterator);
printf("FUNC: %s | TYPE : %s\n", evaluate(current->name), evaluate(current->type));
printf("\tPARAMETERS:\n");
dump_node(current->parameters, 2);
printf("\tBODY:\n");
dump_node(current->root->children, 2);
}
}
}