Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
7.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation.
  4. //
  5. // File: OutFmt.hxx
  6. //
  7. // Contents: COutputFormat
  8. //
  9. // History: 11-Jun-97 KyleP Moved from WQIter.hxx
  10. //
  11. //----------------------------------------------------------------------------
  12. #pragma once
  13. //+---------------------------------------------------------------------------
  14. //
  15. // Class: COutputFormat
  16. //
  17. // Purpose: Stores the number and current formats for a given locale.
  18. //
  19. // History: 96/Jan/23 DwightKr Created
  20. //
  21. //----------------------------------------------------------------------------
  22. class COutputFormat : public CWebServer
  23. {
  24. public:
  25. COutputFormat( CWebServer & webServer );
  26. ~COutputFormat()
  27. {
  28. delete _numberFormat.lpDecimalSep;
  29. delete _numberFormat.lpThousandSep;
  30. delete _currencyFormat.lpDecimalSep;
  31. delete _currencyFormat.lpThousandSep;
  32. //
  33. // Don't attempt to delete _currencyFormat.lpCurrencySymbol
  34. // as it points to a constant.
  35. //
  36. }
  37. void LoadNumberFormatInfo( LCID lcid );
  38. void LoadNumberFormatInfo( LCID lcid , ULONG codepage );
  39. NUMBERFMT * GetNumberFormat() { return &_numberFormat; }
  40. CURRENCYFMT * GetCurrencyFormat() { return &_currencyFormat; }
  41. int FormatNumber( ULONG ulNumber, WCHAR * wcsNumber, ULONG cwcNumber );
  42. int FormatNumber( LONG lNumber, WCHAR * wcsNumber, ULONG cwcNumber );
  43. int FormatNumber( _int64 i64Number, WCHAR * wcsNumber, ULONG cwcNumber );
  44. int FormatNumber( unsigned _int64 ui64Number, WCHAR * wcsNumber, ULONG cwcNumber );
  45. int FormatFloat( double flt, unsigned cchPrec, WCHAR * pwszNumber, ULONG cchNumber );
  46. int FormatFloatRaw( double flt, unsigned cchPrec, WCHAR * pwszNumber, ULONG cchNumber );
  47. int FormatCurrency( CY cyVal, WCHAR * wcsNumber, ULONG cwcNumber );
  48. int FormatDateTime( FILETIME & ftUTC, WCHAR * wcsDate, ULONG cwcDate )
  49. {
  50. SYSTEMTIME SysTime;
  51. FileTimeToSystemTime( &ftUTC, &SysTime );
  52. return FormatDateTime( SysTime, wcsDate, cwcDate );
  53. }
  54. int FormatDateTime( SYSTEMTIME & sysTime, WCHAR * wcsDate, ULONG cwcDate );
  55. int FormatDate( SYSTEMTIME & sysTime, WCHAR * wcsDate, ULONG cwcDate );
  56. int FormatTime( SYSTEMTIME & sysTime, WCHAR * wcsTime, ULONG cwcTime );
  57. void SetBoolVectorFormat( const WCHAR * wcsVectorPrefix,
  58. const WCHAR * wcsVectorSeparator,
  59. const WCHAR * wcsVectorSuffix )
  60. {
  61. if ( wcsVectorPrefix ) _wcsBoolVectorPrefix = wcsVectorPrefix;
  62. if ( wcsVectorSeparator ) _wcsBoolVectorSeparator = wcsVectorSeparator;
  63. if ( wcsVectorSuffix ) _wcsBoolVectorSuffix = wcsVectorSuffix;
  64. }
  65. void SetCurrencyVectorFormat( const WCHAR * wcsVectorPrefix,
  66. const WCHAR * wcsVectorSeparator,
  67. const WCHAR * wcsVectorSuffix )
  68. {
  69. if ( wcsVectorPrefix ) _wcsCurrencyVectorPrefix = wcsVectorPrefix;
  70. if ( wcsVectorSeparator ) _wcsCurrencyVectorSeparator = wcsVectorSeparator;
  71. if ( wcsVectorSuffix ) _wcsCurrencyVectorSuffix = wcsVectorSuffix;
  72. }
  73. void SetDateVectorFormat( const WCHAR * wcsVectorPrefix,
  74. const WCHAR * wcsVectorSeparator,
  75. const WCHAR * wcsVectorSuffix )
  76. {
  77. if ( wcsVectorPrefix ) _wcsDateVectorPrefix = wcsVectorPrefix;
  78. if ( wcsVectorSeparator ) _wcsDateVectorSeparator = wcsVectorSeparator;
  79. if ( wcsVectorSuffix ) _wcsDateVectorSuffix = wcsVectorSuffix;
  80. }
  81. void SetNumberVectorFormat( const WCHAR * wcsVectorPrefix,
  82. const WCHAR * wcsVectorSeparator,
  83. const WCHAR * wcsVectorSuffix )
  84. {
  85. if ( wcsVectorPrefix ) _wcsNumberVectorPrefix = wcsVectorPrefix;
  86. if ( wcsVectorSeparator ) _wcsNumberVectorSeparator = wcsVectorSeparator;
  87. if ( wcsVectorSuffix ) _wcsNumberVectorSuffix = wcsVectorSuffix;
  88. }
  89. void SetStringVectorFormat( const WCHAR * wcsVectorPrefix,
  90. const WCHAR * wcsVectorSeparator,
  91. const WCHAR * wcsVectorSuffix )
  92. {
  93. if ( wcsVectorPrefix ) _wcsStringVectorPrefix = wcsVectorPrefix;
  94. if ( wcsVectorSeparator ) _wcsStringVectorSeparator = wcsVectorSeparator;
  95. if ( wcsVectorSuffix ) _wcsStringVectorSuffix = wcsVectorSuffix;
  96. }
  97. const WCHAR * GetBoolVectorPrefix() const { return _wcsBoolVectorPrefix; }
  98. const WCHAR * GetBoolVectorSeparator() const { return _wcsBoolVectorSeparator; }
  99. const WCHAR * GetBoolVectorSuffix() const { return _wcsBoolVectorSuffix; }
  100. const WCHAR * GetCurrencyVectorPrefix() const { return _wcsCurrencyVectorPrefix; }
  101. const WCHAR * GetCurrencyVectorSeparator() const { return _wcsCurrencyVectorSeparator; }
  102. const WCHAR * GetCurrencyVectorSuffix() const { return _wcsCurrencyVectorSuffix; }
  103. const WCHAR * GetDateVectorPrefix() const { return _wcsDateVectorPrefix; }
  104. const WCHAR * GetDateVectorSeparator() const { return _wcsDateVectorSeparator; }
  105. const WCHAR * GetDateVectorSuffix() const { return _wcsDateVectorSuffix; }
  106. const WCHAR * GetNumberVectorPrefix() const { return _wcsNumberVectorPrefix; }
  107. const WCHAR * GetNumberVectorSeparator() const { return _wcsNumberVectorSeparator; }
  108. const WCHAR * GetNumberVectorSuffix() const { return _wcsNumberVectorSuffix; }
  109. const WCHAR * GetStringVectorPrefix() const { return _wcsStringVectorPrefix; }
  110. const WCHAR * GetStringVectorSeparator() const { return _wcsStringVectorSeparator; }
  111. const WCHAR * GetStringVectorSuffix() const { return _wcsStringVectorSuffix; }
  112. private:
  113. int GetIntegerFormat( WCHAR * const wcsInput,
  114. WCHAR * wcsNumber,
  115. ULONG cwcNumber );
  116. NUMBERFMT _numberFormat; // Number format for the locale
  117. CURRENCYFMT _currencyFormat; // Currency format for the locale
  118. const WCHAR * _wcsBoolVectorPrefix; // Prefix for vectors of bools
  119. const WCHAR * _wcsBoolVectorSeparator; // Separator for vectors of bools
  120. const WCHAR * _wcsBoolVectorSuffix; // Suffix for vectors or bools
  121. const WCHAR * _wcsCurrencyVectorPrefix; // Prefix for vectors of currency
  122. const WCHAR * _wcsCurrencyVectorSeparator;// Separator for vectors of currency
  123. const WCHAR * _wcsCurrencyVectorSuffix; // Suffix for vectors or currency
  124. const WCHAR * _wcsDateVectorPrefix; // Prefix for vectors of strings
  125. const WCHAR * _wcsDateVectorSeparator;// Separator for vectors of string
  126. const WCHAR * _wcsDateVectorSuffix; // Suffix for vectors or strings
  127. const WCHAR * _wcsNumberVectorPrefix; // Prefix for vectors of numbers
  128. const WCHAR * _wcsNumberVectorSeparator;// Separator for vectors of numbers
  129. const WCHAR * _wcsNumberVectorSuffix; // Suffix for vectors or numbers
  130. const WCHAR * _wcsStringVectorPrefix; // Prefix for vectors of strings
  131. const WCHAR * _wcsStringVectorSeparator;// Separator for vectors of string
  132. const WCHAR * _wcsStringVectorSuffix; // Suffix for vectors or strings
  133. };