parser/html/nsHtml5ByteReadable.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser/html/nsHtml5ByteReadable.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef nsHtml5ByteReadable_h
     1.9 +#define nsHtml5ByteReadable_h
    1.10 +
    1.11 +/**
    1.12 + * A weak reference wrapper around a byte array.
    1.13 + */
    1.14 +class nsHtml5ByteReadable
    1.15 +{
    1.16 +  public:
    1.17 +
    1.18 +    nsHtml5ByteReadable(const uint8_t* aCurrent, const uint8_t* aEnd)
    1.19 +     : current(aCurrent),
    1.20 +       end(aEnd)
    1.21 +    {
    1.22 +    }
    1.23 +
    1.24 +    inline int32_t read() {
    1.25 +      if (current < end) {
    1.26 +        return *(current++);
    1.27 +      } else {
    1.28 +        return -1;
    1.29 +      }
    1.30 +    }
    1.31 +
    1.32 +  private:
    1.33 +    const uint8_t* current;
    1.34 +    const uint8_t* end;
    1.35 +};
    1.36 +#endif

mercurial