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.

205 lines
4.4 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. istraux.cpp
  7. NLS/DBCS-aware string class: secondary methods of index class
  8. This file contains the implementation of the auxiliary methods
  9. for the ISTR class. It is separate so that clients of STRING which
  10. do not use this operator need not link to it.
  11. FILE HISTORY:
  12. beng 01/18/91 Separated from original monolithic .cxx
  13. beng 02/07/91 Uses lmui.hxx
  14. beng 04/26/91 Relocated some funcs from string.hxx
  15. gregj 03/25/93 Ported to Chicago environment
  16. gregj 04/02/93 Use NLS_STR::IsDBCSLeadByte()
  17. */
  18. #include "npcommon.h"
  19. extern "C"
  20. {
  21. #include <netlib.h>
  22. }
  23. #if defined(DEBUG)
  24. static const CHAR szFileName[] = __FILE__;
  25. #define _FILENAME_DEFINED_ONCE szFileName
  26. #endif
  27. #include <npassert.h>
  28. #include <npstring.h>
  29. /*******************************************************************
  30. NAME: ISTR::Reset
  31. SYNOPSIS: Reset the ISTR so the index is 0;
  32. updates the version number of the string.
  33. ENTRY:
  34. EXIT:
  35. NOTES:
  36. HISTORY:
  37. Johnl 11/28/90 Created
  38. ********************************************************************/
  39. VOID ISTR::Reset()
  40. {
  41. _ibString = 0;
  42. #ifdef DEBUG
  43. _usVersion = QueryPNLS()->QueryVersion();
  44. #endif
  45. }
  46. /*******************************************************************
  47. NAME: ISTR::operator-
  48. SYNOPSIS: Returns the difference in CB between the two ISTR
  49. ENTRY:
  50. EXIT:
  51. NOTES:
  52. HISTORY:
  53. Johnl 11/28/90 Created
  54. ********************************************************************/
  55. INT ISTR::operator-( const ISTR& istr2 ) const
  56. {
  57. UIASSERT( QueryPNLS() == istr2.QueryPNLS() );
  58. return ( QueryIB() - istr2.QueryIB() );
  59. }
  60. /*******************************************************************
  61. NAME: ISTR::operator++
  62. SYNOPSIS: Increment the ISTR to the next logical character
  63. ENTRY:
  64. EXIT:
  65. NOTES: Stops if we are at the end of the string
  66. HISTORY:
  67. Johnl 11/28/90 Created
  68. beng 07/23/91 Simplified CheckIstr
  69. ********************************************************************/
  70. ISTR& ISTR::operator++()
  71. {
  72. QueryPNLS()->CheckIstr( *this );
  73. CHAR c = *(QueryPNLS()->QueryPch() + QueryIB());
  74. if ( c != '\0' )
  75. {
  76. SetIB( QueryIB() + (QueryPNLS()->IsDBCSLeadByte(c) ? 2 : 1) );
  77. }
  78. return *this;
  79. }
  80. /*******************************************************************
  81. NAME: ISTR::operator+=
  82. SYNOPSIS: Increment the ISTR to the nth logical character
  83. NOTES: Stops if we are at the end of the string
  84. HISTORY:
  85. Johnl 01/14/90 Created
  86. ********************************************************************/
  87. VOID ISTR::operator+=( INT iChars )
  88. {
  89. while ( iChars-- )
  90. operator++();
  91. }
  92. /*******************************************************************
  93. NAME: ISTR::operator==
  94. SYNOPSIS: Equality operator
  95. RETURNS: TRUE if the two ISTRs are equivalent.
  96. NOTES: Only valid between two ISTRs of the same string.
  97. HISTORY:
  98. beng 07/22/91 Header added
  99. ********************************************************************/
  100. BOOL ISTR::operator==( const ISTR& istr ) const
  101. {
  102. UIASSERT( QueryPNLS() == istr.QueryPNLS() );
  103. return QueryIB() == istr.QueryIB();
  104. }
  105. /*******************************************************************
  106. NAME: ISTR::operator>
  107. SYNOPSIS: Greater-than operator
  108. RETURNS: TRUE if this ISTR points further into the string
  109. than the argument.
  110. NOTES: Only valid between two ISTRs of the same string.
  111. HISTORY:
  112. beng 07/22/91 Header added
  113. ********************************************************************/
  114. BOOL ISTR::operator>( const ISTR& istr ) const
  115. {
  116. UIASSERT( QueryPNLS() == istr.QueryPNLS() );
  117. return QueryIB() > istr.QueryIB();
  118. }
  119. /*******************************************************************
  120. NAME: ISTR::operator<
  121. SYNOPSIS: Lesser-than operator
  122. RETURNS: TRUE if this ISTR points less further into the string
  123. than the argument.
  124. NOTES: Only valid between two ISTRs of the same string.
  125. HISTORY:
  126. beng 07/22/91 Header added
  127. ********************************************************************/
  128. BOOL ISTR::operator<( const ISTR& istr ) const
  129. {
  130. UIASSERT( QueryPNLS() == istr.QueryPNLS() );
  131. return QueryIB() < istr.QueryIB();
  132. }