本文整理汇总了C++中write_node函数的典型用法代码示例。如果您正苦于以下问题:C++ write_node函数的具体用法?C++ write_node怎么用?C++ write_node使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ruby_write_node_bool_to_float
void ruby_write_node_bool_to_float(node_t*n, state_t*s)
{
strf(s, "(");
write_node(s, n->child[0]);
strf(s, " ? 1.0 : 0.0");
strf(s, ")");
}
示例2: c_write_node_sqr
void c_write_node_sqr(node_t*n, state_t*s)
{
strf(s, "sqr");
if(n->child[0]->type!=&node_brackets) strf(s, "(");
write_node(s, n->child[0]);
if(n->child[0]->type!=&node_brackets) strf(s, ")");
}
示例3: write_pred
static void
write_pred(SerdWriter* writer, SerdStatementFlags flags, const SerdNode* pred)
{
write_node(writer, pred, NULL, NULL, FIELD_PREDICATE, flags);
write_sep(writer, SEP_P_O);
copy_node(&writer->context.predicate, pred);
}
示例4: read_node
void FileAllocator::remove_node(FileOffset head_offset, list_node *head,
FileOffset node_offset, const list_node *node)
{
list_node tmp;
FileOffset tmp_offset;
if (head->next == node_offset)
{ // first node; make head skip it
head->bytes -= node->bytes;
head->next = node->next;
if (head->next == 0) // list now empty?
head->prev = 0;
else
{ // correct 'prev' ptr of what's now the first node
read_node(head->next, &tmp);
tmp.prev = 0;
write_node(head->next, &tmp);
}
write_node(head_offset, head);
}
else
{ // locate a node that's not the first
tmp_offset = head->next;
read_node(tmp_offset, &tmp);
while (tmp.next != node_offset)
{
tmp_offset = tmp.next;
if (!tmp_offset)
throw GenericException(__FILE__, __LINE__,
"node not found");
read_node(tmp_offset, &tmp);
}
// tmp/tmp_offset == node before the one to be removed
tmp.next = node->next;
write_node(tmp_offset, &tmp);
if (node->next)
{ // adjust prev pointer of node->next
read_node(node->next, &tmp);
tmp.prev = tmp_offset;
write_node(node->next, &tmp);
}
head->bytes -= node->bytes;
if (head->prev == node_offset)
head->prev = node->prev;
write_node(head_offset, head);
}
}
示例5: ruby_write_node_sub
void ruby_write_node_sub(node_t*n, state_t*s)
{
int t;
for(t=0;t<n->num_children;t++) {
if(t && !node_has_minus_prefix(n->child[t])) strf(s, "-");
write_node(s, n->child[t]);
}
}
示例6: printf
bool FileAllocator::attach(FILE *f, FileOffset reserved_space, bool init)
{
#ifdef DEBUG_FA
printf("FileAllocator::attach()\n");
#endif
LOG_ASSERT(f != 0);
this->f = f;
this->reserved_space = reserved_space;
if (fseek(this->f, 0, SEEK_END))
throw GenericException(__FILE__, __LINE__, "fseek error");
file_size = ftell(this->f);
if (file_size < 0)
throw GenericException(__FILE__, __LINE__, "ftell error");
// File size should be
// 0 for new file or at least reserved_space + list headers
if (file_size == 0)
{
if (init == false)
throw GenericException(__FILE__, __LINE__,
"FileAllocator in read-only mode found empty file");
// create empty list headers
memset(&allocated_head, 0, list_node_size);
memset(&free_head, 0, list_node_size);
write_node(this->reserved_space, &allocated_head);
write_node(this->reserved_space+list_node_size, &free_head);
file_size = ftell(this->f);
FileOffset expected = reserved_space + 2*list_node_size;
if (file_size != expected)
throw GenericException(__FILE__, __LINE__,
"Initialization error: "
"Expected file size %ld, found %ld",
(long) expected, (long) file_size);
return true;
}
FileOffset expected = this->reserved_space + 2*list_node_size;
if (file_size < expected)
throw GenericException(__FILE__, __LINE__,
"FileAllocator: Broken file header,"
"expected at least %ld bytes",
(long) expected);
// read existing list headers
read_node(this->reserved_space, &allocated_head);
read_node(this->reserved_space+list_node_size, &free_head);
return false; // Didn't initialize the file
}
示例7: write_nodes
static void
write_nodes(FILE *fp, const NSegment *tree)
{
if (tree == NULL) return;
write_node(fp, tree);
write_nodes(fp, tree->left);
write_nodes(fp, tree->right);
}
示例8: ruby_write_node_block
void ruby_write_node_block(node_t*n, state_t*s)
{
int t;
for(t=0;t<n->num_children;t++) {
if(t)
strf(s, "\n");
write_node(s, n->child[t]);
}
}
示例9: ruby_write_node_arg_min_or_max
static void ruby_write_node_arg_min_or_max(node_t*n, state_t*s, char*min_or_max)
{
strf(s, "([");
int t;
for(t=0;t<n->num_children;t++) {
if(t) strf(s, ",");
write_node(s, n->child[t]);
}
strf(s, "].each_with_index.map.%s)[1]", min_or_max);
}
示例10: ps3_repository_write_highmem_size
int ps3_repository_write_highmem_size(unsigned int region_index,
u64 highmem_size)
{
return write_node(
make_first_field("highmem", 0),
make_field("region", region_index),
make_field("size", 0),
0,
highmem_size, 0);
}
示例11: write_node
bool MemoryDump::draw_tree(Node &node, std::ofstream &ofile, const cmd_opt &opt, std::set<uintptr_t> &declared_nodes, int level)
{
if (node.visited >= 0 && node.visited <= level) return true;
if (opt.critical_only && !node.critical) return true;
if (opt.depth > 0 && level >= opt.depth) return true;
node.visited = level;
std::vector<ChildNode*> edges;
for (auto &&c : node.children) {
if (c.node->subtree_size >= min_size
&& (!opt.critical_only || c.node->critical)) {
edges.push_back(&c);
}
}
std::sort(edges.begin(), edges.end(),
[](const ChildNode *a, const ChildNode *b) {
return a->node->subtree_size > b->node->subtree_size;
}
);
if (opt.max_subnodes > 0 && edges.size() > opt.max_subnodes) { //too many nodes, only write nodes with big sizes;
edges.resize(opt.max_subnodes);
}
bool tail_written = false;
for (const auto & c : edges) {
if (!tail_written && declared_nodes.find(node.label) == declared_nodes.end()) {
write_node(node, ofile, opt);
declared_nodes.insert(node.label);
tail_written = true;
}
if (declared_nodes.find(c->node->label) == declared_nodes.end()) {
write_node(*c->node, ofile, opt);
declared_nodes.insert(c->node->label);
}
exporter->write_edge(node, *c->node, ofile, c->edge.str());
draw_tree(*c->node, ofile, opt, declared_nodes, level + 1);
}
return true;
}
示例12: walk_tree
/*
* Tree walking with acending key order
*/
void walk_tree(int fd_in, int fd_out, compact_header_t * tree)
{
if (tree->left != NULL) {
walk_tree(fd_in, fd_out, tree->left);
}
write_node(fd_in, fd_out, tree, io_buf, IO_BUFFER_SZ);
if (tree->right != NULL) {
walk_tree(fd_in, fd_out, tree->right);
}
free(tree);
}
示例13: set_new
intset_t*
set_new()
{
intset_t *set;
node_t *min, *max;
if ((set = (intset_t *) malloc(sizeof (intset_t))) == NULL)
{
perror("malloc");
EXIT(1);
}
node_t** nodes = (node_t**) pgas_app_alloc_rr(2, sizeof(node_t));
min = nodes[0];
max = nodes[1];
write_node(max, VAL_MAX, 0, 0);
write_node(min, VAL_MIN, OF(max), 0);
set->head = min;
return set;
}
示例14: c_write_node_arg_min_i
void c_write_node_arg_min_i(node_t*n, state_t*s)
{
strf(s, "arg_min_i(%d, ", n->num_children);
int t;
for(t=0;t<n->num_children;t++) {
if(t)
strf(s, ", ");
strf(s, "(int)");
write_node(s, n->child[t]);
}
strf(s, ")");
}
示例15: ps3_repository_write_highmem_region_count
int ps3_repository_write_highmem_region_count(unsigned int region_count)
{
int result;
u64 v1 = (u64)region_count;
result = write_node(
make_first_field("highmem", 0),
make_field("region", 0),
make_field("count", 0),
0,
v1, 0);
return result;
}