VirtualBox

Changeset 99770 in vbox


Ignore:
Timestamp:
May 12, 2023 9:27:23 AM (17 months ago)
Author:
vboxsync
Message:

VBox/com: Added SafeArray::push_front() and implemented a new (initial) testcase for the SafeArray glue code.

Location:
trunk
Files:
1 added
2 edited

Legend:

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

    r98103 r99770  
    816816
    817817    /**
     818     * Prepends a copy of the given element at the beginning of the array.
     819     *
     820     * The array size is increased by one by this method and the additional
     821     * space is allocated as needed.
     822     *
     823     * This method is handy in cases where you want to assign a copy of the
     824     * existing value to the array element, for example:
     825     * <tt>Bstr string; array.push_front(string);</tt>. If you create a string
     826     * just to put it in the array, you may find #appendedRaw() more useful.
     827     *
     828     * @param aElement Element to prepend.
     829     *
     830     * @return          @c true on success and @c false if there is not enough
     831     *                  memory for resizing.
     832     */
     833    bool push_front(const T &aElement)
     834    {
     835        if (!ensureCapacity(size() + 1))
     836            return false;
     837
     838        for (size_t i = size(); i > 0; --i)
     839        {
     840#ifdef VBOX_WITH_XPCOM
     841            SafeArray::Copy(m.arr[i - 1], m.arr[i]);
     842#else
     843            Copy(m.arr[i - 1], m.arr[i]);
     844#endif
     845        }
     846
     847#ifdef VBOX_WITH_XPCOM
     848        SafeArray::Copy(aElement, m.arr[0]);
     849        ++ m.size;
     850#else
     851        Copy(aElement, m.arr[0]);
     852#endif
     853        return true;
     854    }
     855
     856    /**
    818857     * Appends a copy of the given element at the end of the array.
    819858     *
  • trunk/src/VBox/Main/testcase/Makefile.kmk

    r99744 r99770  
    4747        $(if $(VBOX_WITH_GUEST_CONTROL),tstGuestCtrlPaths,) \
    4848        tstMediumLock \
     49        tstSafeArray \
    4950        tstBstr \
    5051        tstGuid \
     
    285286tstMediumLock_TEMPLATE = VBoxMainClientTstExe
    286287tstMediumLock_SOURCES  = tstMediumLock.cpp
     288
     289
     290#
     291# tstSafeArray
     292#
     293tstSafeArray_TEMPLATE = VBoxMainClientTstExe
     294tstSafeArray_SOURCES  = tstSafeArray.cpp
    287295
    288296
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