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.

292 lines
6.7 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. _LOCSTR.INL
  5. History:
  6. --*/
  7. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. //
  9. // Swaps two elements of the translation array.
  10. //
  11. //-----------------------------------------------------------------------------
  12. inline
  13. void
  14. CLocTranslationArray::SwapElements(
  15. UINT iOne, // First index to swap
  16. UINT iTwo) // Second index to swap
  17. {
  18. CLocTranslation Temp;
  19. LTASSERT(iOne <= (UINT)GetSize());
  20. LTASSERT(iTwo <= (UINT)GetSize());
  21. Temp = (*this)[iOne];
  22. (*this)[iOne] = (*this)[iTwo];
  23. (*this)[iTwo] = Temp;
  24. }
  25. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26. //
  27. // Assignment operator for cracked strings.
  28. //
  29. //-----------------------------------------------------------------------------
  30. inline
  31. const CLocCrackedString &
  32. CLocCrackedString::operator=(
  33. const CLocCrackedString &csSource)
  34. {
  35. m_pstrBaseString = csSource.m_pstrBaseString;
  36. m_pstrExtension = csSource.m_pstrExtension;
  37. m_pstrControl = csSource.m_pstrControl;
  38. m_cControlLeader = csSource.m_cControlLeader;
  39. m_cHotKeyChar = csSource.m_cHotKeyChar;
  40. m_uiHotKeyPos = csSource.m_uiHotKeyPos;
  41. return *this;
  42. }
  43. //-----------------------------------------------------------------------------
  44. //
  45. // Implementation for comparing two cracked strings. Language ID and
  46. // string type are NOT significant!
  47. //
  48. //-----------------------------------------------------------------------------
  49. inline
  50. BOOL
  51. CLocCrackedString::Compare(
  52. const CLocCrackedString &csOther)
  53. const
  54. {
  55. return ((m_uiHotKeyPos == csOther.m_uiHotKeyPos) &&
  56. (m_cHotKeyChar == csOther.m_cHotKeyChar) &&
  57. (m_pstrControl == csOther.m_pstrControl) &&
  58. (m_cControlLeader == csOther.m_cControlLeader) &&
  59. (m_pstrExtension == csOther.m_pstrExtension) &&
  60. (m_pstrBaseString == csOther.m_pstrBaseString));
  61. }
  62. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  63. //
  64. // Comparision operator.
  65. //
  66. //-----------------------------------------------------------------------------
  67. inline
  68. int
  69. CLocCrackedString::operator==(
  70. const CLocCrackedString &csOther)
  71. const
  72. {
  73. return Compare(csOther);
  74. }
  75. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  76. //
  77. // Comparision operator.
  78. //
  79. //-----------------------------------------------------------------------------
  80. inline
  81. int
  82. CLocCrackedString::operator!=(
  83. const CLocCrackedString &csOther)
  84. const
  85. {
  86. return !Compare(csOther);
  87. }
  88. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  89. //
  90. // Tests to see if the Cracked string has an 'extension'. The extension
  91. // is a sequence of characters ("...", ">>", stc) that indicates that this
  92. // item leads to another UI element.
  93. //
  94. //-----------------------------------------------------------------------------
  95. inline
  96. BOOL // TRUE if the extension is non-null.
  97. CLocCrackedString::HasExtension(void)
  98. const
  99. {
  100. return m_pstrExtension.GetStringLength() != 0;
  101. }
  102. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  103. //
  104. // Tests to see if the cracked string has a 'control' sequence. This is
  105. // usually text describing a shortcut key that invokes the same action as this
  106. // item, for example "Ctrl + F".
  107. //
  108. //-----------------------------------------------------------------------------
  109. inline
  110. BOOL // TRUE if the control seq. is non-null
  111. CLocCrackedString::HasControl(void)
  112. const
  113. {
  114. return m_pstrControl.GetStringLength() != 0;
  115. }
  116. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  117. //
  118. // Check to see if the cracked string has a hot-key. This come directly out
  119. // of the CLocString that was parsed into the Cracked String.
  120. //
  121. //-----------------------------------------------------------------------------
  122. inline
  123. BOOL // TRUE if the string has a hot-key.
  124. CLocCrackedString::HasHotKey(void)
  125. const
  126. {
  127. return (m_cHotKeyChar != 0);
  128. }
  129. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  130. //
  131. // Returns the 'base string'. This is the original string stripped of
  132. // extension and control sequences, and of the hot-key.
  133. //
  134. //-----------------------------------------------------------------------------
  135. inline
  136. const CPascalString & // Base string.
  137. CLocCrackedString::GetBaseString(void)
  138. const
  139. {
  140. return m_pstrBaseString;
  141. }
  142. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  143. //
  144. // Returns the extension component of the string.
  145. //
  146. //-----------------------------------------------------------------------------
  147. inline
  148. const CPascalString &
  149. CLocCrackedString::GetExtension(void)
  150. const
  151. {
  152. return m_pstrExtension;
  153. }
  154. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  155. //
  156. // Returns the constol sequence of the string.
  157. //
  158. //-----------------------------------------------------------------------------
  159. inline
  160. const CPascalString &
  161. CLocCrackedString::GetControl(void)
  162. const
  163. {
  164. return m_pstrControl;
  165. }
  166. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  167. //
  168. // Returns the hot-key character for the string.
  169. //
  170. //-----------------------------------------------------------------------------
  171. inline
  172. WCHAR
  173. CLocCrackedString::GetHotKeyChar(void)
  174. const
  175. {
  176. LTASSERT(HasHotKey());
  177. return m_cHotKeyChar;
  178. }
  179. inline
  180. UINT
  181. CLocCrackedString::GetHotKeyPos(void)
  182. const
  183. {
  184. LTASSERT(HasHotKey());
  185. return m_uiHotKeyPos;
  186. }
  187. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  188. //
  189. // Returns the string type for the string.
  190. //
  191. //-----------------------------------------------------------------------------
  192. inline
  193. CST::StringType
  194. CLocCrackedString::GetStringType(void)
  195. const
  196. {
  197. return m_stStringType;
  198. }
  199. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  200. //
  201. // Cleans out all the components of the cracked string.
  202. //
  203. //-----------------------------------------------------------------------------
  204. inline
  205. void
  206. CLocCrackedString::ClearCrackedString(void)
  207. {
  208. m_pstrBaseString.ClearString();
  209. m_pstrExtension.ClearString();
  210. m_pstrControl.ClearString();
  211. m_cControlLeader = L'\0';
  212. m_cHotKeyChar = L'\0';
  213. m_uiHotKeyPos = 0;
  214. m_stStringType = CST::None;
  215. }
  216. inline
  217. void
  218. CLocCrackedString::SetBaseString(
  219. const CPascalString &pasBase)
  220. {
  221. m_pstrBaseString = pasBase;
  222. }
  223. inline
  224. void
  225. CLocCrackedString::SetHotKey(
  226. WCHAR cHotKeyChar,
  227. UINT uiHotKeyPos)
  228. {
  229. m_cHotKeyChar = cHotKeyChar;
  230. m_uiHotKeyPos = uiHotKeyPos;
  231. }