37. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 2/17/2017 12:43:23 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

37.1 Files compared

# Location File Last Modified
1 CPRS_V32_T20_cif.zip\OR_30_405V20_SRC.zip\CPRS-chart\Cover Sheet oDelimitedString.pas Thu Dec 15 14:28:30 2016 UTC
2 CPRS_V32_T20_cif.zip\OR_30_405V20_SRC.zip\CPRS-chart\Cover Sheet oDelimitedString.pas Fri Feb 17 17:19:19 2017 UTC

37.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 954
Changed 1 2
Inserted 0 0
Removed 0 0

37.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

37.4 Active regular expressions

No regular expressions were active.

37.5 Comparison detail

  1   unit oDeli mitedStrin g;
  2   {
  3     ======== ========== ========== ========== ========== ========== ========== ========== ==
  4     *
  5     *        Applicatio n:  CPRS -  Utility
  6              Developer:       PII                   
  7     *        Site:          Salt L ake City I SC
  8     *        Date:          2015-1 2-04
  9     *
  10     *        Descriptio n:  A bett er (IMHO)  way of han dling deli mited stri ngs from M
  11     *                       as wel l as a way  to store  the string s as an ob ject.
  12     *
  13     *        Notes:
  14     *
  15     ======== ========== ========== ========== ========== ========== ========== ========== ==
  16   }
  17  
  18   interface
  19  
  20   uses
  21     System.C lasses,
  22     System.S ysUtils;
  23  
  24   type
  25     TDelimit edStringDa teTimeStyl e = (dsdts Fileman, d sdtsSQL);
  26     TDelimit edStringDa teTimeForm at = (dsdt fDateTime,  dsdtfDate Only, dsdt fTimeOnly) ;
  27  
  28     TDelimit edString =  class(TOb ject)
  29     private
  30       fDelim iter: Char ;
  31       fList:  TStringLi st;
  32       fTrue:  string;
  33       fFalse : string;
  34       fDateT imeStyle:  TDelimited StringDate TimeStyle;
  35       fDoubl e: double;
  36       fInteg er: intege r;
  37  
  38       functi on getFals eStr: stri ng;
  39       functi on getTrue Str: strin g;
  40       functi on getCoun t: integer ;
  41       functi on getStyl e: TDelimi tedStringD ateTimeSty le;
  42  
  43       proced ure setFal seStr(cons t aValue:  string);
  44       proced ure setTru eStr(const  aValue: s tring);
  45       proced ure setSty le(const a Value: TDe limitedStr ingDateTim eStyle);
  46     public
  47       constr uctor Crea te(aString : string;  aDelimiter : Char = ' ^');
  48       destru ctor Destr oy; overri de;
  49  
  50       functi on GetPiec e(aIndex:  integer):  string; ov erload;
  51       functi on GetPiec e(aStart:  integer; a Stop: inte ger): stri ng; overlo ad;
  52       functi on GetPiec eAsString( aIndex: in teger; aDe fault: str ing = ''):  string;
  53       functi on GetPiec eAsInteger (aIndex: i nteger; aD efault: in teger = 0) : integer;
  54       functi on GetPiec eAsDouble( aIndex: in teger; aDe fault: dou ble = 0.0) : double;
  55       functi on GetPiec eAsBoolean (aIndex: i nteger; aD efault: bo olean = Fa lse): bool ean;
  56       functi on GetPiec eAsFMDateT imeStr(aIn dex: integ er; aDefau lt: double  = 0.0): s tring;
  57       functi on GetPiec eAsTDateTi me(aIndex:  integer;  aDefault:  TDateTime  = 0.0; aFo rmat: TDel imitedStri ngDateTime Format = d sdtfDateTi me): TDate Time;
  58       functi on GetPiec eEquals(aI ndex: inte ger; aComp areValue:  string; aC aseSensiti ve: boolea n = True):  boolean;  overload;
  59       functi on GetPiec eEquals(aI ndex: inte ger; aComp areValue:  integer):  boolean; o verload;
  60       functi on GetPiec eEquals(aI ndex: inte ger; aComp areValue:  double): b oolean; ov erload;
  61       functi on GetPiec eEquals(aI ndex: inte ger; aComp areValue:  boolean):  boolean; o verload;
  62       functi on GetPiec eIsDouble( aIndex: in teger): bo olean;
  63       functi on GetPiec eIsInteger (aIndex: i nteger): b oolean;
  64       functi on GetPiec eIsNotNull (aIndex: i nteger): b oolean;
  65       functi on GetPiec eIsNull(aI ndex: inte ger): bool ean;
  66       functi on GetPiec eIsTDateTi me(aIndex:  integer):  boolean;
  67  
  68       functi on GetDeli mitedStrin g: string;
  69       functi on GetStri ngInfo: st ring;
  70  
  71       proced ure SetPie ce(aIndex:  integer;  aValue: st ring); ove rload;
  72       proced ure SetPie ce(aIndex:  integer;  aValue: in teger); ov erload;
  73       proced ure SetPie ce(aIndex:  integer;  aValue: do uble; aPre cision: in teger = 2) ; overload ;
  74       proced ure SetPie ce(aIndex:  integer;  aValue: bo olean); ov erload;
  75       proced ure SetPie ce(aIndex:  integer;  aValue: TD ateTime);  overload;
  76  
  77       proper ty FalseSt r: string  read getFa lseStr wri te setFals eStr;
  78       proper ty TrueStr : string r ead getTru eStr write  setTrueSt r;
  79       proper ty Style:  TDelimited StringDate TimeStyle  read getSt yle write  setStyle;
  80       proper ty Count:  integer re ad getCoun t;
  81     end;
  82  
  83   function N ewDelimite dString(aS tring: str ing; aDeli miter: Cha r = '^'):  TDelimited String;
  84  
  85   implementa tion
  86  
  87   function N ewDelimite dString(aS tring: str ing; aDeli miter: Cha r = '^'):  TDelimited String;
  88   begin
  89     Result : = TDelimit edString.C reate(aStr ing, aDeli miter);
  90   end;
  91  
  92   { TDelimit edString }
  93  
  94   constructo r TDelimit edString.C reate(aStr ing: strin g; aDelimi ter: Char  = '^');
  95   begin
  96     inherite d Create;
  97     fTrue :=  '1';
  98     fFalse : = '0';
  99     fDateTim eStyle :=  dsdtsFilem an;
  100     fDelimit er := aDel imiter;
  101     fList :=  TStringLi st.Create;
  102     fList.De limiter :=  aDelimite r;
  103     fList.St rictDelimi ter := Tru e;
  104     fList.De limitedTex t := aStri ng;
  105   end;
  106  
  107   destructor  TDelimite dString.De stroy;
  108   begin
  109     fList.Cl ear;
  110     FreeAndN il(fList);
  111     inherite d;
  112   end;
  113  
  114   function T DelimitedS tring.getC ount: inte ger;
  115   begin
  116     Result : = fList.Co unt;
  117   end;
  118  
  119   function T DelimitedS tring.GetD elimitedSt ring: stri ng;
  120   begin
  121     Result : = fList.De limitedTex t;
  122   end;
  123  
  124   function T DelimitedS tring.getF alseStr: s tring;
  125   begin
  126     Result : = fFalse;
  127   end;
  128  
  129   function T DelimitedS tring.getS tyle: TDel imitedStri ngDateTime Style;
  130   begin
  131     Result : = fDateTim eStyle;
  132   end;
  133  
  134   function T DelimitedS tring.getT rueStr: st ring;
  135   begin
  136     Result : = fTrue;
  137   end;
  138  
  139   procedure  TDelimited String.set FalseStr(c onst aValu e: string) ;
  140   begin
  141     fFalse : = aValue;
  142   end;
  143  
  144   procedure  TDelimited String.set Style(cons t aValue:  TDelimited StringDate TimeStyle) ;
  145   begin
  146     fDateTim eStyle :=  aValue;
  147   end;
  148  
  149   procedure  TDelimited String.set TrueStr(co nst aValue : string);
  150   begin
  151     fTrue :=  aValue;
  152   end;
  153  
  154   function T DelimitedS tring.GetP iece(aInde x: integer ): string;
  155   { Does the  actual 'r eading' of  the value s - all ot her method s come her e }
  156   begin
  157     if fList .Count > 0  then
  158       if (aI ndex <= fL ist.Count)  and (aInd ex > 0) th en
  159         Resu lt := fLis t[aIndex -  1]
  160       else
  161         Resu lt := ''
  162     else
  163       Result  := '';
  164   end;
  165  
  166   function T DelimitedS tring.GetP iece(aStar t: integer ; aStop: i nteger): s tring;
  167   var
  168     i: integ er;
  169   begin
  170     Result : = '';
  171     for i :=  aStart to  aStop do
  172       begin
  173         Resu lt := Resu lt + GetPi ece(i);
  174         if i  < aStop t hen
  175           Re sult := Re sult + fDe limiter;
  176       end;
  177   end;
  178  
  179   function T DelimitedS tring.GetP ieceAsBool ean(aIndex : integer;  aDefault:  boolean):  boolean;
  180   begin
  181     Result : = CompareS tr(GetPiec e(aIndex),  fTrue) =  0;
  182   end;
  183  
  184   function T DelimitedS tring.GetP ieceAsDoub le(aIndex:  integer;  aDefault:  double): d ouble;
  185   begin
  186     Result : = StrToFlo atDef(GetP iece(aInde x), aDefau lt);
  187   end;
  188  
  189   function T DelimitedS tring.GetP ieceAsFMDa teTimeStr( aIndex: in teger; aDe fault: dou ble = 0.0) : string;
  190   var
  191     aStr: st ring;
  192     aDT: TDa teTime;
  193     YY, MM,  DD: intege r;
  194     h, m, s:  integer;
  195   begin
  196     if GetPi eceIsNotNu ll(aIndex)  then
  197       try
  198         aStr  := FloatT oStr(GetPi eceAsDoubl e(aIndex,  aDefault)  + 0.000000 1);
  199  
  200         YY : = StrToInt Def(Copy(a Str, 1, 3) , 0) + 170 0;
  201         MM : = StrToInt Def(Copy(a Str, 4, 2) , 0);
  202         DD : = StrToInt Def(Copy(a Str, 6, 2) , 0);
  203  
  204         h :=  StrToIntD ef(Copy(aS tr, 9, 2),  0);
  205         m :=  StrToIntD ef(Copy(aS tr, 11, 2) , 0);
  206         s :=  StrToIntD ef(Copy(aS tr, 13, 2) , 0);
  207  
  208         aStr  := 'MMM D D, YYYY';
  209  
  210         if ( MM = 0) th en
  211           be gin
  212              MM := 1;
  213              DD := 1;
  214              aStr := 'Y YYY';
  215           en d
  216         else  if (DD =  0) then
  217           be gin
  218              DD := 1;
  219              aStr := 'M MM YYYY';
  220           en d;
  221  
  222         aDT  := EncodeD ate(YY, MM , DD);
  223         if ( h > 0) or  (m > 0) or  (s > 0) t hen
  224           be gin
  225              aDT := aDT  + EncodeT ime(h, m,  s, 0);
  226              aStr := aS tr + ' @ h h:mm:ss';
  227           en d;
  228  
  229         Resu lt := Form atDateTime (aStr, aDT );
  230       except
  231         Resu lt := '##'  + GetPiec e(aIndex)  + '##';
  232       end
  233     else
  234       Result  := '';
  235   end;
  236  
  237   function T DelimitedS tring.GetP ieceAsInte ger(aIndex , aDefault : integer) : integer;
  238   begin
  239     Result : = StrToInt Def(GetPie ce(aIndex) , aDefault );
  240   end;
  241  
  242   function T DelimitedS tring.GetP ieceAsStri ng(aIndex:  integer;  aDefault:  string): s tring;
  243   begin
  244     Result : = GetPiece (aIndex);
  245     if Resul t = '' the n
  246       Result  := aDefau lt;
  247   end;
  248  
  249   function T DelimitedS tring.GetP ieceAsTDat eTime(aInd ex: intege r; aDefaul t: TDateTi me = 0.0;  aFormat: T DelimitedS tringDateT imeFormat  = dsdtfDat eTime): TD ateTime;
  250   var
  251     aDT: str ing;
  252     YY, MM,  DD: Word;
  253     h, m, s:  Word;
  254   begin
  255     Result : = aDefault ;
  256  
  257     aDT := G etPiece(aI ndex);
  258     if aDT =  '' then
  259       Exit;
  260  
  261     case fDa teTimeStyl e of
  262       dsdtsF ileman: {  VA Fileman  YYYMMDD.h hmmss }
  263         try
  264           aD T := Float ToStr(StrT oFloat(aDT ) + 0.0000 001); // M ay need to  use FORMA T HERE!!!
  265           YY  := StrToI nt(Copy(aD T, 1, 3))  + 1700;
  266           MM  := StrToI nt(Copy(aD T, 4, 2));
  267           DD  := StrToI nt(Copy(aD T, 6, 2));
  268           h  := StrToIn t(Copy(aDT , 9, 2));
  269           m  := StrToIn t(Copy(aDT , 11, 2));
  270           s  := StrToIn t(Copy(aDT , 13, 2));
  271           Re sult := En codeDate(Y Y, MM, DD)  + EncodeT ime(h, m,  s, 0);
  272         exce pt
  273           Re sult := aD efault;
  274         end;
  275       dsdtsS QL: { SQL  DATE TIME  YYYY-MM-DD  hh:mm:ss  }
  276         try
  277           YY  := StrToI nt(Copy(aD T, 1, 4));
  278           MM  := StrToI nt(Copy(aD T, 6, 2));
  279           DD  := StrToI nt(Copy(aD T, 9, 2));
  280           h  := StrToIn t(Copy(aDT , 12, 2));
  281           m  := StrToIn t(Copy(aDT , 15, 2));
  282           s  := StrToIn t(Copy(aDT , 18, 2));
  283           Re sult := En codeDate(Y Y, MM, DD)  + EncodeT ime(h, m,  s, 0);
  284         exce pt
  285           Re sult := aD efault;
  286         end;
  287     else
  288       Result  := aDefau lt;
  289     end;
  290   end;
  291  
  292   function T DelimitedS tring.GetP ieceEquals (aIndex: i nteger; aC ompareValu e: double) : boolean;
  293   var
  294     aPiece:  double;
  295   begin
  296     if GetPi eceIsNotNu ll(aIndex)  then
  297       begin
  298         aPie ce := GetP ieceAsDoub le(aIndex,  aCompareV alue - 1);
  299         Resu lt := aPie ce = aComp areValue;
  300       end
  301     else
  302       Result  := False;
  303   end;
  304  
  305   function T DelimitedS tring.GetP ieceEquals (aIndex, a CompareVal ue: intege r): boolea n;
  306   var
  307     aPiece:  integer;
  308   begin
  309     if GetPi eceIsNotNu ll(aIndex)  then
  310       begin
  311         aPie ce := GetP ieceAsInte ger(aIndex , aCompare Value - 1) ;
  312         Resu lt := aPie ce = aComp areValue;
  313       end
  314     else
  315       Result  := False;
  316   end;
  317  
  318   function T DelimitedS tring.GetP ieceEquals (aIndex: i nteger; aC ompareValu e: boolean ): boolean ;
  319   begin
  320     case aCo mpareValue  of
  321       True:  Result :=  (CompareSt r(GetPiece (aIndex),  fTrue) = 0 );
  322       False:  Result :=  (CompareS tr(GetPiec e(aIndex),  fFalse) =  0);
  323     else
  324       Result  := False;
  325     end;
  326   end;
  327  
  328   function T DelimitedS tring.GetP ieceEquals (aIndex: i nteger; aC ompareValu e: string;  aCaseSens itive: boo lean = Tru e): boolea n;
  329   var
  330     aPiece:  string;
  331   begin
  332     aPiece : = GetPiece (aIndex);
  333     case aCa seSensitiv e of
  334       True:  Result :=  (CompareSt r(aPiece,  aCompareVa lue) = 0);
  335       False:  Result :=  (CompareT ext(aPiece , aCompare Value) = 0 );
  336     else
  337       Result  := False;
  338     end;
  339   end;
  340  
  341   function T DelimitedS tring.GetS tringInfo:  string;
  342   var
  343     aLst: TS tringList;
  344     i: integ er;
  345   begin
  346     aLst :=  TStringLis t.Create;
  347     try
  348       aLst.A dd('Delimi ted String ');
  349       aLst.A dd('  Stri ng ......:  ' + GetDe limitedStr ing);
  350       aLst.A dd('  Coun t .......:  ' + IntTo Str(fList. Count));
  351       aLst.A dd('  Deli miter ...:  ' + fDeli miter);
  352       aLst.A dd('  True /False ..:  ' + fTrue  + '/' + f False);
  353       for i  := 0 to fL ist.Count  - 1 do
  354         aLst .Add(Forma t('  %2.2d :  %s', [i  + 1, fLis t[i]]));
  355       Result  := aLst.T ext;
  356     finally
  357       FreeAn dNil(aLst) ;
  358     end;
  359   end;
  360  
  361   procedure  TDelimited String.Set Piece(aInd ex: intege r; aValue:  string);
  362   { Does the  actual se tting of t he piece -  all other s convert  and come h ere }
  363   begin
  364     while fL ist.Count  < aIndex d o
  365       fList. Add('');
  366     fList[aI ndex - 1]  := aValue;
  367   end;
  368  
  369   procedure  TDelimited String.Set Piece(aInd ex: intege r; aValue:  boolean);
  370   begin
  371     if aValu e then
  372       SetPie ce(aIndex,  fTrue)
  373     else
  374       SetPie ce(aIndex,  fFalse);
  375   end;
  376  
  377   procedure  TDelimited String.Set Piece(aInd ex: intege r; aValue:  TDateTime );
  378   var
  379     aFMDT: d ouble;
  380     YY: Word ;
  381     MM: Word ;
  382     DD: Word ;
  383     h: Word;
  384     m: Word;
  385     s: Word;
  386     ms: Word ;
  387   begin
  388     DecodeDa te(aValue,  YY, MM, D D);
  389     DecodeTi me(aValue,  h, m, s,  ms);
  390  
  391     case fDa teTimeStyl e of
  392       dsdtsF ileman:
  393         begi n
  394           YY  := YY - 1 700;
  395           aF MDT := (YY  * 10000)  + (MM * 10 0) + DD;
  396           if  (h + m +  s) > 0 the n
  397              aFMDT := a FMDT + (h  * 0.01) +  (m * 0.000 1) + (s *  0.000001);
  398           Se tPiece(aIn dex, Forma t('%.6f',  [aFMDT]));
  399         end;
  400       dsdtsS QL:
  401         begi n
  402           Se tPiece(aIn dex, Forma tDateTime( 'YYYY-MM-D D hh:nn:ss ', aValue) );
  403         end;
  404     else
  405     end;
  406   end;
  407  
  408   procedure  TDelimited String.Set Piece(aInd ex: intege r; aValue:  double; a Precision:  integer =  2);
  409   begin
  410     SetPiece (aIndex, F ormat('%1. *f', [aPre cision, aV alue]));
  411   end;
  412  
  413   procedure  TDelimited String.Set Piece(aInd ex: intege r; aValue:  integer);
  414   begin
  415     SetPiece (aIndex, I ntToStr(aV alue))
  416   end;
  417  
  418   function T DelimitedS tring.GetP ieceIsDoub le(aIndex:  integer):  boolean;
  419   var
  420     aCode: i nteger;
  421   begin
  422     try
  423       if Get PieceIsNot Null(aInde x) then
  424         begi n
  425           Va l(GetPiece (aIndex),  fDouble, a Code);
  426           Re sult := (a Code = 0);
  427         end
  428       else
  429         Resu lt := Fals e;
  430     except
  431       on E:  EConvertEr ror do
  432         Resu lt := Fals e;
  433       on E:  Exception  do
  434         rais e E;
  435     end;
  436   end;
  437  
  438   function T DelimitedS tring.GetP ieceIsInte ger(aIndex : integer) : boolean;
  439   var
  440     aCode: i nteger;
  441   begin
  442     try
  443       if Get PieceIsNot Null(aInde x) then
  444         begi n
  445           Va l(GetPiece (aIndex),  fInteger,  aCode);
  446           Re sult := (a Code = 0);
  447         end
  448       else
  449         Resu lt := Fals e;
  450     except
  451       on E:  EConvertEr ror do
  452         Resu lt := Fals e;
  453       on E:  Exception  do
  454         rais e E;
  455     end;
  456   end;
  457  
  458   function T DelimitedS tring.GetP ieceIsNotN ull(aIndex : integer) : boolean;
  459   begin
  460     Result : = (Length( GetPiece(a Index)) >  0);
  461   end;
  462  
  463   function T DelimitedS tring.GetP ieceIsNull (aIndex: i nteger): b oolean;
  464   begin
  465     Result : = (Length( GetPiece(a Index)) =  0);
  466   end;
  467  
  468   function T DelimitedS tring.GetP ieceIsTDat eTime(aInd ex: intege r): boolea n;
  469   begin
  470     try
  471       GetPie ceAsTDateT ime(aIndex );
  472       Result  := True;
  473     except
  474       Result  := False;
  475     end;
  476   end;
  477  
  478   end.