?? myldbconverts.pas
字號:
Break;
end;
end;//StrToAft
//------------------------------------------------------------------------------
// BaseFieldType for print
//------------------------------------------------------------------------------
function BftToStr(BaseFieldType: TMYLDBBaseFieldType): String;
var i: Integer;
begin
Result := 'Unknown';
for i:=Low(SQLFieldTypes) to High(SQLFieldTypes) do
if SQLFieldTypes[i].BaseFieldType = BaseFieldType then
begin
Result := SQLFieldTypes[i].SqlName;
break;
end;
end;//BftToStr
//------------------------------------------------------------------------------
// FieldType for print
//------------------------------------------------------------------------------
function FtToStr(FieldType: TFieldType): String;
var i: Integer;
begin
Result := 'Unknown';
for i:=Low(SQLFieldTypes) to High(SQLFieldTypes) do
if SQLFieldTypes[i].FieldType = FieldType then
begin
Result := SQLFieldTypes[i].SqlName;
break;
end;
end;//FtToStr
//------------------------------------------------------------------------------
// Convert MYLDBDate to Date
//------------------------------------------------------------------------------
function MYLDBDateToDate(MYLDBDate: TMYLDBDate): TDateTime;
const
// MinInteger (-2147483648) + DateDelta
MinDate = -2146790054;
begin
if MYLDBDate > MinDate then
Result := MYLDBDate - DateDelta;
end;//MYLDBDateToDate
//------------------------------------------------------------------------------
// Convert Date to MYLDBDate
//------------------------------------------------------------------------------
function DateToMYLDBDate(Date: TDateTime): TMYLDBDate;
begin
Result := Trunc(Date) + DateDelta;
end;//DateToMYLDBDate
//------------------------------------------------------------------------------
// Convert MYLDBTime to Time
//------------------------------------------------------------------------------
function MYLDBTimeToTime(MYLDBTime: TMYLDBTime): TDateTime;
begin
Result := Frac(MYLDBTime / (24*60*60*1000));
end;//MYLDBTimeToTime
//------------------------------------------------------------------------------
// Convert Time to MYLDBTime
//------------------------------------------------------------------------------
function TimeToMYLDBTime(Time: TDateTime): TMYLDBTime;
begin
//Result := Trunc(Frac(Time) * (24*60*60*1000));
Result := Round(Frac(Time) * (24*60*60*1000));
end;//TimeToMYLDBTime
//------------------------------------------------------------------------------
// Convert MYLDBDateTime to DateTime
//------------------------------------------------------------------------------
function MYLDBDateTimeToDateTime(MYLDBDateTime: TMYLDBDateTime): TDateTime;
begin
Result := MYLDBDateToDate(MYLDBDateTime.Date) + MYLDBTimeToTime(MYLDBDateTime.Time);
end;//MYLDBDateTimeToDateTime
//------------------------------------------------------------------------------
// Convert DateTime to MYLDBDateTime
//------------------------------------------------------------------------------
function DateTimeToMYLDBDateTime(DateTime: TDateTime): TMYLDBDateTime;
begin
Result.Date := DateToMYLDBDate(DateTime);
Result.Time := TimeToMYLDBTime(DateTime);
end;//MYLDBDateTimeToDateTime
//------------------------------------------------------------------------------
// return true if field type is a BLOB field type
//------------------------------------------------------------------------------
function IsBLOBFieldType(FieldType: TMYLDBBaseFieldType): Boolean;
begin
Result := FieldType in [bftBLOB, bftClob, bftWideClob];
end; // IsBLOBFieldType
//------------------------------------------------------------------------------
// return true if field type is a BLOB field type
//------------------------------------------------------------------------------
function IsBLOBFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftBLOB, aftGraphic, aftMemo, aftFormattedMemo, aftWideMemo];
end; // IsBLOBFieldType
//------------------------------------------------------------------------------
// return true if field type is a string field type, but not wide string
//------------------------------------------------------------------------------
function IsStringFieldType(FieldType: TMYLDBBaseFieldType): Boolean;
begin
Result := FieldType in [bftChar, bftWideChar, bftVarchar, bftWideVarchar];
end; // IsStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a string field type, but not wide string
//------------------------------------------------------------------------------
function IsStringFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftChar, aftString, aftWideChar, aftWideString, aftGuid];
end; // IsStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a wide string field type
//------------------------------------------------------------------------------
function IsWideStringFieldType(FieldType: TMYLDBBaseFieldType): Boolean;
begin
Result := FieldType in [bftWideChar, bftWideVarchar];
end; // IsStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a wide string field type
//------------------------------------------------------------------------------
function IsWideStringFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftWideChar, aftWideString];
end; // IsWideStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a Bytes field type, but not wide Bytes
//------------------------------------------------------------------------------
function IsBytesFieldType(FieldType: TMYLDBBaseFieldType): Boolean;
begin
Result := FieldType in [bftBytes, bftVarBytes];
end; // IsBytesFieldType
//------------------------------------------------------------------------------
// return true if field type is a Bytes field type, but not wide Bytes
//------------------------------------------------------------------------------
function IsBytesFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftBytes, aftVarBytes];
end; // IsBytesFieldType
//------------------------------------------------------------------------------
// return true if field type is a Autoinc field type, but not wide Autoinc
//------------------------------------------------------------------------------
function IsAutoincFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftAutoInc,
aftAutoIncShortint,
aftAutoIncSmallint,
aftAutoIncInteger,
aftAutoIncLargeint,
aftAutoIncByte,
aftAutoIncWord,
aftAutoIncCardinal];
end; // IsAutoincFieldType
//------------------------------------------------------------------------------
// return true if DataType is numeric
//------------------------------------------------------------------------------
function IsNumericFieldType(FieldType: TMYLDBBaseFieldType): Boolean;
begin
Result := FieldType in [bftSignedInt8, bftSignedInt16, bftSignedInt32, bftSignedInt64,
bftUnsignedInt8, bftUnsignedInt16, bftUnsignedInt32,
bftSingle, bftDouble, bftExtended, bftCurrency];
end;//IsNumericDataType
//------------------------------------------------------------------------------
// return true if DataType is numeric
//------------------------------------------------------------------------------
function IsNumericFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := IsNumericFieldType(AdvancedFieldTypeToBaseFieldType(FieldType));
end;//IsNumericDataType
//------------------------------------------------------------------------------
// return true if DataType is TateTime, Time, Date, TimeStamp
//------------------------------------------------------------------------------
function IsDateTimeFieldType(FieldType: TMYLDBBaseFieldType): Boolean;
begin
Result := FieldType in [bftDate, bftTime, bftDateTime];
end;//IsDateTimeFieldType
//------------------------------------------------------------------------------
// return true if DataType is TateTime, Time, Date, TimeStamp
//------------------------------------------------------------------------------
function IsDateTimeFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := IsDateTimeFieldType(AdvancedFieldTypeToBaseFieldType(FieldType));
end;//IsDateTimeFieldType
//------------------------------------------------------------------------------
// return true if DataType is String, bytes, etc.
//------------------------------------------------------------------------------
function IsSizebleFieldType(FieldType: TMYLDBAdvancedFieldType): Boolean;
begin
Result := (IsStringFieldType(FieldType) or (FieldType in [aftBytes, aftVarBytes])) and
(FieldType <> aftGuid); // 5.05 fix ExportToSQL problem
end;//IsSizebleFieldType
//------------------------------------------------------------------------------
// Result = Can cast this type
//------------------------------------------------------------------------------
function IsConvertableFieldType(FieldType: TMYLDBAdvancedFieldType): boolean;
begin
Result := FieldType in [aftChar, aftString, aftWideChar, aftWideString,
aftShortint, aftSmallint,
aftAutoInc,aftAutoIncShortint,aftAutoIncSmallint,aftAutoIncInteger,aftAutoIncLargeint,aftAutoIncByte,aftAutoIncWord,aftAutoIncCardinal,
aftInteger,
aftLargeint, aftByte, aftWord, aftCardinal,
aftSingle, aftDouble, aftExtended,
aftBoolean,
aftCurrency,
aftDate, aftTime, aftDateTime, aftTimeStamp,
aftMemo, aftFormattedMemo, aftWideMemo];
end; // IsConvertableFieldType
function IsStrMatchPattern(StrPtr: PChar; PatternPtr: PChar; IsPatternEscaped: Boolean; EscapeChar: Char; bIgnoreCase:boolean): Boolean;
var i : integer;
bEQ: Boolean;
tmp1, tmp2: array [0..1] of char;
begin
tmp1[0]:=#0; tmp1[1]:=#0;
tmp2[0]:=#0;tmp2[1]:=#0;
repeat
if (StrComp(PatternPtr,WildCardMultipleChar)=0) then
begin
Result:=True;
exit;
end
else if (StrPtr^=#0) and (PatternPtr^ <> #0) then
begin
Result:=False;
exit;
end
else if (StrPtr^=#0) then
begin
Result:=True;
exit;
end
else
begin
case PatternPtr^ of
WildCardMultipleChar:
begin
for i:=0 to Length(StrPtr)-1 do
begin
if IsStrMatchPattern(StrPtr+i,PatternPtr+1,IsPatternEscaped,EscapeChar,bIgnoreCase) then
begin
Result := True;
exit;
end;
end;
Result := False;
exit;
end;
WildCardSingleChar:
begin
inc(StrPtr);
inc(PatternPtr);
end;
else
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -