
//////////////////////////////////////////////////
//  ASE Data Access Components
//  Copyright © 2008-2014 Devart. All right reserved.
//////////////////////////////////////////////////

{$IFNDEF CLR}

{$I ASEDac.inc}
unit ASEDataTypeMapUni;
{$ENDIF}

interface

uses
  DB, CRDataTypeMap,
{$IFNDEF UNIDACPRO}
  ODBCCall, ODBCDataTypeMap;
{$ELSE}
  ODBCCallUni, ODBCDataTypeMapUni;
{$ENDIF}

const
  aseOffset       = 300;
  aseBase         = odbcBase + aseOffset;

  aseChar         = odbcChar          + aseOffset;
  aseUniChar      = odbcWideChar      + aseOffset;
  aseVarchar      = odbcVarChar       + aseOffset;
  aseUniVarChar   = odbcWideVarChar   + aseOffset;
  aseSmallint     = odbcSmallInt      + aseOffset;
  aseTinyInt      = odbcTinyInt       + aseOffset;
  aseInteger      = odbcInteger       + aseOffset;
  aseDecimal      = odbcDecimal       + aseOffset;
  aseFloat        = odbcFloat         + aseOffset;
  aseDouble       = odbcDouble        + aseOffset;
  aseReal         = odbcReal          + aseOffset;
  aseNumeric      = odbcNumeric       + aseOffset;
  aseDate         = odbcDate          + aseOffset;
  aseTime         = odbcTime          + aseOffset;
  aseDateTime     = odbcTimeStamp     + aseOffset;
  aseBit          = odbcBit           + aseOffset;
  aseBinary       = odbcBinary        + aseOffset;
  aseVarBinary    = odbcVarBinary     + aseOffset;
  aseImage        = odbcLongVarBinary + aseOffset;
  aseText         = odbcLongVarChar   + aseOffset;

type

  TASEMapRules = class (TCRMapRules)
  public
    class function GetConverterManager: TConverterManager; override;
  end;

  TASEConverterManager = class(TODBCConverterManager)
  public
    class function GetDBProvider: Word; override;
    class function GetDBType(SQLType: Integer): Word; override;
  end;

  procedure InitASETypes;

implementation

uses
  MemData,
{$IFNDEF UNIDACPRO}
  ASEClasses;
{$ELSE}
  ASEClassesUni;
{$ENDIF}

var
  ASEConverterManager: TASEConverterManager;

{ Function }

procedure InitASETypes;
begin
  DBTypeInfos.Add(aseChar,           'Char',             True,  False);
  DBTypeInfos.Add(aseUniChar,        'UniChar',          True,  False);
  DBTypeInfos.Add(aseVarchar,        'VarChar',          True,  False);
  DBTypeInfos.Add(aseUniVarChar,     'UniVarChar',       True,  False);
  DBTypeInfos.Add(aseSmallint,       'SmallInt',         False, False);
  DBTypeInfos.Add(aseTinyInt,        'TinyInt',          False, False);
  DBTypeInfos.Add(aseInteger,        'Integer',          False, False);
  DBTypeInfos.Add(aseDecimal,        'Decimal',          False, False);
  DBTypeInfos.Add(aseFloat,          'Float',            False, False);
  DBTypeInfos.Add(aseDouble,         'Double',           False, False);
  DBTypeInfos.Add(aseReal,           'Real',             True,  False);
  DBTypeInfos.Add(aseNumeric,        'Numeric',          True,  True);
  DBTypeInfos.Add(aseDate,           'Date',             False, False);
  DBTypeInfos.Add(aseTime,           'Time',             False, False);
  DBTypeInfos.Add(aseDateTime,       'DateTime',         False, False);
  DBTypeInfos.Add(aseBit,            'Bit',              False, False);
  DBTypeInfos.Add(aseBinary,         'Binary',           True,  False);
  DBTypeInfos.Add(aseVarBinary,      'VarBinary',        True,  False);
  DBTypeInfos.Add(aseImage,          'Image',            False, False);
  DBTypeInfos.Add(aseText,           'Text',             False, False);
end;

{ TASEDataMapRules }

class function TASEMapRules.GetConverterManager: TConverterManager;
begin
  Result := ASEConverterManager;
end;

{ TASEConverterManager }

class function TASEConverterManager.GetDBProvider: Word;
begin
  Result := aseBase;
end;

class function TASEConverterManager.GetDBType(SQLType: Integer): Word;
begin
  Result := inherited GetDBType(SQLType) + aseOffset;
end;

initialization
  InitASETypes;
  ASEConverterManager := TASEConverterManager.Create;

finalization
  ASEConverterManager.Free;

end.
