| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- // This is a part of the Microsoft Foundation Classes C++ library.
- // Copyright (C) 1992-1998 Microsoft Corporation
- // All rights reserved.
- //
- // This source code is only intended as a supplement to the
- // Microsoft Foundation Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding the
- // Microsoft Foundation Classes product.
- // Inlines for AFX.H
- #ifdef _AFX_INLINE
- // CObject
- _AFX_INLINE CObject::CObject()
- { }
- _AFX_INLINE CObject::~CObject()
- { }
- // exceptions
- _AFX_INLINE CException::~CException()
- { }
- _AFX_INLINE CFileException::CFileException(int cause, LONG lOsError,
- LPCTSTR pstrFileName /* = NULL */)
- { m_cause = cause; m_lOsError = lOsError; m_strFileName = pstrFileName; }
- _AFX_INLINE CFileException::~CFileException()
- { }
- // CString
- _AFX_INLINE CStringData* CString::GetData() const
- { ASSERT(m_pchData != NULL); return ((CStringData*)m_pchData)-1; }
- _AFX_INLINE void CString::Init()
- { m_pchData = afxEmptyString.m_pchData; }
- _AFX_INLINE CString::CString()
- { m_pchData = afxEmptyString.m_pchData; }
- _AFX_INLINE CString::CString(const unsigned char* lpsz)
- { Init(); *this = (LPCSTR)lpsz; }
- _AFX_INLINE const CString& CString::operator=(const unsigned char* lpsz)
- { *this = (LPCSTR)lpsz; return *this; }
- _AFX_INLINE const CString& CString::operator+=(char ch)
- { *this += (TCHAR)ch; return *this; }
- _AFX_INLINE const CString& CString::operator=(char ch)
- { *this = (TCHAR)ch; return *this; }
- _AFX_INLINE CString AFXAPI operator+(const CString& string, char ch)
- { return string + (TCHAR)ch; }
- _AFX_INLINE CString AFXAPI operator+(char ch, const CString& string)
- { return (TCHAR)ch + string; }
- _AFX_INLINE int CString::GetLength() const
- { return GetData()->nDataLength; }
- _AFX_INLINE int CString::GetAllocLength() const
- { return GetData()->nAllocLength; }
- _AFX_INLINE BOOL CString::IsEmpty() const
- { return GetData()->nDataLength == 0; }
- _AFX_INLINE CString::operator LPCTSTR() const
- { return m_pchData; }
- _AFX_INLINE int PASCAL CString::SafeStrlen(LPCTSTR lpsz)
- { return (lpsz == NULL) ? 0 : lstrlen(lpsz); }
- // CString support (windows specific)
- _AFX_INLINE int CString::Compare(LPCTSTR lpsz) const
- { ASSERT(AfxIsValidString(lpsz)); return _tcscmp(m_pchData, lpsz); } // MBCS/Unicode aware
- _AFX_INLINE int CString::CompareNoCase(LPCTSTR lpsz) const
- { ASSERT(AfxIsValidString(lpsz)); return _tcsicmp(m_pchData, lpsz); } // MBCS/Unicode aware
- _AFX_INLINE TCHAR CString::GetAt(int nIndex) const
- {
- ASSERT(nIndex >= 0);
- ASSERT(nIndex < GetData()->nDataLength);
- return m_pchData[nIndex];
- }
- _AFX_INLINE TCHAR CString::operator[](int nIndex) const
- {
- // same as GetAt
- ASSERT(nIndex >= 0);
- ASSERT(nIndex < GetData()->nDataLength);
- return m_pchData[nIndex];
- }
- _AFX_INLINE bool AFXAPI operator==(const CString& s1, const CString& s2)
- { return s1.Compare(s2) == 0; }
- _AFX_INLINE bool AFXAPI operator==(const CString& s1, LPCTSTR s2)
- { return s1.Compare(s2) == 0; }
- _AFX_INLINE bool AFXAPI operator==(LPCTSTR s1, const CString& s2)
- { return s2.Compare(s1) == 0; }
- _AFX_INLINE bool AFXAPI operator!=(const CString& s1, const CString& s2)
- { return s1.Compare(s2) != 0; }
- _AFX_INLINE bool AFXAPI operator!=(const CString& s1, LPCTSTR s2)
- { return s1.Compare(s2) != 0; }
- _AFX_INLINE bool AFXAPI operator!=(LPCTSTR s1, const CString& s2)
- { return s2.Compare(s1) != 0; }
- _AFX_INLINE bool AFXAPI operator<(const CString& s1, const CString& s2)
- { return s1.Compare(s2) < 0; }
- _AFX_INLINE bool AFXAPI operator<(const CString& s1, LPCTSTR s2)
- { return s1.Compare(s2) < 0; }
- _AFX_INLINE bool AFXAPI operator<(LPCTSTR s1, const CString& s2)
- { return s2.Compare(s1) > 0; }
- // CTime and CTimeSpan
- _AFX_INLINE CTimeSpan::CTimeSpan(time_t time)
- { m_timeSpan = time; }
- _AFX_INLINE CTimeSpan::CTimeSpan(const CTimeSpan& timeSpanSrc)
- { m_timeSpan = timeSpanSrc.m_timeSpan; }
- _AFX_INLINE const CTimeSpan& CTimeSpan::operator=(const CTimeSpan& timeSpanSrc)
- { m_timeSpan = timeSpanSrc.m_timeSpan; return *this; }
- _AFX_INLINE LONG CTimeSpan::GetTotalSeconds() const
- { return m_timeSpan; }
- _AFX_INLINE BOOL CTimeSpan::operator==(CTimeSpan timeSpan) const
- { return m_timeSpan == timeSpan.m_timeSpan; }
- _AFX_INLINE BOOL CTimeSpan::operator!=(CTimeSpan timeSpan) const
- { return m_timeSpan != timeSpan.m_timeSpan; }
- _AFX_INLINE CTime::CTime()
- { }
- _AFX_INLINE CTime::CTime(time_t time)
- { m_time = time; }
- _AFX_INLINE CTime::CTime(const CTime& timeSrc)
- { m_time = timeSrc.m_time; }
- _AFX_INLINE const CTime& CTime::operator=(const CTime& timeSrc)
- { m_time = timeSrc.m_time; return *this; }
- _AFX_INLINE const CTime& CTime::operator=(time_t t)
- { m_time = t; return *this; }
- _AFX_INLINE time_t CTime::GetTime() const
- { return m_time; }
- _AFX_INLINE int CTime::GetYear() const
- { return (GetLocalTm(NULL)->tm_year) + 1900; }
- _AFX_INLINE int CTime::GetMonth() const
- { return GetLocalTm(NULL)->tm_mon + 1; }
- _AFX_INLINE int CTime::GetDay() const
- { return GetLocalTm(NULL)->tm_mday; }
- _AFX_INLINE int CTime::GetHour() const
- { return GetLocalTm(NULL)->tm_hour; }
- _AFX_INLINE int CTime::GetMinute() const
- { return GetLocalTm(NULL)->tm_min; }
- _AFX_INLINE CTimeSpan CTime::operator-(CTime time) const
- { return CTimeSpan(m_time - time.m_time); }
- _AFX_INLINE BOOL CTime::operator==(CTime time) const
- { return m_time == time.m_time; }
- _AFX_INLINE BOOL CTime::operator!=(CTime time) const
- { return m_time != time.m_time; }
- /////////////////////////////////////////////////////////////////////////////
- #endif //_AFX_INLINE
|