• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS.  All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 #ifndef SRC_ID_PARSER_H_
9 #define SRC_ID_PARSER_H_
10 
11 #include <cstdint>
12 
13 #include "src/parser.h"
14 #include "webm/callback.h"
15 #include "webm/id.h"
16 #include "webm/reader.h"
17 #include "webm/status.h"
18 
19 namespace webm {
20 
21 // Parses an EBML ID from a byte stream.
22 class IdParser : public Parser {
23  public:
24   IdParser() = default;
25   IdParser(IdParser&&) = default;
26   IdParser& operator=(IdParser&&) = default;
27 
28   IdParser(const IdParser&) = delete;
29   IdParser& operator=(const IdParser&) = delete;
30 
31   Status Feed(Callback* callback, Reader* reader,
32               std::uint64_t* num_bytes_read) override;
33 
34   // Gets the parsed ID. This must not be called until the parse had been
35   // successfully completed.
36   Id id() const;
37 
38  private:
39   int num_bytes_remaining_ = -1;
40   Id id_;
41 };
42 
43 }  // namespace webm
44 
45 #endif  // SRC_ID_PARSER_H_
46