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.

312 lines
13 KiB

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1993 Microsoft Corporation,
  3. // All rights reserved.
  4. // This source code is only intended as a supplement to the
  5. // Microsoft Foundation Classes Reference and Microsoft
  6. // QuickHelp and/or WinHelp documentation provided with the library.
  7. // See these sources for detailed information regarding the
  8. // Microsoft Foundation Classes product.
  9. // Inlines for AFX.H
  10. #ifdef _AFX_INLINE
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CObject
  13. _AFX_INLINE CObject::CObject()
  14. { }
  15. _AFX_INLINE CObject::~CObject()
  16. { }
  17. _AFX_INLINE void* CObject::operator new(size_t, void* p)
  18. { return p; }
  19. #ifndef _DEBUG
  20. // _DEBUG versions in memory.cpp
  21. _AFX_INLINE void CObject::operator delete(void* p)
  22. { ::operator delete(p); }
  23. _AFX_INLINE void* CObject::operator new(size_t nSize)
  24. { return ::operator new(nSize); }
  25. #endif
  26. // exceptions
  27. _AFX_INLINE CMemoryException::CMemoryException()
  28. { }
  29. _AFX_INLINE CNotSupportedException::CNotSupportedException()
  30. { }
  31. _AFX_INLINE CArchiveException::CArchiveException(int cause /* = CArchiveException::none */)
  32. { m_cause = cause; }
  33. _AFX_INLINE CFileException::CFileException(int cause /* = CFileException::none */, LONG lOsError /* = -1 */)
  34. { m_cause = cause; m_lOsError = lOsError; }
  35. // CFile
  36. _AFX_INLINE DWORD CFile::SeekToEnd()
  37. { return Seek(0, CFile::end); }
  38. _AFX_INLINE void CFile::SeekToBegin()
  39. { Seek(0, CFile::begin); }
  40. // CString
  41. _AFX_INLINE int CString::GetLength() const
  42. { return m_nDataLength; }
  43. _AFX_INLINE int CString::GetAllocLength() const
  44. { return m_nAllocLength; }
  45. _AFX_INLINE BOOL CString::IsEmpty() const
  46. { return m_nDataLength == 0; }
  47. _AFX_INLINE CString::operator const char*() const
  48. { return (const char*)m_pchData; }
  49. _AFX_INLINE int CString::SafeStrlen(const char* psz)
  50. { return (psz == NULL) ? NULL : strlen(psz); }
  51. #ifndef _WINDOWS
  52. _AFX_INLINE int CString::Compare(const char* psz) const
  53. { return strcmp(m_pchData, psz); }
  54. _AFX_INLINE int CString::CompareNoCase(const char* psz) const
  55. { return _stricmp(m_pchData, psz); }
  56. _AFX_INLINE int CString::Collate(const char* psz) const
  57. { return strcoll(m_pchData, psz); }
  58. _AFX_INLINE void CString::MakeUpper()
  59. { _strupr(m_pchData); }
  60. _AFX_INLINE void CString::MakeLower()
  61. { _strlwr(m_pchData); }
  62. // Windows version in AFXWIN.H
  63. #endif //!_WINDOWS
  64. _AFX_INLINE void CString::MakeReverse()
  65. { _strrev(m_pchData); }
  66. _AFX_INLINE char CString::GetAt(int nIndex) const
  67. {
  68. ASSERT(nIndex >= 0);
  69. ASSERT(nIndex < m_nDataLength);
  70. return m_pchData[nIndex];
  71. }
  72. _AFX_INLINE char CString::operator[](int nIndex) const
  73. {
  74. // same as GetAt
  75. ASSERT(nIndex >= 0);
  76. ASSERT(nIndex < m_nDataLength);
  77. return m_pchData[nIndex];
  78. }
  79. _AFX_INLINE void CString::SetAt(int nIndex, char ch)
  80. {
  81. ASSERT(nIndex >= 0);
  82. ASSERT(nIndex < m_nDataLength);
  83. ASSERT(ch != 0);
  84. m_pchData[nIndex] = ch;
  85. }
  86. _AFX_INLINE BOOL AFXAPI operator==(const CString& s1, const CString& s2)
  87. { return s1.Compare(s2) == 0; }
  88. _AFX_INLINE BOOL AFXAPI operator==(const CString& s1, const char* s2)
  89. { return s1.Compare(s2) == 0; }
  90. _AFX_INLINE BOOL AFXAPI operator==(const char* s1, const CString& s2)
  91. { return s2.Compare(s1) == 0; }
  92. _AFX_INLINE BOOL AFXAPI operator!=(const CString& s1, const CString& s2)
  93. { return s1.Compare(s2) != 0; }
  94. _AFX_INLINE BOOL AFXAPI operator!=(const CString& s1, const char* s2)
  95. { return s1.Compare(s2) != 0; }
  96. _AFX_INLINE BOOL AFXAPI operator!=(const char* s1, const CString& s2)
  97. { return s2.Compare(s1) != 0; }
  98. _AFX_INLINE BOOL AFXAPI operator<(const CString& s1, const CString& s2)
  99. { return s1.Compare(s2) < 0; }
  100. _AFX_INLINE BOOL AFXAPI operator<(const CString& s1, const char* s2)
  101. { return s1.Compare(s2) < 0; }
  102. _AFX_INLINE BOOL AFXAPI operator<(const char* s1, const CString& s2)
  103. { return s2.Compare(s1) > 0; }
  104. _AFX_INLINE BOOL AFXAPI operator>(const CString& s1, const CString& s2)
  105. { return s1.Compare(s2) > 0; }
  106. _AFX_INLINE BOOL AFXAPI operator>(const CString& s1, const char* s2)
  107. { return s1.Compare(s2) > 0; }
  108. _AFX_INLINE BOOL AFXAPI operator>(const char* s1, const CString& s2)
  109. { return s2.Compare(s1) < 0; }
  110. _AFX_INLINE BOOL AFXAPI operator<=(const CString& s1, const CString& s2)
  111. { return s1.Compare(s2) <= 0; }
  112. _AFX_INLINE BOOL AFXAPI operator<=(const CString& s1, const char* s2)
  113. { return s1.Compare(s2) <= 0; }
  114. _AFX_INLINE BOOL AFXAPI operator<=(const char* s1, const CString& s2)
  115. { return s2.Compare(s1) >= 0; }
  116. _AFX_INLINE BOOL AFXAPI operator>=(const CString& s1, const CString& s2)
  117. { return s1.Compare(s2) >= 0; }
  118. _AFX_INLINE BOOL AFXAPI operator>=(const CString& s1, const char* s2)
  119. { return s1.Compare(s2) >= 0; }
  120. _AFX_INLINE BOOL AFXAPI operator>=(const char* s1, const CString& s2)
  121. { return s2.Compare(s1) <= 0; }
  122. // CTime and CTimeSpan
  123. _AFX_INLINE CTimeSpan::CTimeSpan()
  124. { }
  125. _AFX_INLINE CTimeSpan::CTimeSpan(time_t time)
  126. { m_timeSpan = time; }
  127. _AFX_INLINE CTimeSpan::CTimeSpan(LONG lDays, int nHours, int nMins, int nSecs)
  128. { m_timeSpan = nSecs + 60* (nMins + 60* (nHours + 24* lDays)); }
  129. _AFX_INLINE CTimeSpan::CTimeSpan(const CTimeSpan& timeSpanSrc)
  130. { m_timeSpan = timeSpanSrc.m_timeSpan; }
  131. _AFX_INLINE const CTimeSpan& CTimeSpan::operator=(const CTimeSpan& timeSpanSrc)
  132. { m_timeSpan = timeSpanSrc.m_timeSpan; return *this; }
  133. _AFX_INLINE LONG CTimeSpan::GetDays() const
  134. { return m_timeSpan / (24*3600L); }
  135. _AFX_INLINE LONG CTimeSpan::GetTotalHours() const
  136. { return m_timeSpan/3600; }
  137. _AFX_INLINE int CTimeSpan::GetHours() const
  138. { return (int)(GetTotalHours() - GetDays()*24); }
  139. _AFX_INLINE LONG CTimeSpan::GetTotalMinutes() const
  140. { return m_timeSpan/60; }
  141. _AFX_INLINE int CTimeSpan::GetMinutes() const
  142. { return (int)(GetTotalMinutes() - GetTotalHours()*60); }
  143. _AFX_INLINE LONG CTimeSpan::GetTotalSeconds() const
  144. { return m_timeSpan; }
  145. _AFX_INLINE int CTimeSpan::GetSeconds() const
  146. { return (int)(GetTotalSeconds() - GetTotalMinutes()*60); }
  147. _AFX_INLINE CTimeSpan CTimeSpan::operator-(CTimeSpan timeSpan) const
  148. { return CTimeSpan(m_timeSpan - timeSpan.m_timeSpan); }
  149. _AFX_INLINE CTimeSpan CTimeSpan::operator+(CTimeSpan timeSpan) const
  150. { return CTimeSpan(m_timeSpan + timeSpan.m_timeSpan); }
  151. _AFX_INLINE const CTimeSpan& CTimeSpan::operator+=(CTimeSpan timeSpan)
  152. { m_timeSpan += timeSpan.m_timeSpan; return *this; }
  153. _AFX_INLINE const CTimeSpan& CTimeSpan::operator-=(CTimeSpan timeSpan)
  154. { m_timeSpan -= timeSpan.m_timeSpan; return *this; }
  155. _AFX_INLINE BOOL CTimeSpan::operator==(CTimeSpan timeSpan) const
  156. { return m_timeSpan == timeSpan.m_timeSpan; }
  157. _AFX_INLINE BOOL CTimeSpan::operator!=(CTimeSpan timeSpan) const
  158. { return m_timeSpan != timeSpan.m_timeSpan; }
  159. _AFX_INLINE BOOL CTimeSpan::operator<(CTimeSpan timeSpan) const
  160. { return m_timeSpan < timeSpan.m_timeSpan; }
  161. _AFX_INLINE BOOL CTimeSpan::operator>(CTimeSpan timeSpan) const
  162. { return m_timeSpan > timeSpan.m_timeSpan; }
  163. _AFX_INLINE BOOL CTimeSpan::operator<=(CTimeSpan timeSpan) const
  164. { return m_timeSpan <= timeSpan.m_timeSpan; }
  165. _AFX_INLINE BOOL CTimeSpan::operator>=(CTimeSpan timeSpan) const
  166. { return m_timeSpan >= timeSpan.m_timeSpan; }
  167. _AFX_INLINE CTime::CTime()
  168. { }
  169. _AFX_INLINE CTime::CTime(time_t time)
  170. { m_time = time; }
  171. _AFX_INLINE CTime::CTime(const CTime& timeSrc)
  172. { m_time = timeSrc.m_time; }
  173. _AFX_INLINE const CTime& CTime::operator=(const CTime& timeSrc)
  174. { m_time = timeSrc.m_time; return *this; }
  175. _AFX_INLINE const CTime& CTime::operator=(time_t t)
  176. { m_time = t; return *this; }
  177. _AFX_INLINE time_t CTime::GetTime() const
  178. { return m_time; }
  179. _AFX_INLINE int CTime::GetYear() const
  180. { return (GetLocalTm(NULL)->tm_year) + 1900; }
  181. _AFX_INLINE int CTime::GetMonth() const
  182. { return GetLocalTm(NULL)->tm_mon + 1; }
  183. _AFX_INLINE int CTime::GetDay() const
  184. { return GetLocalTm(NULL)->tm_mday; }
  185. _AFX_INLINE int CTime::GetHour() const
  186. { return GetLocalTm(NULL)->tm_hour; }
  187. _AFX_INLINE int CTime::GetMinute() const
  188. { return GetLocalTm(NULL)->tm_min; }
  189. _AFX_INLINE int CTime::GetSecond() const
  190. { return GetLocalTm(NULL)->tm_sec; }
  191. _AFX_INLINE int CTime::GetDayOfWeek() const
  192. { return GetLocalTm(NULL)->tm_wday + 1; }
  193. _AFX_INLINE CTimeSpan CTime::operator-(CTime time) const
  194. { return CTimeSpan(m_time - time.m_time); }
  195. _AFX_INLINE CTime CTime::operator-(CTimeSpan timeSpan) const
  196. { return CTime(m_time - timeSpan.m_timeSpan); }
  197. _AFX_INLINE CTime CTime::operator+(CTimeSpan timeSpan) const
  198. { return CTime(m_time + timeSpan.m_timeSpan); }
  199. _AFX_INLINE const CTime& CTime::operator+=(CTimeSpan timeSpan)
  200. { m_time += timeSpan.m_timeSpan; return *this; }
  201. _AFX_INLINE const CTime& CTime::operator-=(CTimeSpan timeSpan)
  202. { m_time -= timeSpan.m_timeSpan; return *this; }
  203. _AFX_INLINE BOOL CTime::operator==(CTime time) const
  204. { return m_time == time.m_time; }
  205. _AFX_INLINE BOOL CTime::operator!=(CTime time) const
  206. { return m_time != time.m_time; }
  207. _AFX_INLINE BOOL CTime::operator<(CTime time) const
  208. { return m_time < time.m_time; }
  209. _AFX_INLINE BOOL CTime::operator>(CTime time) const
  210. { return m_time > time.m_time; }
  211. _AFX_INLINE BOOL CTime::operator<=(CTime time) const
  212. { return m_time <= time.m_time; }
  213. _AFX_INLINE BOOL CTime::operator>=(CTime time) const
  214. { return m_time >= time.m_time; }
  215. // CArchive
  216. _AFX_INLINE BOOL CArchive::IsLoading() const
  217. { return (m_nMode & CArchive::load) != 0; }
  218. _AFX_INLINE BOOL CArchive::IsStoring() const
  219. { return (m_nMode & CArchive::load) == 0; }
  220. _AFX_INLINE BOOL CArchive::IsBufferEmpty() const
  221. { return m_lpBufCur == m_lpBufMax; }
  222. _AFX_INLINE CFile* CArchive::GetFile() const
  223. { return m_pFile; }
  224. _AFX_INLINE CArchive& CArchive::operator<<(BYTE by)
  225. { if (m_lpBufCur + sizeof(BYTE) > m_lpBufMax) Flush();
  226. *(BYTE FAR*)m_lpBufCur = by; m_lpBufCur += sizeof(BYTE); return *this; }
  227. _AFX_INLINE CArchive& CArchive::operator<<(WORD w)
  228. { if (m_lpBufCur + sizeof(WORD) > m_lpBufMax) Flush();
  229. *(WORD FAR*)m_lpBufCur = w; m_lpBufCur += sizeof(WORD); return *this; }
  230. _AFX_INLINE CArchive& CArchive::operator<<(LONG l)
  231. { if (m_lpBufCur + sizeof(LONG) > m_lpBufMax) Flush();
  232. *(LONG FAR*)m_lpBufCur = l; m_lpBufCur += sizeof(LONG); return *this; }
  233. _AFX_INLINE CArchive& CArchive::operator<<(DWORD dw)
  234. { if (m_lpBufCur + sizeof(DWORD) > m_lpBufMax) Flush();
  235. *(DWORD FAR*)m_lpBufCur = dw; m_lpBufCur += sizeof(DWORD); return *this; }
  236. _AFX_INLINE CArchive& CArchive::operator<<(float f)
  237. { if (m_lpBufCur + sizeof(float) > m_lpBufMax) Flush();
  238. *(_AFXFLOAT FAR*)m_lpBufCur = *(_AFXFLOAT FAR*)&f; m_lpBufCur += sizeof(float); return *this; }
  239. _AFX_INLINE CArchive& CArchive::operator<<(double d)
  240. { if (m_lpBufCur + sizeof(double) > m_lpBufMax) Flush();
  241. *(_AFXDOUBLE FAR*)m_lpBufCur = *(_AFXDOUBLE FAR*)&d; m_lpBufCur += sizeof(double); return *this; }
  242. _AFX_INLINE CArchive& CArchive::operator>>(BYTE& by)
  243. { if (m_lpBufCur + sizeof(BYTE) > m_lpBufMax)
  244. FillBuffer(sizeof(BYTE) - (UINT)(m_lpBufMax - m_lpBufCur));
  245. by = *(BYTE FAR*)m_lpBufCur; m_lpBufCur += sizeof(BYTE); return *this; }
  246. _AFX_INLINE CArchive& CArchive::operator>>(WORD& w)
  247. { if (m_lpBufCur + sizeof(WORD) > m_lpBufMax)
  248. FillBuffer(sizeof(WORD) - (UINT)(m_lpBufMax - m_lpBufCur));
  249. w = *(WORD FAR*)m_lpBufCur; m_lpBufCur += sizeof(WORD); return *this; }
  250. _AFX_INLINE CArchive& CArchive::operator>>(DWORD& dw)
  251. { if (m_lpBufCur + sizeof(DWORD) > m_lpBufMax)
  252. FillBuffer(sizeof(DWORD) - (UINT)(m_lpBufMax - m_lpBufCur));
  253. dw = *(DWORD FAR*)m_lpBufCur; m_lpBufCur += sizeof(DWORD); return *this; }
  254. _AFX_INLINE CArchive& CArchive::operator>>(float& f)
  255. { if (m_lpBufCur + sizeof(float) > m_lpBufMax)
  256. FillBuffer(sizeof(float) - (UINT)(m_lpBufMax - m_lpBufCur));
  257. *(_AFXFLOAT FAR*)&f = *(_AFXFLOAT FAR*)m_lpBufCur; m_lpBufCur += sizeof(float); return *this; }
  258. _AFX_INLINE CArchive& CArchive::operator>>(double& d)
  259. { if (m_lpBufCur + sizeof(double) > m_lpBufMax)
  260. FillBuffer(sizeof(double) - (UINT)(m_lpBufMax - m_lpBufCur));
  261. *(_AFXDOUBLE FAR*)&d = *(_AFXDOUBLE FAR*)m_lpBufCur; m_lpBufCur += sizeof(double); return *this; }
  262. _AFX_INLINE CArchive& CArchive::operator>>(LONG& l)
  263. { if (m_lpBufCur + sizeof(LONG) > m_lpBufMax)
  264. FillBuffer(sizeof(LONG) - (UINT)(m_lpBufMax - m_lpBufCur));
  265. l = *(LONG FAR*)m_lpBufCur; m_lpBufCur += sizeof(LONG); return *this; }
  266. _AFX_INLINE CArchive::CArchive(const CArchive& /* arSrc */)
  267. { }
  268. _AFX_INLINE void CArchive::operator=(const CArchive& /* arSrc */)
  269. { }
  270. _AFX_INLINE CArchive& AFXAPI operator<<(CArchive& ar, const CObject* pOb)
  271. { ar.WriteObject(pOb); return ar; }
  272. _AFX_INLINE CArchive& AFXAPI operator>>(CArchive& ar, CObject*& pOb)
  273. { pOb = ar.ReadObject(NULL); return ar; }
  274. _AFX_INLINE CArchive& AFXAPI operator>>(CArchive& ar, const CObject*& pOb)
  275. { pOb = ar.ReadObject(NULL); return ar; }
  276. // CDumpContext
  277. _AFX_INLINE int CDumpContext::GetDepth() const
  278. { return m_nDepth; }
  279. _AFX_INLINE void CDumpContext::SetDepth(int nNewDepth)
  280. { m_nDepth = nNewDepth; }
  281. _AFX_INLINE CDumpContext::CDumpContext(const CDumpContext& /* dcSrc */)
  282. { }
  283. _AFX_INLINE void CDumpContext::operator=(const CDumpContext& /* dcSrc */)
  284. { }
  285. /////////////////////////////////////////////////////////////////////////////
  286. #endif //_AFX_INLINE