home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / sformat.hpp < prev    next >
C/C++ Source or Header  |  1996-07-03  |  4KB  |  128 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1996, by Watcom.  All rights  reserved.           %
  3.    %     No part of this software may be reproduced or used in any form  %
  4.    %     or by any means - graphic, electronic or mechanical, including  %
  5.    %     photocopying, recording, taping or information storage and      %
  6.    %     retrieval systems - except with the written permission of       %
  7.    %     Watcom.                                                         %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9.   
  10.     Date        By              Reason
  11.     ----        --              ------
  12.     27 May 96   Alan Shi        Created (Ported from VX-REXX)
  13.  
  14. */
  15.  
  16. #ifndef SFORMAT_HPP_INCLUDED
  17. #define SFORMAT_HPP_INCLUDED
  18.  
  19. #define VALID_ROUTINE                  0
  20. #define INVALID_ROUTINE                40
  21. #define MAXYEAR                        3000
  22.  
  23. enum {
  24.     DECIMAL_SUB = 0,
  25.     THOUSANDS_SUB,
  26.     TIMESEP_SUB,
  27.     DATESEP_SUB,
  28.     NUM_COUNTRY,
  29. };
  30.  
  31.  
  32. // Some of these fields were originally WUChars instead of WULongs.
  33. // This was changed because there is some code that assigns these values
  34. // to variables that were declared as WULongs (because these variables
  35. // sometimes held sentiel values outside the range of a WUChar).
  36.  
  37. typedef struct dateInf {
  38.     WULong   month;
  39.     WULong   year;
  40.     WULong   daynum;
  41.     WULong   day;
  42.     WBool    dayset;
  43.     WBool    daynumset;
  44.     WBool    yearset;
  45.     WBool    monthset;
  46. } dateInfo;
  47.  
  48. typedef dateInfo * pdateInfo;
  49.  
  50. typedef struct timeInf {
  51.     WULong   hours;
  52.     WULong   minutes;
  53.     WULong   seconds;
  54.     WULong   millths;
  55.     WBool    millthsset;
  56.     WBool    secondsset;
  57.     WBool    minutesset;
  58.     WBool    hoursset;
  59. } timeInfo;
  60.  
  61. typedef timeInfo * ptimeInfo;
  62.  
  63. typedef struct numInf {
  64.     WChar        *number;
  65.     WLong        exponent;
  66.     WBool        negative;
  67. } numInfo;
  68.  
  69. typedef numInfo * pnumInfo;
  70.  
  71. class SFormat {
  72.     public:
  73.         static WString SFormat::FormatString( WString input, WString mask,
  74.                                               WBool useCurDate = FALSE,
  75.                                               WDateOrder dOrder = WDateOrderUSA );
  76.     private:
  77.         static WChar *SFormat::Format( WChar *input, WChar *mask,
  78.                                        WBool usecurrentdate, WULong inptype );
  79.  
  80.         static WULong SFormat::DaysThisYear( WULong year, WULong month,
  81.                                              WULong daynum );
  82.  
  83.         static void SFormat::InvBaseDate( WULong daynumber, pdateInfo dinfo );
  84.  
  85.         static WULong SFormat::BaseDate( WULong year, WULong month,
  86.                                          WULong daynum );
  87.  
  88.         static WBool SFormat::DayCheck( pdateInfo dinfo );
  89.  
  90.         static WBool SFormat::FormatInDateInfo( pdateInfo dinfo, WChar *input,
  91.                                                 WBool usecurrentdate,
  92.                                                 WULong inptype );
  93.  
  94.         static WChar *SFormat::FormatOutDateInfo( pdateInfo dinfo,
  95.                                                   WChar *mask );
  96.  
  97.         static WChar *SFormat::FormatDate( WChar *input, WChar *mask,
  98.                                            WBool usecurrentdate,
  99.                                            WULong inptype );
  100.  
  101.         static WBool SFormat::FormatInTimeInfo( ptimeInfo tinfo,
  102.                                                 WChar *input,
  103.                                                 WBool usecurrentdate );
  104.  
  105.         static WChar * SFormat::FormatOutTimeInfo( ptimeInfo tinfo,
  106.                                                    WChar *mask );
  107.  
  108.         static WChar *SFormat::FormatTime( WChar *input, WChar *mask,
  109.                                            WBool usecurrentdate );
  110.  
  111.         static WBool SFormat::FormatInNumberInfo( pnumInfo ninfo,
  112.                                                   WChar *input );
  113.  
  114.         static WULong SFormat::FormatOutNumber( WChar **output, WChar *mask,
  115.                                                 pnumInfo ninfo );
  116.  
  117.         static WChar *SFormat::FormatOutNumberInfo( pnumInfo ninfo,
  118.                                                     WChar *mask );
  119.  
  120.         static WChar *SFormat::FormatNumber( WChar *input, WChar *mask );
  121.  
  122.         static WChar *SFormat::FormatOutString( WChar *input, WChar *mask );
  123.  
  124. };
  125.  
  126. #endif
  127.  
  128.