Debian Codegraph @

libs/protoutil/include/android/util/ProtoReader.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #pragma once
18
19 #include <utils/Errors.h>
20 #include <utils/RefBase.h>
21
22 #include <stdint.h>
23 #include <vector>
24
25 namespace android {
26 namespace util {
27
28 class ProtoReader : public virtual RefBase {
29 public:
30 ProtoReader();
31 ~ProtoReader();
32
33 /**
34 * Returns the number of bytes written in the buffer
35 */
36 virtual ssize_t size() const = 0;
37
38 /**
39 * Returns the size of total bytes read.
40 */
41 virtual size_t bytesRead() const = 0;
42
43 /**
44 * Returns the current position of read pointer, if NULL is returned, it reaches
45 * end of buffer.
46 */
47 virtual uint8_t const* readBuffer() = 0;
48
49 /**
50 * Returns the readable size in the current read buffer.
51 */
52 virtual size_t currentToRead() = 0;
53
54 /**
55 * Returns true if next bytes is available for read.
56 */
57 virtual bool hasNext() = 0;
58
59 /**
60 * Reads the current byte and moves pointer 1 bit.
61 */
62 virtual uint8_t next() = 0;
63
64 /**
65 * Read varint from the reader, the reader will point to next available byte.
66 */
67 virtual uint64_t readRawVarint() = 0;
68
69 /**
70 * Advance the read pointer.
71 */
72 virtual void move(size_t amt) = 0;
73 };
74
75 } // util
76 } // android
77