include/relpipe/writer/RelationalWriter.h
author František Kučera <franta-hg@frantovo.cz>
Mon, 13 Aug 2018 20:30:55 +0200
branchv_0
changeset 20 bef6648e79b1
parent 18 include/RelationalWriter.h@90efe2db1ca8
child 22 53f4887dadb4
permissions -rw-r--r--
relpipe-lib-writer: move public header files to: include/relpipe/writer/
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
#pragma once
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
#include <string>
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
#include <iostream>
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
#include <vector>
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
13
e7234dd45166 use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
     7
#include "typedefs.h"
e7234dd45166 use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
     8
#include "TypeId.h"
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
8
03750aff8619 writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    10
namespace relpipe {
03750aff8619 writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    11
namespace writer {
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    13
class RelationalWriter {
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
public:
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    16
	virtual ~RelationalWriter() = default;
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    17
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    18
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    19
	 * @param typeCode string type code as defined in Specification
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    20
	 * @return numeric id of given type
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    21
	 * @throws RelpipeWriterException on unsupported typeCode
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    22
	 */
15
8fd6c4d44071 use more TypeId enum
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    23
	virtual TypeId toTypeId(const string_t typeCode) = 0;
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    24
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    25
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    26
	 * @param typeId numeric type id as defined in Specification
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    27
	 * @return string code of given type
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    28
	 * @throws RelpipeWriterException on unsupported typeId
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    29
	 */
15
8fd6c4d44071 use more TypeId enum
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    30
	virtual string_t toTypeCode(const TypeId typeId) = 0;
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    32
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    33
	 * @param name name of the relation (table)
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    34
	 * @param attributes list of attributes (columns) containing their names and types
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    35
	 * @param writeHeader header might be omitted – when appending new records to a stream alreaready containing the header
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    36
	 */
13
e7234dd45166 use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
    37
	virtual void startRelation(string_t name, std::vector<std::pair<string_t, TypeId>> attributes, boolean_t writeHeader) = 0;
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    39
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    40
	 * Writes a single attribute.
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    41
	 * @param value string representation of value of given attribute type as defined in Specification
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    42
	 */
17
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    43
	virtual void writeAttribute(const string_t& value) = 0;
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    44
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    45
	// TODO: fluent interface?
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    46
	// TODO: << operator?
16
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    47
	// TODO: write bitmap + attribute:
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    48
	// virtual void writeBitmap(...) = 0;
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    49
	// virtual void writeAttribute(string_t attribute) = 0;
17
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    50
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    51
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    52
	 * Writes a single attribute.
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    53
	 * @param value raw pointer to the value in format of given attribute type as defined in Specification
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    54
	 * @param type used as a safety mechanism to avoid wrong pointer interpretation;
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    55
	 * should be called in this way: writeAttribute(&value, typeid(value));
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    56
	 * if the type does not match, the RelpipeWriterException is thrown
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    57
	 */
16
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    58
	virtual void writeAttribute(const void* value, const std::type_info& type) = 0;
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
};
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
8
03750aff8619 writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    62
}
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    63
}