void relation(const osmium::Relation& relation) { if (m_write_change_ops) { open_close_op_tag(relation.visible() ? (relation.version() == 1 ? operation::op_create : operation::op_modify) : operation::op_delete); } write_prefix(); m_out += "<relation"; write_meta(relation); if (relation.tags().empty() && relation.members().empty()) { m_out += "/>\n"; return; } m_out += ">\n"; for (const auto& member : relation.members()) { write_prefix(); m_out += " <member type=\""; m_out += item_type_to_name(member.type()); oprintf(m_out, "\" ref=\"%" PRId64 "\" role=\"", member.ref()); xml_string(m_out, member.role()); m_out += "\"/>\n"; } write_tags(relation.tags()); write_prefix(); m_out += "</relation>\n"; }
void node(const osmium::Node& node) { if (m_write_change_ops) { open_close_op_tag(node.visible() ? (node.version() == 1 ? operation::op_create : operation::op_modify) : operation::op_delete); } write_prefix(); m_out += "<node"; write_meta(node); if (node.location()) { m_out += " lat=\""; osmium::util::double2string(std::back_inserter(m_out), node.location().lat_without_check(), 7); m_out += "\" lon=\""; osmium::util::double2string(std::back_inserter(m_out), node.location().lon_without_check(), 7); m_out += "\""; } if (node.tags().empty()) { m_out += "/>\n"; return; } m_out += ">\n"; write_tags(node.tags()); write_prefix(); m_out += "</node>\n"; }
void way(const osmium::Way& way) { if (m_write_change_ops) { open_close_op_tag(way.visible() ? (way.version() == 1 ? operation::op_create : operation::op_modify) : operation::op_delete); } write_prefix(); m_out += "<way"; write_meta(way); if (way.tags().empty() && way.nodes().empty()) { m_out += "/>\n"; return; } m_out += ">\n"; for (const auto& node_ref : way.nodes()) { write_prefix(); oprintf(m_out, " <nd ref=\"%" PRId64 "\"/>\n", node_ref.ref()); } write_tags(way.tags()); write_prefix(); m_out += "</way>\n"; }
void base_ptree::dump_internal_tree_graphviz(base_stream &os, const ptree_node *node, const char *color) const { if (!node) return; os.xprintf("\"%p\" ", (const void *)node); if (color) { os.write("[label=\""); if (node->_t_color == ptree_node::BLACK) write_prefix(os, node); else os.xprintf("white %i", (int)node->_t_bit); os.xprintf("\",color=%s];\n", color); dump_internal_tree_graphviz(os, node->_t_left, "red"); dump_internal_tree_graphviz(os, node->_t_right, "green"); } else { os.write("-- {"); if (node->_t_left) os.xprintf("\"%p\"", (const void *)node->_t_left); if (node->_t_right) os.xprintf(" \"%p\"", (const void *)node->_t_right); os.writeline("};"); dump_internal_tree_graphviz(os, node->_t_left, 0); dump_internal_tree_graphviz(os, node->_t_right, 0); } }
void changeset(const osmium::Changeset& changeset) { write_prefix(); m_out += "<changeset"; oprintf(m_out, " id=\"%" PRId32 "\"", changeset.id()); if (changeset.created_at()) { m_out += " created_at=\""; m_out += changeset.created_at().to_iso(); m_out += "\""; } oprintf(m_out, " num_changes=\"%" PRId32 "\"", changeset.num_changes()); if (changeset.closed_at()) { m_out += " closed_at=\""; m_out += changeset.closed_at().to_iso(); m_out += "\" open=\"false\""; } else { m_out += " open=\"true\""; } if (changeset.bounds()) { oprintf(m_out, " min_lon=\"%.7f\"", changeset.bounds().bottom_left().lon_without_check()); oprintf(m_out, " min_lat=\"%.7f\"", changeset.bounds().bottom_left().lat_without_check()); oprintf(m_out, " max_lon=\"%.7f\"", changeset.bounds().top_right().lon_without_check()); oprintf(m_out, " max_lat=\"%.7f\"", changeset.bounds().top_right().lat_without_check()); } if (!changeset.user_is_anonymous()) { m_out += " user=\""; xml_string(m_out, changeset.user()); oprintf(m_out, "\" uid=\"%d\"", changeset.uid()); } if (changeset.tags().empty()) { m_out += "/>\n"; return; } m_out += ">\n"; write_tags(changeset.tags()); write_prefix(); m_out += "</changeset>\n"; }
void write_tags(const osmium::TagList& tags) { for (const auto& tag : tags) { write_prefix(); m_out += " <tag k=\""; xml_string(m_out, tag.key()); m_out += "\" v=\""; xml_string(m_out, tag.value()); m_out += "\"/>\n"; } }
static void* log_routine(void *arg){ printf("log_routine\n"); while(1){ uint32_t ms = stop ? 0:100; struct log_item *item = NULL; msgque_get(pending_log,(lnode**)&item,ms); if(item){ if(item->_logfile->file == NULL || item->_logfile->total_size > MAX_FILE_SIZE) { if(item->_logfile->total_size){ fclose(item->_logfile->file); item->_logfile->total_size = 0; } //还没创建文件 char filename[128]; struct timespec tv; clock_gettime(CLOCK_REALTIME, &tv); struct tm _tm; localtime_r(&tv.tv_sec, &_tm); snprintf(filename,128,"%s-%04d-%02d-%02d %02d.%02d.%02d.%03d.log",to_cstr(item->_logfile->filename), _tm.tm_year+1900,_tm.tm_mon+1,_tm.tm_mday,_tm.tm_hour,_tm.tm_min,_tm.tm_sec,(int32_t)tv.tv_nsec/1000000); item->_logfile->file = fopen(filename,"w+"); if(!item->_logfile->file){ printf("%d\n",errno); free(item); continue; } } fprintf(item->_logfile->file,"%s\n",item->content); //fflush(item->_logfile->file); item->_logfile->total_size += strlen(item->content); free(item); }else if(stop){ break; } } //向所有打开的日志文件写入"log close success" struct logfile *l = NULL; char buf[128]; mutex_lock(g_mtx_log_file_list); while((l = LLIST_POP(struct logfile*,&g_log_file_list)) != NULL) { int32_t size = write_prefix(buf,LOG_INFO); snprintf(&buf[size],128-size,"log close success"); fprintf(l->file,"%s\n",buf); } mutex_unlock(g_mtx_log_file_list); printf("log_routine end\n"); return NULL; }
//expectation here is that hton is done //and crc is calculated void BlinkerMac::send_frame(IRFrame &frame) { debug("Sending packet"); write_prefix(); for (uint16_t i = 0; i < sizeof(IRFrame); i++) { encode_byte(frame.blob()[i], *this); } serial.flush(); // while this is happening, you'll get crap that is your own packet. // clear out any remaining input while(serial.available()) { (void)serial.read(); delay(1); } }
void base_ptree::dump_internal_tree(base_stream &os, const ptree_node *node, const char *desc) const { if (!node) return; os.xprintf("%s ", desc); if (node->_t_color == ptree_node::BLACK) write_prefix(os, node); else os.write("white"); os.xprintf(" at %i", (int)node->_t_bit); os.newl(); os.inc_level(); dump_internal_tree(os, node->_t_left, "left"); dump_internal_tree(os, node->_t_right, "right"); os.dec_level(); }
void qdimacs_cnft::write_qdimacs_cnf(std::ostream &out) { write_problem_line(out); write_prefix(out); write_clauses(out); }