SVGPathByteStream.h [plain text]
#ifndef SVGPathByteStream_h
#define SVGPathByteStream_h
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
namespace WebCore {
typedef union {
bool value;
unsigned char bytes[sizeof(bool)];
} BoolByte;
typedef union {
float value;
unsigned char bytes[sizeof(float)];
} FloatByte;
typedef union {
unsigned short value;
unsigned char bytes[sizeof(unsigned short)];
} UnsignedShortByte;
class SVGPathByteStream {
WTF_MAKE_FAST_ALLOCATED;
public:
typedef Vector<unsigned char> Data;
typedef Data::const_iterator DataIterator;
SVGPathByteStream() { }
SVGPathByteStream(const Data& data) : m_data(data) { }
std::unique_ptr<SVGPathByteStream> copy() const
{
return std::make_unique<SVGPathByteStream>(m_data);
}
DataIterator begin() { return m_data.begin(); }
DataIterator end() { return m_data.end(); }
void append(unsigned char byte) { m_data.append(byte); }
void append(SVGPathByteStream* other)
{
for (DataIterator it = other->begin(); it != other->end(); ++it)
append(*it);
}
void clear() { m_data.clear(); }
bool isEmpty() const { return !m_data.size(); }
unsigned size() const { return m_data.size(); }
void resize(unsigned) { }
private:
Data m_data;
};
}
#endif // SVGPathByteStream_h