Changeset 45520 in vbox for trunk/include/VBox
- Timestamp:
- Apr 12, 2013 2:22:41 PM (12 years ago)
- Location:
- trunk/include/VBox/com
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/list.h
r37861 r45520 5 5 6 6 /* 7 * Copyright (C) 2011 Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 30 30 #include <VBox/com/ptr.h> 31 31 #include <VBox/com/string.h> 32 #include <VBox/com/array.h> 32 33 #include <iprt/cpp/list.h> 34 33 35 34 36 /** … … 55 57 * @throws std::bad_alloc 56 58 */ 57 RTCList(size_t cCapacity = BASE:: DefaultCapacity)58 : BASE(cCapacity) {}59 RTCList(size_t cCapacity = BASE::kDefaultCapacity) 60 : BASE(cCapacity) {} 59 61 60 62 /* Define our own new and delete. */ … … 85 87 * @throws std::bad_alloc 86 88 */ 87 RTCList(size_t cCapacity = BASE:: DefaultCapacity)88 : BASE(cCapacity) {}89 RTCList(size_t cCapacity = BASE::kDefaultCapacity) 90 : BASE(cCapacity) {} 89 91 90 92 /* Define our own new and delete. */ … … 98 100 */ 99 101 template <> 100 class RTCList< Utf8Str>: public RTCListBase<Utf8Str,Utf8Str*, false>102 class RTCList<com::Utf8Str>: public RTCListBase<com::Utf8Str, com::Utf8Str*, false> 101 103 { 102 104 /* Traits */ 103 typedef Utf8StrT;105 typedef com::Utf8Str T; 104 106 typedef T *ITYPE; 105 107 static const bool MT = false; … … 115 117 * @throws std::bad_alloc 116 118 */ 117 RTCList(size_t cCapacity = BASE:: DefaultCapacity)118 : BASE(cCapacity) {}119 RTCList(size_t cCapacity = BASE::kDefaultCapacity) 120 : BASE(cCapacity) {} 119 121 120 122 /** … … 131 133 { 132 134 com::SafeArray<IN_BSTR> sfaOther(ComSafeArrayInArg(other)); 133 realloc(sfaOther.size()); 134 m_cSize = sfaOther.size(); 135 for (size_t i = 0; i < m_cSize; ++i) 135 size_t const cElementsOther = sfaOther.size(); 136 resizeArray(cElementsOther); 137 m_cElements = cElementsOther; 138 for (size_t i = 0; i < cElementsOther; ++i) 136 139 RTCListHelper<T, ITYPE>::set(m_pArray, i, T(sfaOther[i])); 137 140 } … … 148 151 */ 149 152 RTCList(const com::SafeArray<IN_BSTR> &other) 150 : BASE(other.size())151 { 152 for (size_t i = 0; i < m_c Size; ++i)153 : BASE(other.size()) 154 { 155 for (size_t i = 0; i < m_cElements; ++i) 153 156 RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i])); 154 157 } … … 165 168 { 166 169 m_guard.enterWrite(); 170 167 171 /* Values cleanup */ 168 RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cSize); 172 RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements); 173 169 174 /* Copy */ 170 if (other.size() != m_cCapacity) 171 realloc_no_elements_clean(other.size()); 172 m_cSize = other.size(); 173 for (size_t i = 0; i < other.size(); ++i) 175 size_t cElementsOther = other.size(); 176 if (cElementsOther != m_cCapacity) 177 resizeArrayNoErase(cElementsOther); 178 m_cElements = cElementsOther; 179 for (size_t i = 0; i < cElementsOther; ++i) 174 180 RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i])); 181 175 182 m_guard.leaveWrite(); 176 177 183 return *this; 178 184 } -
trunk/include/VBox/com/mtlist.h
r37861 r45520 5 5 6 6 /* 7 * Copyright (C) 2011 Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 30 30 #include <VBox/com/ptr.h> 31 31 #include <VBox/com/string.h> 32 #include <VBox/com/array.h> 32 33 #include <iprt/cpp/mtlist.h> 33 34 … … 55 56 * @throws std::bad_alloc 56 57 */ 57 RTC List(size_t cCapacity = BASE::DefaultCapacity)58 : BASE(cCapacity) {}58 RTCMTList(size_t cCapacity = BASE::kDefaultCapacity) 59 : BASE(cCapacity) {} 59 60 60 61 /* Define our own new and delete. */ … … 85 86 * @throws std::bad_alloc 86 87 */ 87 RTC List(size_t cCapacity = BASE::DefaultCapacity)88 RTCMTList(size_t cCapacity = BASE::kDefaultCapacity) 88 89 : BASE(cCapacity) {} 89 90 … … 98 99 */ 99 100 template <> 100 class RTCMTList< Utf8Str>: public RTCListBase<Utf8Str, Utf8Str*, true>101 class RTCMTList<com::Utf8Str>: public RTCListBase<com::Utf8Str, com::Utf8Str *, true> 101 102 { 102 103 /* Traits */ 103 typedef Utf8StrT;104 typedef com::Utf8Str T; 104 105 typedef T *ITYPE; 105 106 static const bool MT = true; … … 115 116 * @throws std::bad_alloc 116 117 */ 117 RTCMTList(size_t cCapacity = BASE:: DefaultCapacity)118 : BASE(cCapacity) {}118 RTCMTList(size_t cCapacity = BASE::kDefaultCapacity) 119 : BASE(cCapacity) {} 119 120 120 121 /** … … 131 132 { 132 133 com::SafeArray<IN_BSTR> sfaOther(ComSafeArrayInArg(other)); 133 realloc(sfaOther.size()); 134 m_cSize = sfaOther.size(); 135 for (size_t i = 0; i < m_cSize; ++i) 134 size_t const cElementsOther = sfaOther.size(); 135 resizeArray(cElementsOther); 136 m_cElements = cElementsOther; 137 for (size_t i = 0; i < cElementsOther; ++i) 136 138 RTCListHelper<T, ITYPE>::set(m_pArray, i, T(sfaOther[i])); 137 139 } … … 150 152 : BASE(other.size()) 151 153 { 152 for (size_t i = 0; i < m_c Size; ++i)154 for (size_t i = 0; i < m_cElements; ++i) 153 155 RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i])); 154 156 } … … 166 168 m_guard.enterWrite(); 167 169 /* Values cleanup */ 168 RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_c Size);170 RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements); 169 171 /* Copy */ 170 172 if (other.size() != m_cCapacity) 171 re alloc_no_elements_clean(other.size());172 m_c Size= other.size();173 resizeArrayNoErase(other.size()); 174 m_cElements = other.size(); 173 175 for (size_t i = 0; i < other.size(); ++i) 174 176 RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i]));
Note:
See TracChangeset
for help on using the changeset viewer.