[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-dev] Alignment in AMF data

From: Bastiaan Jacques
Subject: Re: [Gnash-dev] Alignment in AMF data
Date: Sat, 25 Oct 2008 13:56:45 -0700 (PDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

An interface that would solve the problem could look like this:

template <typename T, size_t N>
networkConvert(boost::uint8_t* word);

Where T is the requested type and N the number of bytes to read from
'word'. networkConvert copies the data byte by byte, solving the
alignment issue. For example:

double number = networkConvert<double, 8>(stream);

The point of the template here is to have the ability to add specialized
implementations, for example one for even and one for uneven sized byte
counts, without adding runtime overhead. networkConvert could call
swapBytes in its implementation, but from the perspective of the
interface we don't really care.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]