Source code of Windows XP (NT5)
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.

142 lines
3.4 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1995 - 1997 **/
  4. /**********************************************************************/
  5. /*
  6. FILE HISTORY:
  7. */
  8. #ifndef _INTLNUM_H_
  9. #define _INTLNUM_H_
  10. class CIntlNumber : public CObjectPlus
  11. {
  12. public:
  13. CIntlNumber()
  14. {
  15. m_lValue = 0L;
  16. m_fInitOk = TRUE;
  17. }
  18. CIntlNumber(LONG lValue)
  19. {
  20. m_lValue = lValue;
  21. m_fInitOk = TRUE;
  22. }
  23. CIntlNumber(const CString & str);
  24. CIntlNumber(CIntlNumber const &x)
  25. {
  26. m_lValue = x.m_lValue;
  27. m_fInitOk = x.m_fInitOk;
  28. }
  29. CIntlNumber& operator =(CIntlNumber const &x)
  30. {
  31. m_lValue = x.m_lValue;
  32. m_fInitOk = x.m_fInitOk;
  33. return(*this);
  34. }
  35. public:
  36. // Assignment Operators
  37. CIntlNumber& operator =(LONG l);
  38. CIntlNumber& operator =(const CString &str);
  39. // Shorthand operators.
  40. CIntlNumber& operator +=(const CIntlNumber& num);
  41. CIntlNumber& operator +=(const LONG l);
  42. CIntlNumber& operator -=(const CIntlNumber& num);
  43. CIntlNumber& operator -=(const LONG l);
  44. CIntlNumber& operator /=(const CIntlNumber& num);
  45. CIntlNumber& operator /=(const LONG l);
  46. CIntlNumber& operator *=(const CIntlNumber& num);
  47. CIntlNumber& operator *=(const LONG l);
  48. // Conversion operators
  49. operator const LONG() const
  50. {
  51. return(m_lValue);
  52. }
  53. operator const CString() const;
  54. public:
  55. virtual BOOL IsValid() const
  56. {
  57. return(m_fInitOk);
  58. }
  59. public:
  60. static void Reset();
  61. static void SetBadNumber(CString strBadNumber = "--")
  62. {
  63. m_strBadNumber = strBadNumber;
  64. }
  65. static CString ConvertNumberToString(const LONG l);
  66. static LONG ConvertStringToNumber(const CString & str, BOOL * pfOk);
  67. static CString& GetBadNumber()
  68. {
  69. return(m_strBadNumber);
  70. }
  71. private:
  72. static CString GetThousandSeperator();
  73. private:
  74. static CString m_strThousandSeperator;
  75. static CString m_strBadNumber;
  76. private:
  77. LONG m_lValue;
  78. BOOL m_fInitOk;
  79. public:
  80. #ifdef _DEBUG
  81. friend CDumpContext& AFXAPI operator<<(CDumpContext& dc, const CIntlNumber& num);
  82. #endif // _DEBUG
  83. friend CArchive& AFXAPI operator<<(CArchive& ar, const CIntlNumber& num);
  84. friend CArchive& AFXAPI operator>>(CArchive& ar, CIntlNumber& num);
  85. };
  86. class CIntlLargeNumber : public CObjectPlus
  87. {
  88. public:
  89. CIntlLargeNumber()
  90. {
  91. m_lLowValue = 0L;
  92. m_lHighValue = 0L;
  93. m_fInitOk = TRUE;
  94. }
  95. CIntlLargeNumber(LONG lHighWord, LONG lLowWord)
  96. {
  97. m_lLowValue = lLowWord;
  98. m_lHighValue = lHighWord;
  99. m_fInitOk = TRUE;
  100. }
  101. CIntlLargeNumber(const CString & str);
  102. public:
  103. // Assignment Operators
  104. CIntlLargeNumber& operator =(const CString &str);
  105. operator const CString() { return ConvertNumberToString(); }
  106. operator CString() { return ConvertNumberToString(); }
  107. public:
  108. virtual LONG GetLowWord() const { return m_lLowValue; }
  109. virtual LONG GetHighWord() const { return m_lHighValue; }
  110. virtual BOOL IsValid() const { return(m_fInitOk); }
  111. private:
  112. static CString m_strBadNumber;
  113. CString ConvertNumberToString();
  114. void ConvertStringToNumber(const CString & str, BOOL * pfOk);
  115. private:
  116. LONG m_lLowValue;
  117. LONG m_lHighValue;
  118. BOOL m_fInitOk;
  119. };
  120. #endif _INTLNUM_H