| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef SVGPathByteStream_h | 20 #ifndef SVGPathByteStream_h |
| 21 #define SVGPathByteStream_h | 21 #define SVGPathByteStream_h |
| 22 | 22 |
| 23 #include "wtf/Noncopyable.h" | 23 #include "wtf/Noncopyable.h" |
| 24 #include "wtf/PtrUtil.h" | 24 #include "wtf/PassOwnPtr.h" |
| 25 #include "wtf/Vector.h" | 25 #include "wtf/Vector.h" |
| 26 #include <memory> | |
| 27 | 26 |
| 28 namespace blink { | 27 namespace blink { |
| 29 | 28 |
| 30 template<typename DataType> | 29 template<typename DataType> |
| 31 union ByteType { | 30 union ByteType { |
| 32 DataType value; | 31 DataType value; |
| 33 unsigned char bytes[sizeof(DataType)]; | 32 unsigned char bytes[sizeof(DataType)]; |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 class SVGPathByteStream { | 35 class SVGPathByteStream { |
| 37 USING_FAST_MALLOC(SVGPathByteStream); | 36 USING_FAST_MALLOC(SVGPathByteStream); |
| 38 public: | 37 public: |
| 39 static std::unique_ptr<SVGPathByteStream> create() | 38 static PassOwnPtr<SVGPathByteStream> create() |
| 40 { | 39 { |
| 41 return wrapUnique(new SVGPathByteStream); | 40 return adoptPtr(new SVGPathByteStream); |
| 42 } | 41 } |
| 43 | 42 |
| 44 std::unique_ptr<SVGPathByteStream> clone() const | 43 PassOwnPtr<SVGPathByteStream> clone() const |
| 45 { | 44 { |
| 46 return wrapUnique(new SVGPathByteStream(m_data)); | 45 return adoptPtr(new SVGPathByteStream(m_data)); |
| 47 } | 46 } |
| 48 | 47 |
| 49 typedef Vector<unsigned char> Data; | 48 typedef Vector<unsigned char> Data; |
| 50 typedef Data::const_iterator DataIterator; | 49 typedef Data::const_iterator DataIterator; |
| 51 | 50 |
| 52 DataIterator begin() const { return m_data.begin(); } | 51 DataIterator begin() const { return m_data.begin(); } |
| 53 DataIterator end() const { return m_data.end(); } | 52 DataIterator end() const { return m_data.end(); } |
| 54 void append(const unsigned char* data, size_t dataSize) { m_data.append(data
, dataSize); } | 53 void append(const unsigned char* data, size_t dataSize) { m_data.append(data
, dataSize); } |
| 55 void clear() { m_data.clear(); } | 54 void clear() { m_data.clear(); } |
| 56 void reserveInitialCapacity(size_t size) { m_data.reserveInitialCapacity(siz
e); } | 55 void reserveInitialCapacity(size_t size) { m_data.reserveInitialCapacity(siz
e); } |
| 57 void shrinkToFit() { m_data.shrinkToFit(); } | 56 void shrinkToFit() { m_data.shrinkToFit(); } |
| 58 bool isEmpty() const { return m_data.isEmpty(); } | 57 bool isEmpty() const { return m_data.isEmpty(); } |
| 59 unsigned size() const { return m_data.size(); } | 58 unsigned size() const { return m_data.size(); } |
| 60 | 59 |
| 61 bool operator==(const SVGPathByteStream& other) const { return m_data == oth
er.m_data; } | 60 bool operator==(const SVGPathByteStream& other) const { return m_data == oth
er.m_data; } |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 SVGPathByteStream() { } | 63 SVGPathByteStream() { } |
| 65 SVGPathByteStream(const Data& data) | 64 SVGPathByteStream(const Data& data) |
| 66 : m_data(data) | 65 : m_data(data) |
| 67 { | 66 { |
| 68 } | 67 } |
| 69 | 68 |
| 70 Data m_data; | 69 Data m_data; |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 } // namespace blink | 72 } // namespace blink |
| 74 | 73 |
| 75 #endif // SVGPathByteStream_h | 74 #endif // SVGPathByteStream_h |
| OLD | NEW |