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.

283 lines
5.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: locvar.inl
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // Inline functions for the variant class. This should ONLY be included from
  8. // locvar.h
  9. //
  10. //-----------------------------------------------------------------------------
  11. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12. //
  13. // Default constructor. Sets the variant type to none ie no value is in
  14. // the variant.
  15. //
  16. //-----------------------------------------------------------------------------
  17. inline
  18. CLocVariant::CLocVariant()
  19. {
  20. m_VarType = lvtNone;
  21. }
  22. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  23. //
  24. // Returns the type of the data in the variant.
  25. //
  26. //-----------------------------------------------------------------------------
  27. inline
  28. LocVariantType
  29. CLocVariant::GetVariantType(void)
  30. const
  31. {
  32. return m_VarType;
  33. }
  34. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  35. //
  36. // Returns the integer data in the variant. The data must have been set
  37. // previously as an integer.
  38. //
  39. //-----------------------------------------------------------------------------
  40. inline
  41. DWORD
  42. CLocVariant::GetDword(void)
  43. const
  44. {
  45. LTASSERT(m_VarType == lvtInteger || m_VarType == lvtStringList);
  46. if (m_VarType == lvtInteger)
  47. {
  48. return m_dwInteger;
  49. }
  50. else
  51. {
  52. return m_StringList.GetIndex();
  53. }
  54. }
  55. inline
  56. BOOL
  57. CLocVariant::GetBOOL(void)
  58. const
  59. {
  60. LTASSERT(m_VarType == lvtBOOL);
  61. return m_fBOOL;
  62. }
  63. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  64. //
  65. // Returns the string data in the variant. The data must have been set
  66. // previously as an string.
  67. //
  68. //-----------------------------------------------------------------------------
  69. inline
  70. const CPascalString &
  71. CLocVariant::GetString(void)
  72. const
  73. {
  74. LTASSERT(m_VarType == lvtString || m_VarType == lvtFileName);
  75. return m_psString;
  76. }
  77. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  78. //
  79. // Returns the dual string/integer data in the variant. The data must have
  80. // been set previously as an dual string/integer.
  81. //
  82. //-----------------------------------------------------------------------------
  83. inline
  84. const CLocId &
  85. CLocVariant::GetIntPlusString(void)
  86. const
  87. {
  88. LTASSERT(m_VarType == lvtIntPlusString);
  89. return m_IntPlusString;
  90. }
  91. inline
  92. const CLocCOWBlob &
  93. CLocVariant::GetBlob(void)
  94. const
  95. {
  96. LTASSERT(m_VarType == lvtBlob);
  97. return m_Blob;
  98. }
  99. inline
  100. const CPasStringList &
  101. CLocVariant::GetStringList(void)
  102. const
  103. {
  104. LTASSERT(m_VarType == lvtStringList);
  105. return m_StringList;
  106. }
  107. inline
  108. const CLString &
  109. CLocVariant::GetFileExtensions(void)
  110. const
  111. {
  112. LTASSERT(m_VarType == lvtFileName);
  113. return m_strFileExtensions;
  114. }
  115. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  116. //
  117. // Comparison operator.
  118. //
  119. //-----------------------------------------------------------------------------
  120. inline
  121. int
  122. CLocVariant::operator==(
  123. const CLocVariant &lvOther)
  124. const
  125. {
  126. return IsEqualTo(lvOther);
  127. }
  128. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  129. //
  130. // Comparison operator.
  131. //
  132. //-----------------------------------------------------------------------------
  133. inline
  134. int
  135. CLocVariant::operator!=(
  136. const CLocVariant &lvOther)
  137. const
  138. {
  139. return !IsEqualTo(lvOther);
  140. }
  141. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  142. //
  143. // Sets the variant to an integer value.
  144. //
  145. //-----------------------------------------------------------------------------
  146. inline
  147. void
  148. CLocVariant::SetDword(
  149. const DWORD dwNewValue)
  150. {
  151. m_VarType = lvtInteger;
  152. m_dwInteger = dwNewValue;
  153. }
  154. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  155. //
  156. // TODO - comment this function
  157. //
  158. //-----------------------------------------------------------------------------
  159. inline
  160. void
  161. CLocVariant::SetBOOL(
  162. const BOOL fNewValue)
  163. {
  164. m_VarType = lvtBOOL;
  165. m_fBOOL = fNewValue;
  166. }
  167. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  168. //
  169. // Sets the variant to a CPascalString value.
  170. //
  171. //-----------------------------------------------------------------------------
  172. inline
  173. void
  174. CLocVariant::SetString(
  175. const CPascalString &psNewValue)
  176. {
  177. m_VarType = lvtString;
  178. m_psString = psNewValue;
  179. }
  180. inline
  181. void
  182. CLocVariant::SetFileName(
  183. const CPascalString &psNewValue,
  184. const CLString & strExtensions)
  185. {
  186. m_VarType = lvtFileName;
  187. m_psString = psNewValue;
  188. m_strFileExtensions = strExtensions;
  189. }
  190. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  191. //
  192. // Sets the variant to a dual string/integer value.
  193. //
  194. //-----------------------------------------------------------------------------
  195. inline
  196. void
  197. CLocVariant::SetIntPlusString(
  198. const CLocId &NewIntPlusString)
  199. {
  200. m_VarType = lvtIntPlusString;
  201. m_IntPlusString = NewIntPlusString;
  202. }
  203. inline
  204. void
  205. CLocVariant::SetBlob(
  206. const CLocCOWBlob &blbNewValue)
  207. {
  208. m_VarType = lvtBlob;
  209. m_Blob = blbNewValue;
  210. }
  211. inline
  212. void
  213. CLocVariant::SetStringList(
  214. const CPasStringList &slNewValue)
  215. {
  216. m_VarType = lvtStringList;
  217. m_StringList = slNewValue;
  218. }