2012-05-29 15:52:43 +00: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 16:19:36 +00:00
|
|
|
|
2013-08-23 15:07:10 +00:00
|
|
|
#ifndef nsHtml5ByteReadable_h
|
|
|
|
#define nsHtml5ByteReadable_h
|
2009-06-28 22:44:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A weak reference wrapper around a byte array.
|
|
|
|
*/
|
|
|
|
class nsHtml5ByteReadable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-02-22 02:10:59 +00:00
|
|
|
nsHtml5ByteReadable(const uint8_t* aCurrent, const uint8_t* aEnd)
|
|
|
|
: current(aCurrent),
|
|
|
|
end(aEnd)
|
2009-06-28 22:44:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
inline int32_t read() {
|
2009-06-28 22:44:22 +00:00
|
|
|
if (current < end) {
|
|
|
|
return *(current++);
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint8_t* current;
|
|
|
|
const uint8_t* end;
|
2009-06-28 22:44:22 +00:00
|
|
|
};
|
|
|
|
#endif
|