Mudanças entre as edições de "Tiny Types"
De Grupo Acert
Linha 79: | Linha 79: | ||
TCNPJ = record | TCNPJ = record | ||
− | + | private | |
FUnformatted: string; | FUnformatted: string; | ||
function GetFormatted: string; | function GetFormatted: string; | ||
Linha 91: | Linha 91: | ||
property Unformatted: string read FUnformatted; | property Unformatted: string read FUnformatted; | ||
property Formatted: string read GetFormatted; | property Formatted: string read GetFormatted; | ||
− | + | ||
end; | end; | ||
− | + | ||
TCPF = record | TCPF = record | ||
private | private | ||
Linha 99: | Linha 99: | ||
function GetFormatted: string; | function GetFormatted: string; | ||
+ | |||
public | public | ||
class operator Implicit(const CPF: string): TCPF; | class operator Implicit(const CPF: string): TCPF; | ||
Linha 113: | Linha 114: | ||
uses | uses | ||
− | + | MaskUtils, StrUtils, SysUtils; | |
function Clear(const Doc: string): string; | function Clear(const Doc: string): string; | ||
Linha 136: | Linha 137: | ||
class operator TCNPJ.Implicit(const CNPJ: string): TCNPJ; | class operator TCNPJ.Implicit(const CNPJ: string): TCNPJ; | ||
begin | begin | ||
− | |||
Result.FUnformatted := Clear(CNPJ); | Result.FUnformatted := Clear(CNPJ); | ||
− | |||
end; | end; | ||
function TCNPJ.GetFormatted: string; | function TCNPJ.GetFormatted: string; | ||
begin | begin | ||
− | |||
Result := MaskUtils.FormatMaskText('00.000.000/0000-00;0; ', FUnformatted); | Result := MaskUtils.FormatMaskText('00.000.000/0000-00;0; ', FUnformatted); | ||
− | |||
end; | end; | ||
class operator TCNPJ.Implicit(const CNPJ: TCNPJ): string; | class operator TCNPJ.Implicit(const CNPJ: TCNPJ): string; | ||
begin | begin | ||
− | |||
Result := CNPJ.FUnformatted; | Result := CNPJ.FUnformatted; | ||
− | |||
end; | end; | ||
Linha 226: | Linha 221: | ||
class operator TCPF.Implicit(const CPF: string): TCPF; | class operator TCPF.Implicit(const CPF: string): TCPF; | ||
begin | begin | ||
− | |||
Result.FUnformatted := Clear(CPF); | Result.FUnformatted := Clear(CPF); | ||
− | |||
end; | end; | ||
function TCPF.GetFormatted: string; | function TCPF.GetFormatted: string; | ||
begin | begin | ||
− | |||
Result := MaskUtils.FormatMaskText('000.000.000-00;0; ', FUnformatted); | Result := MaskUtils.FormatMaskText('000.000.000-00;0; ', FUnformatted); | ||
− | |||
end; | end; | ||
class operator TCPF.Implicit(const CPF: TCPF): string; | class operator TCPF.Implicit(const CPF: TCPF): string; | ||
begin | begin | ||
− | |||
Result := CPF.FUnformatted; | Result := CPF.FUnformatted; | ||
− | |||
end; | end; | ||