2012-05-29 08:52:43 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2013-01-10 08:19:36 -08:00
|
|
|
|
2013-08-23 08:07:10 -07:00
|
|
|
#ifndef nsHtml5ByteReadable_h
|
|
|
|
#define nsHtml5ByteReadable_h
|
2009-06-28 15:44:22 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A weak reference wrapper around a byte array.
|
|
|
|
*/
|
|
|
|
class nsHtml5ByteReadable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-02-21 18:10:59 -08:00
|
|
|
nsHtml5ByteReadable(const uint8_t* aCurrent, const uint8_t* aEnd)
|
|
|
|
: current(aCurrent),
|
|
|
|
end(aEnd)
|
2009-06-28 15:44:22 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
inline int32_t read() {
|
2009-06-28 15:44:22 -07:00
|
|
|
if (current < end) {
|
|
|
|
return *(current++);
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t* current;
|
|
|
|
const uint8_t* end;
|
2009-06-28 15:44:22 -07:00
|
|
|
};
|
|
|
|
#endif
|