builds with cmake 3.7.2 (e.g. on Debian GNU/Linux 9.6)
/**
* Relational pipes (library)
* Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the:
* - GNU Lesser General Public License as published by the Free Software Foundation;
* either version 3 of the License, or (at your option) any later version;
* or (at your option)
* - GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <iostream>
#include <vector>
#include "typedefs.h"
#include "TypeId.h"
#include "AttributeMetadata.h"
namespace relpipe {
namespace writer {
class RelationalWriter {
public:
virtual ~RelationalWriter() = default;
/**
* @param typeCode string type code as defined in Specification
* @return numeric id of given type
* @throws RelpipeWriterException on unsupported typeCode
*/
virtual TypeId toTypeId(const string_t typeCode) = 0;
/**
* TODO: use custom extensible class instead of std::pair
*
* @param name name of the relation (table)
* @param attributes list of attributes (columns) containing their names and types
* @param writeHeader header might be omitted – when appending new records to a stream alreaready containing the header
*/
virtual void startRelation(string_t name, std::vector<AttributeMetadata> attributes, boolean_t writeHeader) = 0;
/**
* Writes a single attribute.
* @param value string representation of value of given attribute type as defined in Specification
*/
virtual void writeAttribute(const string_t& value) = 0;
// TODO: fluent interface?
// TODO: << operator?
// TODO: write bitmap + attribute:
// virtual void writeBitmap(...) = 0;
// virtual void writeAttribute(string_t attribute) = 0;
/**
* Writes a single attribute.
* @param value raw pointer to the value in format of given attribute type as defined in Specification
* @param type used as a safety mechanism to avoid wrong pointer interpretation;
* should be called in this way: writeAttribute(&value, typeid(value));
* if the type does not match, the RelpipeWriterException is thrown
*/
virtual void writeAttribute(const void* value, const std::type_info& type) = 0;
};
}
}