include/relpipe/writer/RelationalWriter.h
author František Kučera <franta-hg@frantovo.cz>
Mon, 03 Sep 2018 23:41:29 +0200
branchv_0
changeset 26 8ae93a43fed2
parent 24 00fe696500c5
child 27 a64afb2d24c9
permissions -rw-r--r--
remove toTypeCode() (is needed only in lib-reader)
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 <iostream>
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
#include <vector>
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
13
e7234dd45166 use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
     6
#include "typedefs.h"
e7234dd45166 use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
     7
#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
     8
8
03750aff8619 writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
     9
namespace relpipe {
03750aff8619 writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    10
namespace writer {
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    12
class RelationalWriter {
7
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
public:
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    15
	virtual ~RelationalWriter() = default;
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    16
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    17
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    18
	 * @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
    19
	 * @return numeric id of given type
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    20
	 * @throws RelpipeWriterException on unsupported typeCode
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    21
	 */
15
8fd6c4d44071 use more TypeId enum
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
    22
	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
    23
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    24
	/**
22
53f4887dadb4 todo comments
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    25
	 * TODO: use custom extensible class instead of std::pair 
53f4887dadb4 todo comments
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    26
	 * 
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    27
	 * @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
    28
	 * @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
    29
	 * @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
    30
	 */
13
e7234dd45166 use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 11
diff changeset
    31
	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
    32
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    33
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    34
	 * Writes a single attribute.
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    35
	 * @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
    36
	 */
17
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    37
	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
    38
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    39
	// TODO: fluent interface?
f2cccaa9dd38 replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 16
diff changeset
    40
	// TODO: << operator?
16
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    41
	// TODO: write bitmap + attribute:
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    42
	// virtual void writeBitmap(...) = 0;
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    43
	// 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
    44
18
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    45
	/**
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    46
	 * Writes a single attribute.
90efe2db1ca8 documentation for RelationalWriter and DataTypeWriterBase
František Kučera <franta-hg@frantovo.cz>
parents: 17
diff changeset
    47
	 * @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
    48
	 * @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
    49
	 * 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
    50
	 * 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
    51
	 */
16
3613617d3076 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 15
diff changeset
    52
	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
    53
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
};
01dd90eeedbb add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
8
03750aff8619 writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    56
}
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    57
}