1 /* 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 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 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef SVGPathByteStream_h 21 #define SVGPathByteStream_h 22 23 #include "wtf/Noncopyable.h" 24 #include "wtf/PassOwnPtr.h" 25 #include "wtf/Vector.h" 26 27 namespace WebCore { 28 29 // Type definitions for the byte stream data 30 typedef union { 31 bool value; 32 unsigned char bytes[sizeof(bool)]; 33 } BoolByte; 34 35 typedef union { 36 float value; 37 unsigned char bytes[sizeof(float)]; 38 } FloatByte; 39 40 typedef union { 41 unsigned short value; 42 unsigned char bytes[sizeof(unsigned short)]; 43 } UnsignedShortByte; 44 45 class SVGPathByteStream { 46 WTF_MAKE_FAST_ALLOCATED; 47 public: create()48 static PassOwnPtr<SVGPathByteStream> create() 49 { 50 return adoptPtr(new SVGPathByteStream); 51 } 52 copy()53 PassOwnPtr<SVGPathByteStream> copy() 54 { 55 return adoptPtr(new SVGPathByteStream(m_data)); 56 } 57 58 typedef Vector<unsigned char> Data; 59 typedef Data::const_iterator DataIterator; 60 begin()61 DataIterator begin() { return m_data.begin(); } end()62 DataIterator end() { return m_data.end(); } append(unsigned char byte)63 void append(unsigned char byte) { m_data.append(byte); } append(SVGPathByteStream * other)64 void append(SVGPathByteStream* other) 65 { 66 for (DataIterator it = other->begin(); it != other->end(); ++it) 67 append(*it); 68 } clear()69 void clear() { m_data.clear(); } isEmpty()70 bool isEmpty() const { return !m_data.size(); } size()71 unsigned size() const { return m_data.size(); } 72 73 // Only defined to let SVGAnimatedPathAnimator use the standard list code paths - this method is never called. resize(unsigned)74 void resize(unsigned) { } 75 76 private: SVGPathByteStream()77 SVGPathByteStream() { } SVGPathByteStream(Data & data)78 SVGPathByteStream(Data& data) 79 : m_data(data) 80 { 81 } 82 83 Data m_data; 84 }; 85 86 } // namespace WebCore 87 88 #endif // SVGPathByteStream_h 89