chromium/net/third_party/quiche/src/quiche/common/quiche_data_reader.h

// Copyright (c) 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef QUICHE_COMMON_QUICHE_DATA_READER_H_
#define QUICHE_COMMON_QUICHE_DATA_READER_H_

#include <cstddef>
#include <cstdint>
#include <limits>
#include <string>

#include "absl/strings/string_view.h"
#include "quiche/common/platform/api/quiche_export.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/quiche_endian.h"

namespace quiche {

// To use, simply construct a QuicheDataReader using the underlying buffer that
// you'd like to read fields from, then call one of the Read*() methods to
// actually do some reading.
//
// This class keeps an internal iterator to keep track of what's already been
// read and each successive Read*() call automatically increments said iterator
// on success. On failure, internal state of the QuicheDataReader should not be
// trusted and it is up to the caller to throw away the failed instance and
// handle the error as appropriate. None of the Read*() methods should ever be
// called after failure, as they will also fail immediately.
class QUICHE_EXPORT QuicheDataReader {};

}  // namespace quiche

#endif  // QUICHE_COMMON_QUICHE_DATA_READER_H_