src/XMLDocumentConstructor.h
branchv_0
changeset 10 6904e4448807
parent 7 afb7f3a4981a
child 13 d5e2cb9e31f1
equal deleted inserted replaced
9:7a6abdd00ab5 10:6904e4448807
    21 #include <libxml++-2.6/libxml++/libxml++.h>
    21 #include <libxml++-2.6/libxml++/libxml++.h>
    22 
    22 
    23 #include "lib/BasicASN1Reader.h"
    23 #include "lib/BasicASN1Reader.h"
    24 #include "lib/GenericASN1ContentHandler.h"
    24 #include "lib/GenericASN1ContentHandler.h"
    25 #include "lib/DOMBuildingXMLContentHandler.h"
    25 #include "lib/DOMBuildingXMLContentHandler.h"
       
    26 #include "lib/TransactionalBuffer.h"
    26 
    27 
    27 namespace relpipe {
    28 namespace relpipe {
    28 namespace in {
    29 namespace in {
    29 namespace xmltable {
    30 namespace xmltable {
    30 
    31 
    48 
    49 
    49 		asn1handler->addHandler(saxHandler);
    50 		asn1handler->addHandler(saxHandler);
    50 		reader.addHandler(asn1handler);
    51 		reader.addHandler(asn1handler);
    51 
    52 
    52 
    53 
    53 		// TODO: buffering? (reader itself also buffers)
    54 		try {
    54 		for (char ch = input->get(); input->good(); ch = input->get()) reader.write(&ch, 1);
    55 			// TODO: buffering? (reader itself also buffers)
       
    56 			for (char ch = input->get(); input->good(); ch = input->get()) reader.write(&ch, 1);
       
    57 		} catch (const relpipe::in::asn1::lib::TransactionalBuffer::WriteBufferOverflowException& e) {
       
    58 			// TODO: avoid leaky abstraction and use different exception
       
    59 			throw relpipe::writer::RelpipeWriterException(L"Transactional buffer for ASN.1 input is too small");
       
    60 		}
    55 
    61 
    56 		reader.close();
    62 		reader.close();
       
    63 
       
    64 		if (parser->get_document()->get_root_node() == nullptr) throw relpipe::writer::RelpipeWriterException(L"Empty ASN.1 input"); // TODO: move to common class
    57 	}
    65 	}
    58 };
    66 };
    59 
    67 
    60 }
    68 }
    61 }
    69 }