VirtualBox

Changeset 10709 in vbox


Ignore:
Timestamp:
Jul 16, 2008 7:23:38 PM (16 years ago)
Author:
vboxsync
Message:

Main: SafeArray: Added SafeArrayTraits <const PRUnichar *> to make sure there is no unnecessary const violation. Note that the parameter to the ComSafeArray template must be now INPTR BSTR for input BSTR array parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/array.h

    r10151 r10709  
    153153 * supported and therefore cannot be used as element types.
    154154 *
     155 * In order to pass input BSTR array parameters delcared using the
     156 * ComSafeArrayIn (INPTR BSTR, aParam) macro to the SafeArray<> constructor
     157 * using the ComSafeArrayInArg() macro, you should use INPTR BSTR as the
     158 * SafeArray<> template argument, not just BSTR.
     159 *
    155160 * Arrays of interface pointers are also supported but they require to use a
    156161 * special SafeArray implementation, com::SafeIfacePointer, which takes the
     
    265270        return const_cast <const PRUnichar **> (aArr);
    266271    }
     272    static const PRUnichar **__asInParam_Arr (const PRUnichar **aArr) { return aArr; }
     273};
     274
     275template<>
     276struct SafeArrayTraits <const PRUnichar *>
     277{
     278protected:
     279
     280    static void Init (const PRUnichar * &aElem) { aElem = NULL; }
     281    static void Uninit (const PRUnichar * &aElem)
     282    {
     283        if (aElem)
     284        {
     285            ::SysFreeString (const_cast <PRUnichar *> (aElem));
     286            aElem = NULL;
     287        }
     288    }
     289
     290    static void Copy (const PRUnichar * aFrom, const PRUnichar * &aTo)
     291    {
     292        AssertCompile (sizeof (PRUnichar) == sizeof (OLECHAR));
     293        aTo = aFrom ? ::SysAllocString ((const OLECHAR *) aFrom) : NULL;
     294    }
     295
     296public:
     297
     298    /* Magic to workaround strict rules of par. 4.4.4 of the C++ standard */
    267299    static const PRUnichar **__asInParam_Arr (const PRUnichar **aArr) { return aArr; }
    268300};
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette