include/relpipe/reader/DataTypeReaderBase.h
branchv_0
changeset 13 543f1613c2da
parent 12 2d7109286408
child 14 e8de089f95dd
equal deleted inserted replaced
12:2d7109286408 13:543f1613c2da
     1 #pragma once
       
     2 
       
     3 #include <string>
       
     4 #include "typedefs.h"
       
     5 
       
     6 namespace relpipe {
       
     7 namespace reader {
       
     8 
       
     9 /**
       
    10  * This class contains common features that are independent from particular data type (generic/template type)
       
    11  */
       
    12 class DataTypeReaderBase {
       
    13 private:
       
    14 	const integer_t typeId;
       
    15 	const string_t typeCode;
       
    16 public:
       
    17 
       
    18 	DataTypeReaderBase(const integer_t typeId, const string_t typeCode) :
       
    19 	typeId(typeId), typeCode(typeCode) {
       
    20 	}
       
    21 
       
    22 	virtual ~DataTypeReaderBase() {
       
    23 	};
       
    24 
       
    25 	/**
       
    26 	 * @param input input stream, should be at position where the value is to be read; the stream will not be closed afred reading
       
    27 	 * @return read value in form of the string representation of given data type.
       
    28 	 * E.g. integer 123 is returned as a character string "123",
       
    29 	 * boolean true is returned as a character string "true".
       
    30 	 * See Relational pipes format specification for details.
       
    31 	 */
       
    32 	virtual string_t readString(std::istream &input) = 0;
       
    33 
       
    34 	/**
       
    35 	 * @param dataType data type code as defined in DDP L0
       
    36 	 * @return whether this class supports conversions of this type
       
    37 	 */
       
    38 	virtual bool supports(const integer_t &dataType);
       
    39 
       
    40 	/**
       
    41 	 * @param dataType data type name as defined in DDP L0
       
    42 	 * @return whether this class supports conversions of this type
       
    43 	 */
       
    44 	virtual bool supports(const string_t &dataType);
       
    45 
       
    46 	integer_t getTypeId();
       
    47 
       
    48 	string_t getTypeCode();
       
    49 };
       
    50 
       
    51 }
       
    52 }