Author: gedmurphy Date: Wed May 6 21:31:40 2015 New Revision: 67579
URL: http://svn.reactos.org/svn/reactos?rev=67579&view=rev Log: [ATL] Add skeleton support for CAtlStringW
Added: trunk/reactos/lib/atl/atlsimpstr.h (with props) trunk/reactos/lib/atl/atlstr.h (with props) trunk/reactos/lib/atl/cstringt.h (with props)
Added: trunk/reactos/lib/atl/atlsimpstr.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlsimpstr.h?rev=67... ============================================================================== --- trunk/reactos/lib/atl/atlsimpstr.h (added) +++ trunk/reactos/lib/atl/atlsimpstr.h [iso-8859-1] Wed May 6 21:31:40 2015 @@ -0,0 +1,126 @@ +#ifndef __ATLSIMPSTR_H__ +#define __ATLSIMPSTR_H__ + +#pragma once + +#include <atlcore.h> + + +namespace ATL +{ + struct CStringData; + + __interface IAtlStringMgr + { + public: + + _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) + CStringData* Allocate( + _In_ int nAllocLength, + _In_ int nCharSize) throw(); + + void Free(_Inout_ CStringData* pData) throw(); + + virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) + CStringData* Reallocate( + _Inout_ CStringData* pData, + _In_ int nAllocLength, + _In_ int nCharSize) throw(); + + CStringData* GetNilString() throw(); + + IAtlStringMgr* Clone() throw(); + }; + + struct CStringData + { + IAtlStringMgr* pStringMgr; + int nDataLength; + int nAllocLength; + long nRefs; + + void* data() throw() + { + return (this + 1); + } + + void AddRef() throw() + { + ATLASSERT(nRefs > 0); + _InterlockedIncrement(&nRefs); + } + + void Release() throw() + { + ATLASSERT(nRefs != 0); + + if (_InterlockedDecrement(&nRefs) <= 0) + { + pStringMgr->Free(this); + } + } + }; + + template< typename BaseType = char > + class ChTraitsBase + { + public: + typedef char XCHAR; + typedef LPSTR PXSTR; + typedef LPCSTR PCXSTR; + typedef wchar_t YCHAR; + typedef LPWSTR PYSTR; + typedef LPCWSTR PCYSTR; + }; + + template<> + class ChTraitsBase< wchar_t > + { + public: + typedef wchar_t XCHAR; + typedef LPWSTR PXSTR; + typedef LPCWSTR PCXSTR; + typedef char YCHAR; + typedef LPSTR PYSTR; + typedef LPCSTR PCYSTR; + }; + + + + template< typename BaseType, bool t_bMFCDLL = false> + class CSimpleStringT + { + public: + typedef typename ChTraitsBase<BaseType>::XCHAR XCHAR; + typedef typename ChTraitsBase<BaseType>::PXSTR PXSTR; + typedef typename ChTraitsBase<BaseType>::PCXSTR PCXSTR; + typedef typename ChTraitsBase<BaseType>::YCHAR YCHAR; + typedef typename ChTraitsBase<BaseType>::PYSTR PYSTR; + typedef typename ChTraitsBase<BaseType>::PCYSTR PCYSTR; + + public: + explicit CSimpleStringT(_Inout_ IAtlStringMgr* pStringMgr) + { + ATLENSURE(pStringMgr != NULL); + CStringData* pData = pStringMgr->GetNilString(); + Attach(pData); + } + + CSimpleStringT(_In_ const CSimpleStringT& strSrc) + { + CStringData* pSrcData = strSrc.GetData(); + CStringData* pNewData = CloneData(pSrcData); + Attach(pNewData); + } + + CSimpleStringT(_In_ const CSimpleStringT<BaseType, !t_bMFCDLL>& strSrc) + { + CStringData* pSrcData = strSrc.GetData(); + CStringData* pNewData = CloneData(pSrcData); + Attach(pNewData); + } + + }; +} + +#endif
Propchange: trunk/reactos/lib/atl/atlsimpstr.h ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/lib/atl/atlstr.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/atlstr.h?rev=67579 ============================================================================== --- trunk/reactos/lib/atl/atlstr.h (added) +++ trunk/reactos/lib/atl/atlstr.h [iso-8859-1] Wed May 6 21:31:40 2015 @@ -0,0 +1,55 @@ +#ifndef __ATLSTR_H__ +#define __ATLSTR_H__ + +#pragma once + +#ifndef __cplusplus + #error ATL requires C++ compilation (use a .cpp suffix) +#endif + +#include <atlbase.h> +#include <cstringt.h> + +namespace ATL +{ + template< typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>> + class StrTraitATL : + public StringIterator + { + public: + static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw() + { + return(AtlFindStringResourceInstance(nID)); + } + + static IAtlStringMgr* GetDefaultManager() throw() + { + return CAtlStringMgr::GetInstance(); + } + }; + + + template< typename _CharType = wchar_t> + class ChTraitsOS : + public ChTraitsBase<_CharType> + { + protected: + + public: + + }; + +#ifndef _ATL_CSTRING_NO_CRT + typedef CStringT<wchar_t, StrTraitATL<wchar_t, ChTraitsCRT<wchar_t>>> CAtlStringW; +#else + typedef CStringT<wchar_t, StrTraitATL<wchar_t>> CAtlStringW; +#endif + +#ifndef _AFX + typedef CAtlStringW CStringW; +#endif + + +} //namespace ATL + +#endif
Propchange: trunk/reactos/lib/atl/atlstr.h ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/lib/atl/cstringt.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/atl/cstringt.h?rev=6757... ============================================================================== --- trunk/reactos/lib/atl/cstringt.h (added) +++ trunk/reactos/lib/atl/cstringt.h [iso-8859-1] Wed May 6 21:31:40 2015 @@ -0,0 +1,77 @@ +#ifndef __CSTRINGT_H__ +#define __CSTRINGT_H__ + +#pragma once + +#include <atlsimpstr.h> +#include <stddef.h> + +#include <stdio.h> +#include <wchar.h> + + +namespace ATL +{ + + template< typename _CharType = wchar_t> + class ChTraitsCRT : + public ChTraitsBase<_CharType> + { + public: + + }; + + + + namespace _CSTRING_IMPL_ + { + template <typename _CharType, class StringTraits> + struct _MFCDLLTraitsCheck + { + const static bool c_bIsMFCDLLTraits = false; + }; + } + + template< typename BaseType, class StringTraits> + class CStringT : + public CSimpleStringT <BaseType, _CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits> + { + public: + typedef CSimpleStringT<BaseType, _CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits> CThisSimpleString; + typedef StringTraits StrTraits; + typedef typename CThisSimpleString::XCHAR XCHAR; + typedef typename CThisSimpleString::PXSTR PXSTR; + typedef typename CThisSimpleString::PCXSTR PCXSTR; + typedef typename CThisSimpleString::YCHAR YCHAR; + typedef typename CThisSimpleString::PYSTR PYSTR; + typedef typename CThisSimpleString::PCYSTR PCYSTR; + + public: + CStringT() throw() : + CThisSimpleString(StringTraits::GetDefaultManager()) + { + } + explicit CStringT( _In_ IAtlStringMgr* pStringMgr) throw() : + CThisSimpleString(pStringMgr) + { + } + + CStringT(_In_ const VARIANT& varSrc); + CStringT( + _In_ const VARIANT& varSrc, + _In_ IAtlStringMgr* pStringMgr); + + static void __cdecl Construct(_In_ CStringT* pString) + { + new(pString)CStringT; + } + + CStringT(_In_ const CStringT& strSrc) : + CThisSimpleString(strSrc) + { + } + }; + +} //namespace ATL + +#endif
Propchange: trunk/reactos/lib/atl/cstringt.h ------------------------------------------------------------------------------ svn:eol-style = native