equal
deleted
inserted
replaced
39 |
39 |
40 class SocketHandler : public relpipe::reader::handlers::RelationalReaderStringHandler { |
40 class SocketHandler : public relpipe::reader::handlers::RelationalReaderStringHandler { |
41 private: |
41 private: |
42 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
42 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
43 Configuration configuration; |
43 Configuration configuration; |
44 shared_ptr<Socket> mq; |
44 shared_ptr<Socket> socket; |
45 |
45 |
46 struct CurrentRelation { |
46 struct CurrentRelation { |
47 relpipe::common::type::StringX name; |
47 relpipe::common::type::StringX name; |
48 std::vector<relpipe::reader::handlers::AttributeMetadata> attributes; |
48 std::vector<relpipe::reader::handlers::AttributeMetadata> attributes; |
49 relpipe::common::type::Integer attributeIndex = 0; |
49 relpipe::common::type::Integer attributeIndex = 0; |
52 |
52 |
53 public: |
53 public: |
54 |
54 |
55 SocketHandler(Configuration configuration) : configuration(configuration) { |
55 SocketHandler(Configuration configuration) : configuration(configuration) { |
56 // TODO: do not throw exception from the constructor: Socket::open() |
56 // TODO: do not throw exception from the constructor: Socket::open() |
57 mq.reset(Socket::open(convertor.to_bytes(configuration.queue), configuration.unlinkOnClose)); |
57 socket = std::make_shared<Socket>(); // TODO: create a TCP, UDP… socket |
58 } |
58 } |
59 |
59 |
60 void startRelation(relpipe::common::type::StringX name, std::vector<relpipe::reader::handlers::AttributeMetadata> attributes) override { |
60 void startRelation(relpipe::common::type::StringX name, std::vector<relpipe::reader::handlers::AttributeMetadata> attributes) override { |
61 currentRelation = CurrentRelation{name, attributes}; |
61 currentRelation = CurrentRelation{name, attributes}; |
62 } |
62 } |
70 else if (attributeName == L"data"); // keep empty or value from 'text' |
70 else if (attributeName == L"data"); // keep empty or value from 'text' |
71 |
71 |
72 currentRelation.attributeIndex++; |
72 currentRelation.attributeIndex++; |
73 if (currentRelation.attributeIndex == currentRelation.attributes.size()) { |
73 if (currentRelation.attributeIndex == currentRelation.attributes.size()) { |
74 currentRelation.attributeIndex = 0; |
74 currentRelation.attributeIndex = 0; |
75 mq->send(currentRelation.currentValue); |
75 socket->send(currentRelation.currentValue); |
76 } |
76 } |
77 |
77 |
78 } |
78 } |
79 |
79 |
80 void endOfPipe() { |
80 void endOfPipe() { |