home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 September / dppcpro0998.iso / Rwc / Sybase / Install.exe / hpp.z / sformat.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  4.6 KB  |  139 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. #pragma once
  19.  
  20. #ifndef _WNO_PRAGMA_PUSH
  21. #pragma pack(push,8);
  22. #pragma enum int;
  23. #endif
  24.  
  25. #define VALID_ROUTINE                  0
  26. #define INVALID_ROUTINE                40
  27. #define MAXYEAR                        3000
  28.  
  29. enum {
  30.     DECIMAL_SUB = 0,
  31.     THOUSANDS_SUB,
  32.     TIMESEP_SUB,
  33.     DATESEP_SUB,
  34.     NUM_COUNTRY,
  35. };
  36.  
  37.  
  38. // Some of these fields were originally WUChars instead of WULongs.
  39. // This was changed because there is some code that assigns these values
  40. // to variables that were declared as WULongs (because these variables
  41. // sometimes held sentiel values outside the range of a WUChar).
  42.  
  43. typedef struct dateInf {
  44.     WULong   month;
  45.     WULong   year;
  46.     WULong   daynum;
  47.     WULong   day;
  48.     WBool    dayset;
  49.     WBool    daynumset;
  50.     WBool    yearset;
  51.     WBool    monthset;
  52. } dateInfo;
  53.  
  54. typedef dateInfo * pdateInfo;
  55.  
  56. typedef struct timeInf {
  57.     WULong   hours;
  58.     WULong   minutes;
  59.     WULong   seconds;
  60.     WULong   millths;
  61.     WBool    millthsset;
  62.     WBool    secondsset;
  63.     WBool    minutesset;
  64.     WBool    hoursset;
  65. } timeInfo;
  66.  
  67. typedef timeInfo * ptimeInfo;
  68.  
  69. typedef struct numInf {
  70.     WChar        *number;
  71.     WLong        exponent;
  72.     WBool        negative;
  73. } numInfo;
  74.  
  75. typedef numInfo * pnumInfo;
  76.  
  77. class SFormat {
  78.     public:
  79.         static WString SFormat::FormatString( WString input, WString mask,
  80.                                               WBool useCurDate = FALSE,
  81.                                               WDateOrder dOrder = WDateOrderUSA );
  82.     private:
  83.         static WChar *SFormat::Format( WChar *input, WChar *mask,
  84.                                        WBool usecurrentdate, WULong inptype );
  85.  
  86.         static WULong SFormat::DaysThisYear( WULong year, WULong month,
  87.                                              WULong daynum );
  88.  
  89.         static void SFormat::InvBaseDate( WULong daynumber, pdateInfo dinfo );
  90.  
  91.         static WULong SFormat::BaseDate( WULong year, WULong month,
  92.                                          WULong daynum );
  93.  
  94.         static WBool SFormat::DayCheck( pdateInfo dinfo );
  95.  
  96.         static WBool SFormat::FormatInDateInfo( pdateInfo dinfo, WChar *input,
  97.                                                 WBool usecurrentdate,
  98.                                                 WULong inptype );
  99.  
  100.         static WChar *SFormat::FormatOutDateInfo( pdateInfo dinfo,
  101.                                                   WChar *mask );
  102.  
  103.         static WChar *SFormat::FormatDate( WChar *input, WChar *mask,
  104.                                            WBool usecurrentdate,
  105.                                            WULong inptype );
  106.  
  107.         static WBool SFormat::FormatInTimeInfo( ptimeInfo tinfo,
  108.                                                 WChar *input,
  109.                                                 WBool usecurrentdate );
  110.  
  111.         static WChar * SFormat::FormatOutTimeInfo( ptimeInfo tinfo,
  112.                                                    WChar *mask );
  113.  
  114.         static WChar *SFormat::FormatTime( WChar *input, WChar *mask,
  115.                                            WBool usecurrentdate );
  116.  
  117.         static WBool SFormat::FormatInNumberInfo( pnumInfo ninfo,
  118.                                                   WChar *input );
  119.  
  120.         static WULong SFormat::FormatOutNumber( WChar **output, WChar *mask,
  121.                                                 pnumInfo ninfo );
  122.  
  123.         static WChar *SFormat::FormatOutNumberInfo( pnumInfo ninfo,
  124.                                                     WChar *mask );
  125.  
  126.         static WChar *SFormat::FormatNumber( WChar *input, WChar *mask );
  127.  
  128.         static WChar *SFormat::FormatOutString( WChar *input, WChar *mask );
  129.  
  130. };
  131.  
  132. #ifndef _WNO_PRAGMA_PUSH
  133. #pragma enum pop;
  134. #pragma pack(pop);
  135. #endif
  136.  
  137. #endif
  138.  
  139.