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/Vector.h> 25 26namespace WebCore { 27 28// Type definitions for the byte stream data 29typedef union { 30 bool value; 31 unsigned char bytes[sizeof(bool)]; 32} BoolByte; 33 34typedef union { 35 float value; 36 unsigned char bytes[sizeof(float)]; 37} FloatByte; 38 39typedef union { 40 unsigned short value; 41 unsigned char bytes[sizeof(unsigned short)]; 42} UnsignedShortByte; 43 44class SVGPathByteStream { 45 WTF_MAKE_FAST_ALLOCATED; 46public: 47 typedef Vector<unsigned char> Data; 48 typedef Data::const_iterator DataIterator; 49 50 SVGPathByteStream() { } 51 SVGPathByteStream(const Data& data) : m_data(data) { } 52 53 std::unique_ptr<SVGPathByteStream> copy() const 54 { 55 return std::make_unique<SVGPathByteStream>(m_data); 56 } 57 58 DataIterator begin() { return m_data.begin(); } 59 DataIterator end() { return m_data.end(); } 60 void append(unsigned char byte) { m_data.append(byte); } 61 void append(SVGPathByteStream* other) 62 { 63 for (DataIterator it = other->begin(); it != other->end(); ++it) 64 append(*it); 65 } 66 void clear() { m_data.clear(); } 67 bool isEmpty() const { return !m_data.size(); } 68 unsigned size() const { return m_data.size(); } 69 70 // Only defined to let SVGAnimatedPathAnimator use the standard list code paths - this method is never called. 71 void resize(unsigned) { } 72 73private: 74 Data m_data; 75}; 76 77} // namespace WebCore 78 79#endif // SVGPathByteStream_h 80