Exemplo n.º 1
0
/* Initialize parser state to be passed around as an opaque reference */
hcerr_t xml_create (start_element_handler_t start_element_callback,
		    end_element_handler_t end_element_callback, 
		    void *data,
		    xml_parser **parser,
                    allocator_t a, 
                    deallocator_t d){
  simple_xml_parser *simple_parser;
  
  ALLOCATOR(simple_parser, sizeof(simple_xml_parser));
  
  simple_parser->start_element_callback = start_element_callback;
  simple_parser->end_element_callback = end_element_callback;
  simple_parser->data = data;

  simple_parser->attribute_arrays_size = ATTRIBUTE_ARRAYS_INITIAL_SIZE;

  simple_parser->current_attribute = 0;
  simple_parser->depth = 0;
  simple_parser->start_tag = FALSE;
  simple_parser->backslash = FALSE;    
  simple_parser->state = OUTSIDE_ELEMENT;  
  simple_parser->count = count++;
  simple_parser->allocator = a;
  simple_parser->deallocator = d;
  simple_parser->attribute_names = NULL;
  ALLOCATOR(simple_parser->attribute_values, (sizeof(char*) * ATTRIBUTE_ARRAYS_INITIAL_SIZE));
  ALLOCATOR(simple_parser->attribute_names, (sizeof(char*) * ATTRIBUTE_ARRAYS_INITIAL_SIZE));

  require_ok(make_buffer_list(&simple_parser->buffer_list));

  *parser = (xml_parser*) simple_parser;
  return HCERR_OK;
}
Exemplo n.º 2
0
    message(const Header& header,
	    const std::string& body)
	: m_header(header),
	  m_body(body),
	  m_buffers(make_buffer_list(m_header, m_body))
    {
	// TRACE_DEBUG();
    }