Ejemplo n.º 1
0
void to_xml( xmlNodePtr parent, const TwsRow &row)
{
	switch( row.type ) {
	case t_error:
		to_xml( parent, *(RowError*)row.data );
		break;
	case t_orderStatus:
		to_xml( parent, *(RowOrderStatus*)row.data );
		break;
	case t_openOrder:
		to_xml( parent, *(RowOpenOrder*)row.data );
		break;
	}
}
Ejemplo n.º 2
0
static cairo_int_status_t
_cairo_xml_surface_mask (void			*abstract_surface,
			 cairo_operator_t	 op,
			 const cairo_pattern_t	*source,
			 const cairo_pattern_t	*mask,
			 const cairo_clip_t	*clip)
{
    cairo_xml_surface_t *surface = abstract_surface;
    cairo_xml_t *xml = to_xml (surface);
    cairo_status_t status;

    _cairo_xml_printf (xml, "<mask>");
    _cairo_xml_indent (xml, 2);

    _cairo_xml_emit_string (xml, "operator", _operator_to_string (op));

    status = _cairo_xml_surface_emit_clip (surface, clip);
    if (unlikely (status))
	return status;

    status = _cairo_xml_emit_pattern (xml, "source", source);
    if (unlikely (status))
	return status;

    status = _cairo_xml_emit_pattern (xml, "mask", mask);
    if (unlikely (status))
	return status;

    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf (xml, "</mask>");

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 3
0
void touphScript::kernel2::dump(std::string const& kernel2,
  std::string const& textPath)
{
  std::ifstream file{kernel2, file.binary};
  std::vector<char> data{
    std::istreambuf_iterator<char>{file},
    std::istreambuf_iterator<char>{}
  };

  auto sections = ff7::kernel2::split(data);

  std::ofstream out((fs::path{textPath}/"kernel2.bin.xml").string(), out.binary);

  out << "<!DOCTYPE kernel2 SYSTEM \"ts_kernel2.dtd\">\n\n"
      << "<kernel2>\n\n";

  for (auto i = 0u; i < sections.size(); ++i) {
    out << "<section type=\"" << section_names[i] << "\">\n\n";
    for (auto s = 0u; s < sections[i].size(); ++s)
      out << "<string id=\"" << s << "\">" << to_xml(sections[i][s])
          << "</string>\n";
    out << "\n</section>\n\n";
  }

  out << "</kernel2>\n\n";
}
Ejemplo n.º 4
0
static cairo_status_t
_cairo_xml_surface_emit_clip_boxes (cairo_xml_surface_t *surface,
				    const cairo_clip_t *clip)
{
    cairo_box_t *box;
    cairo_xml_t *xml;
    int n;

    if (clip->num_boxes == 0)
	return CAIRO_STATUS_SUCCESS;

    /* skip the trivial clip covering the surface extents */
    if (surface->width >= 0 && surface->height >= 0 && clip->num_boxes == 1) {
	box = &clip->boxes[0];
	if (box->p1.x <= 0 && box->p1.y <= 0 &&
	    box->p2.x - box->p1.x >= _cairo_fixed_from_double (surface->width) &&
	    box->p2.y - box->p1.y >= _cairo_fixed_from_double (surface->height))
	{
	    return CAIRO_STATUS_SUCCESS;
	}
    }

    xml = to_xml (surface);

    _cairo_xml_printf (xml, "<clip>");
    _cairo_xml_indent (xml, 2);

    _cairo_xml_printf (xml, "<path>");
    _cairo_xml_indent (xml, 2);
    for (n = 0; n < clip->num_boxes; n++) {
	box = &clip->boxes[n];

	_cairo_xml_printf_start (xml, "%f %f m",
				 _cairo_fixed_to_double (box->p1.x),
				 _cairo_fixed_to_double (box->p1.y));
	_cairo_xml_printf_continue (xml, " %f %f l",
				    _cairo_fixed_to_double (box->p2.x),
				    _cairo_fixed_to_double (box->p1.y));
	_cairo_xml_printf_continue (xml, " %f %f l",
				    _cairo_fixed_to_double (box->p2.x),
				    _cairo_fixed_to_double (box->p2.y));
	_cairo_xml_printf_continue (xml, " %f %f l",
				    _cairo_fixed_to_double (box->p1.x),
				    _cairo_fixed_to_double (box->p2.y));
	_cairo_xml_printf_end (xml, " h");
    }
    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf (xml, "</path>");
    _cairo_xml_emit_double (xml, "tolerance", 1.0);
    _cairo_xml_emit_string (xml, "antialias",
			    _antialias_to_string (CAIRO_ANTIALIAS_NONE));
    _cairo_xml_emit_string (xml, "fill-rule",
			    _fill_rule_to_string (CAIRO_FILL_RULE_WINDING));

    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf (xml, "</clip>");

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 5
0
void PacketOrders::dumpXml()
{
	xmlNodePtr root = TwsXml::newDocRoot();
	xmlNodePtr npcd = xmlNewChild( root, NULL,
		(const xmlChar*)"request", NULL );
	xmlNewProp( npcd, (const xmlChar*)"type",
		(const xmlChar*)"open_orders" );
	
	to_xml(npcd, *request);
	
	xmlNodePtr nrsp = xmlNewChild( npcd, NULL, (xmlChar*)"response", NULL);
	std::vector<TwsRow>::const_iterator it;
	for( it = list->begin(); it < list->end(); it++ ) {
		to_xml( nrsp, *it );
	}
	
	TwsXml::dumpAndFree( root );
}
Ejemplo n.º 6
0
void PacketHistData::dumpXml()
{
	xmlNodePtr root = TwsXml::newDocRoot();
	xmlNodePtr nphd = xmlNewChild( root, NULL,
		(const xmlChar*)"request", NULL );
	xmlNewProp( nphd, (const xmlChar*)"type",
		(const xmlChar*)"historical_data" );
	
	to_xml(nphd, *request);
	
	if( mode == CLOSED ) {
		xmlNodePtr nrsp = xmlNewChild( nphd, NULL, (xmlChar*)"response", NULL);
		for( size_t i=0; i<rows.size(); i++ ) {
			to_xml( nrsp, "row", rows[i] );
		}
		to_xml( nrsp, "fin", finishRow );
	}
	TwsXml::dumpAndFree( root );
}
Ejemplo n.º 7
0
static cairo_int_status_t
_cairo_xml_surface_stroke (void				*abstract_surface,
			   cairo_operator_t		 op,
			   const cairo_pattern_t	*source,
			   const cairo_path_fixed_t		*path,
			   const cairo_stroke_style_t		*style,
			   const cairo_matrix_t		*ctm,
			   const cairo_matrix_t		*ctm_inverse,
			   double			 tolerance,
			   cairo_antialias_t		 antialias,
			   const cairo_clip_t		*clip)
{
    cairo_xml_surface_t *surface = abstract_surface;
    cairo_xml_t *xml = to_xml (surface);
    cairo_status_t status;

    _cairo_xml_printf (xml, "<stroke>");
    _cairo_xml_indent (xml, 2);

    _cairo_xml_emit_string (xml, "operator", _operator_to_string (op));
    _cairo_xml_emit_double (xml, "line-width", style->line_width);
    _cairo_xml_emit_double (xml, "miter-limit", style->miter_limit);
    _cairo_xml_emit_string (xml, "line-cap", _line_cap_to_string (style->line_cap));
    _cairo_xml_emit_string (xml, "line-join", _line_join_to_string (style->line_join));

    status = _cairo_xml_surface_emit_clip (surface, clip);
    if (unlikely (status))
	return status;

    status = _cairo_xml_emit_pattern (xml, "source", source);
    if (unlikely (status))
	return status;

    if (style->num_dashes) {
	unsigned int i;

	_cairo_xml_printf_start (xml, "<dash offset='%f'>",
				 style->dash_offset);
	for (i = 0; i < style->num_dashes; i++)
	    _cairo_xml_printf_continue (xml, "%f ", style->dash[i]);

	_cairo_xml_printf_end (xml, "</dash>");
    }

    _cairo_xml_emit_path (xml, path);
    _cairo_xml_emit_double (xml, "tolerance", tolerance);
    _cairo_xml_emit_string (xml, "antialias", _antialias_to_string (antialias));

    _cairo_xml_emit_matrix (xml, ctm);

    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf (xml, "</stroke>");

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 8
0
void PacketPlaceOrder::dumpXml()
{
	xmlNodePtr root = TwsXml::newDocRoot();
	xmlNodePtr nppo = xmlNewChild( root, NULL,
		(const xmlChar*)"request", NULL );
	xmlNewProp( nppo, (const xmlChar*)"type",
		(const xmlChar*)"place_order" );

	to_xml(nppo, *request);

	if( mode == CLOSED ) {
		xmlNodePtr nrsp = xmlNewChild( nppo, NULL, (xmlChar*)"response", NULL);
		std::vector<TwsRow>::const_iterator it;
		for( it = list->begin(); it < list->end(); it++ ) {
			to_xml( nrsp, *it );
		}
	}

	TwsXml::dumpAndFree( root );
}
Ejemplo n.º 9
0
void PacketContractDetails::dumpXml()
{
	xmlNodePtr root = TwsXml::newDocRoot();
	xmlNodePtr npcd = xmlNewChild( root, NULL,
		(const xmlChar*)"request", NULL );
	xmlNewProp( npcd, (const xmlChar*)"type",
		(const xmlChar*)"contract_details" );
	
	to_xml(npcd, *request );
	
	xmlNodePtr nrsp = xmlNewChild( npcd, NULL, (xmlChar*)"response", NULL);
	for( size_t i=0; i<cdList->size(); i++ ) {
		conv_ib2xml( nrsp, "ContractDetails", (*cdList)[i] );
	}
	
	TwsXml::dumpAndFree( root );
}
Ejemplo n.º 10
0
static cairo_int_status_t
_cairo_xml_surface_glyphs (void			    *abstract_surface,
			   cairo_operator_t	     op,
			   const cairo_pattern_t    *source,
			   cairo_glyph_t	    *glyphs,
			   int			     num_glyphs,
			   cairo_scaled_font_t	    *scaled_font,
			   cairo_clip_t		    *clip,
			   int			    *remaining_glyphs)
{
    cairo_xml_surface_t *surface = abstract_surface;
    cairo_xml_t *xml = to_xml (surface);
    cairo_status_t status;
    int i;

    _cairo_xml_printf (xml, "<glyphs>");
    _cairo_xml_indent (xml, 2);

    _cairo_xml_emit_string (xml, "operator", _operator_to_string (op));

    status = _cairo_xml_surface_emit_clip (surface, clip);
    if (unlikely (status))
	return status;

    status = _cairo_xml_emit_pattern (xml, "source", source);
    if (unlikely (status))
	return status;

    status = _cairo_xml_emit_scaled_font (xml, scaled_font, glyphs, num_glyphs);
    if (unlikely (status))
	return status;

    for (i = 0; i < num_glyphs; i++) {
	_cairo_xml_printf (xml, "<glyph index='%lu'>%f %f</glyph>",
			   glyphs[i].index,
			   glyphs[i].x,
			   glyphs[i].y);
    }

    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf (xml, "</glyphs>");

    *remaining_glyphs = 0;
    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 11
0
void output(const char *field, const char *value)
{
	switch (format) {
		case FORMAT_CSV:
			to_csv(field, value);
			break;
		case FORMAT_XML:
			to_xml(field, value);
			break;
		case FORMAT_HTML:
			to_html(field, value);
			break;
		case FORMAT_TEXT:
		default:
			to_text(field, value);
			break;
	}
}
Ejemplo n.º 12
0
int main(int argc, const char *argv[])
{
    A a;
    a.a.v = 1;
    a.d = "abc";
    a.b.push_back(2);
    a.b.push_back(3);
    a.b.push_back(4);
    a.c.i=4;
    a.c.name="piboye&";
    a.c.other.push_back("piboye1<>");
    a.c.other.push_back("piboye2'\"");

    std::string out = to_xml(a);
    printf("%s\n", out.c_str());

    return 0;
}
Ejemplo n.º 13
0
static cairo_status_t
_cairo_xml_surface_emit_clip_path (cairo_xml_surface_t *surface,
				   const cairo_clip_path_t *clip_path)
{
    cairo_box_t box;
    cairo_status_t status;
    cairo_xml_t *xml;

    if (clip_path == NULL)
	return CAIRO_STATUS_SUCCESS;

    status = _cairo_xml_surface_emit_clip_path (surface, clip_path->prev);
    if (unlikely (status))
	return status;

    /* skip the trivial clip covering the surface extents */
    if (surface->width >= 0 && surface->height >= 0 &&
	_cairo_path_fixed_is_box (&clip_path->path, &box))
    {
	if (box.p1.x <= 0 && box.p1.y <= 0 &&
	    box.p2.x - box.p1.x >= _cairo_fixed_from_double (surface->width) &&
	    box.p2.y - box.p1.y >= _cairo_fixed_from_double (surface->height))
	{
	    return CAIRO_STATUS_SUCCESS;
	}
    }

    xml = to_xml (surface);

    _cairo_xml_printf_start (xml, "<clip>");
    _cairo_xml_indent (xml, 2);

    _cairo_xml_emit_path (xml, &clip_path->path);
    _cairo_xml_emit_double (xml, "tolerance", clip_path->tolerance);
    _cairo_xml_emit_string (xml, "antialias",
			    _antialias_to_string (clip_path->antialias));
    _cairo_xml_emit_string (xml, "fill-rule",
			    _fill_rule_to_string (clip_path->fill_rule));

    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf_end (xml, "</clip>");

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 14
0
static cairo_int_status_t
_cairo_xml_surface_fill (void			*abstract_surface,
			 cairo_operator_t	 op,
			 const cairo_pattern_t	*source,
			 const cairo_path_fixed_t*path,
			 cairo_fill_rule_t	 fill_rule,
			 double			 tolerance,
			 cairo_antialias_t	 antialias,
			 const cairo_clip_t	*clip)
{
    cairo_xml_surface_t *surface = abstract_surface;
    cairo_xml_t *xml = to_xml (surface);
    cairo_status_t status;

    _cairo_xml_printf (xml, "<fill>");
    _cairo_xml_indent (xml, 2);

    _cairo_xml_emit_string (xml, "operator", _operator_to_string (op));

    status = _cairo_xml_surface_emit_clip (surface, clip);
    if (unlikely (status))
	return status;

    status = _cairo_xml_emit_pattern (xml, "source", source);
    if (unlikely (status))
	return status;

    _cairo_xml_emit_path (xml, path);
    _cairo_xml_emit_double (xml, "tolerance", tolerance);
    _cairo_xml_emit_string (xml, "antialias", _antialias_to_string (antialias));
    _cairo_xml_emit_string (xml, "fill-rule", _fill_rule_to_string (fill_rule));

    _cairo_xml_indent (xml, -2);
    _cairo_xml_printf (xml, "</fill>");

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 15
0
std::string Set::to_xml( bool pretty ) const
{
	std::stringstream ss;
	to_xml( ss , pretty );
	return ss.str();
}