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