#ifndef FBCDatatypeMetaData__H
#define FBCDatatypeMetaData__H

#include "FBDataTypes.h"

#ifndef FBVersion
#define FBVersion 7
#elif FBVersion != 7
#error "oThe headers for FBCAccess version have been mixed"
#endif


typedef struct FBCDatatypeMetaData FBCDatatypeMetaData;
/*!
@header FBCDatatypeMetaData
 @discussion FBCDatatypeMetaData objects are maintained by FBCMetaData.  They are read-only and you shouldn't worry about allocating or releasing them.

 Use the methods fbcmdDatatypeMetaDataAtIndex or fbccmdDatatype to get access to FBCDatatypeMetaData objects.
 */

#ifdef __cplusplus
extern "C" {
#endif

typedef FBDatatypeCode FBCDatatypeCode;

/*!
@function fbcdmdDatatypeCode
 @discussion The internal datatype code.
 */
FBCDatatypeCode fbcdmdDatatypeCode(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdLength
 @discussion The length of the datatype in bytes.
 */
unsigned  fbcdmdLength(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdPrecision
 @discussion The precision of the datatype.
 */
unsigned fbcdmdPrecision(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdScale
 @discussion The scale of the datatype.
 */
unsigned fbcdmdScale(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdFractionalPrecision
 @discussion The fractional of the datatype (in case of e.g. INTERVAL '...' DAY TO SECOND(6))
 */
unsigned fbcdmdFractionalPrecision(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdDatatypeString
 @discussion The name of the datatype.
 @result The returned string should not be freed by the caller.
 */
const char* fbcdmdDatatypeString(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdFrom
 @discussion The "from" portion of a SQL 92 INTERVAL.
 */
const char* fbcdmdFrom(const FBCDatatypeMetaData* self);

/*!
@function fbcdmdTo
 @discussion The "to" portion of a SQL 92 INTERVAL.
 */
const char* fbcdmdTo(const FBCDatatypeMetaData* self);


/*!
@function FBCDatatypeMetaData
 @discussion Build a DataTypeMetaData object for a AnyType column
 */
FBCDatatypeMetaData* fbcdmdAnyTypeMetaData(const FBCDatatypeMetaData* dtmd, void* column);

/*!
@function fbcdmdRelease
 @discussion Internal API.
 */
FBCDatatypeMetaData* fbcdmdRetain  ( FBCDatatypeMetaData* self);
void                 fbcdmdRelease ( FBCDatatypeMetaData* self);

#ifdef __cplusplus
}
#endif

#endif /* FBCDatatypeMetaData__H */
