src/DataTypeWriterBase.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 21 Jul 2018 17:30:25 +0200
branchv_0
changeset 9 0a40752e401d
parent 5 include/DataTypeWriterBase.h@7fe870c3362f
child 15 8fd6c4d44071
permissions -rw-r--r--
shared library with pure abstract class (interface)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
#pragma once
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
#include <string>
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     4
#include "../include/typedefs.h"
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
namespace relpipe {
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
namespace writer {
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
/**
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * This class contains common features that are independent from particular data type (generic/template type)
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 */
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
class DataTypeWriterBase {
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
private:
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
	const integer_t typeId;
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
	const string_t typeCode;
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
public:
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
	DataTypeWriterBase(const integer_t typeId, const string_t typeCode) :
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
	typeId(typeId), typeCode(typeCode) {
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
	}
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
	virtual ~DataTypeWriterBase() {
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
	};
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
4
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    25
	/**
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    26
	 * @param output output stream, should be at position where the value is to be written; the stream will not be closed not flushed after writing
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    27
	 * @param stringValue write value as given data type (e.g. integer or boolean); stringValue parameter contains given value in string representation of given data type
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    28
	 * E.g. integer 123 is passed as a character string "123"
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    29
	 * boolean true is passed as a character string "true".
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    30
	 * See Relational pipes format specification for details.
e6db28447957 documentation for readString() and writeString() methods
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    31
	 */
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	virtual void writeString(std::ostream& output, const string_t &stringValue) = 0;
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	/**
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	 * @param dataType data type code as defined in DDP L0
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
	 * @return whether this class supports conversions of this type
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	 */
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    38
	virtual bool supports(const integer_t &dataType) {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    39
		return dataType == typeId;
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    40
	}
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
	/**
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	 * @param dataType data type name as defined in DDP L0
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	 * @return whether this class supports conversions of this type
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
	 */
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    46
	virtual bool supports(const string_t &dataType) {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    47
		return dataType == typeCode;
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    48
	}
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    50
	integer_t getTypeId() {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    51
		return typeId;
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    52
	}
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    54
	string_t getTypeCode() {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    55
		return typeCode;
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    56
	}
1
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
};
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
6e3494943c91 base classes
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
}
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    60
}