tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsHtml5ByteReadable.h (657B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef nsHtml5ByteReadable_h
      6 #define nsHtml5ByteReadable_h
      7 
      8 /**
      9 * A weak reference wrapper around a byte array.
     10 */
     11 class nsHtml5ByteReadable {
     12 public:
     13  nsHtml5ByteReadable(const uint8_t* aCurrent, const uint8_t* aEnd)
     14      : current(aCurrent), end(aEnd) {}
     15 
     16  inline int32_t read() {
     17    if (current < end) {
     18      return *(current++);
     19    } else {
     20      return -1;
     21    }
     22  }
     23 
     24 private:
     25  const uint8_t* current;
     26  const uint8_t* end;
     27 };
     28 #endif