# Poco::Data::ODBC

# class TypeInfo

Library: Data/ODBC
Package: ODBC
Header: Poco/Data/ODBC/TypeInfo.h

## Description

Datatypes mapping utility class.

This class provides mapping between C and SQL datatypes as well as datatypes supported by the underlying database. In order for database types to be available, a valid conection handle must be supplied at either object construction time, or at a later point in time, through call to fillTypeInfo member function.

Class also provides a convenient debugging function that prints tabulated data to an output stream.

## Member Summary

Member Functions: cDataType, fillTypeInfo, getInfo, print, reset, sqlDataType, tryGetInfo

## Types

### DataTypeMap

typedef std::map < int, int > DataTypeMap;

### TypeInfoTup

typedef Poco::NamedTuple < std::string, SQLSMALLINT, SQLINTEGER, std::string, std::string, std::string, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, std::string, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLINTEGER, SQLSMALLINT > TypeInfoTup;

### TypeInfoVec

typedef std::vector < TypeInfoTup > TypeInfoVec;

### ValueType

typedef DataTypeMap::value_type ValueType;

## Constructors

### TypeInfo

explicit TypeInfo(
SQLHDBC * pHDBC = nullptr
);

Creates the TypeInfo.

## Destructor

### ~TypeInfo

~TypeInfo();

Destroys the TypeInfo.

## Member Functions

### cDataType

SQLSMALLINT cDataType(
SQLSMALLINT sqlDataType
) const;

Returns C data type corresponding to supplied SQL data type.

### cDataType

template < SQLSMALLINT T > static constexpr SQLSMALLINT cDataType();

Returns C data type corresponding to supplied SQL data type.

### fillTypeInfo

void fillTypeInfo(
const SQLHDBC * pHDBC
);

Fills the data type info structure for the database.

### getInfo

Dynamic::Var getInfo(
SQLSMALLINT type,
const std::string & param
) const;

Returns information about specified data type as specified by parameter 'type'. The requested information is specified by parameter 'param'. Will fail with a Poco::NotFoundException thrown if the param is not found

### print

void print(
std::ostream & ostr
);

Prints all the types (as reported by the underlying database) to the supplied output stream.

### reset

void reset();

Clears cached type info, allowing refill on next fillTypeInfo call.

### sqlDataType

SQLSMALLINT sqlDataType(
SQLSMALLINT cDataType
) const;

Returns SQL data type corresponding to supplied C data type.

### sqlDataType

template < SQLSMALLINT T > static constexpr SQLSMALLINT sqlDataType();

Returns SQL data type corresponding to supplied C data type.

### tryGetInfo

bool tryGetInfo(
SQLSMALLINT type,
const std::string & param,
Dynamic::Var & result
) const;

Returns information about specified data type as specified by parameter 'type' in param result. The requested information is specified by parameter 'param'. Will return false if the param is not found. The value of result will be not changed in this case.