src/RelpipeASN1ContentHandler.h
branchv_0
changeset 7 2e4ee5a25f76
parent 6 523c9c39c996
equal deleted inserted replaced
6:523c9c39c996 7:2e4ee5a25f76
    40 		RelationName,
    40 		RelationName,
    41 		Header,
    41 		Header,
    42 		HeaderItem,
    42 		HeaderItem,
    43 		AttributeName,
    43 		AttributeName,
    44 		AttributeType,
    44 		AttributeType,
       
    45 		AttributeNext,
    45 		Records,
    46 		Records,
    46 		Record,
    47 		Record,
    47 		End,
    48 		End,
    48 	};
    49 	};
    49 
    50 
    70 		return State::AttributeType;
    71 		return State::AttributeType;
    71 	}
    72 	}
    72 
    73 
    73 	State setAttributeType(relpipe::common::type::StringX value) {
    74 	State setAttributeType(relpipe::common::type::StringX value) {
    74 		currentAttributes.back().typeId = writer->toTypeId(value);
    75 		currentAttributes.back().typeId = writer->toTypeId(value);
    75 		return State::AttributeType;
    76 		return State::AttributeNext;
    76 	}
    77 	}
    77 
    78 
    78 public:
    79 public:
    79 
    80 
    80 	RelpipeASN1ContentHandler(std::shared_ptr<relpipe::writer::RelationalWriter> writer, Configuration configuration) : writer(writer), configuration(configuration) {
    81 	RelpipeASN1ContentHandler(std::shared_ptr<relpipe::writer::RelationalWriter> writer, Configuration configuration) : writer(writer), configuration(configuration) {
    99 		else if (state == State::Records) state = State::Record;
   100 		else if (state == State::Records) state = State::Record;
   100 		else throw std::logic_error("Illegal state in writeCollectionStart(): " + std::to_string((int) state));
   101 		else throw std::logic_error("Illegal state in writeCollectionStart(): " + std::to_string((int) state));
   101 	}
   102 	}
   102 
   103 
   103 	void writeCollectionEnd() override {
   104 	void writeCollectionEnd() override {
   104 		if (state == State::AttributeType) state = State::HeaderItem;
   105 		if (state == State::AttributeNext) state = State::HeaderItem;
   105 		else if (state == State::HeaderItem) state = startRelation();
   106 		else if (state == State::HeaderItem) state = startRelation();
   106 		else if (state == State::Records) state = State::Relation;
   107 		else if (state == State::Records) state = State::Relation;
   107 		else if (state == State::Record) state = State::Records;
   108 		else if (state == State::Record) state = State::Records;
   108 		else if (state == State::Relation) state = State::End;
   109 		else if (state == State::Relation) state = State::End;
   109 		else throw std::logic_error("Illegal state in writeCollectionEnd(): " + std::to_string((int) state));
   110 		else throw std::logic_error("Illegal state in writeCollectionEnd(): " + std::to_string((int) state));