• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc. All Rights Reserved.
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 #ifndef SFNTLY_CPP_SRC_SFNTLY_PORT_INPUT_STREAM_H_
18 #define SFNTLY_CPP_SRC_SFNTLY_PORT_INPUT_STREAM_H_
19 
20 #include "sfntly/port/type.h"
21 
22 namespace sfntly {
23 
24 // C++ equivalent to Java's OutputStream class
25 class InputStream {
26  public:
27   virtual int32_t Length() = 0;
28   virtual int32_t Available() = 0;
29   virtual void Close() = 0;
30   virtual void Mark(int32_t readlimit) = 0;
31   virtual bool MarkSupported() = 0;
32   virtual int32_t Read() = 0;
33   virtual int32_t Read(std::vector<uint8_t>* b) = 0;
34   virtual int32_t Read(std::vector<uint8_t>* b, int32_t offset, int32_t length) = 0;
35   virtual void Reset() = 0;
36   virtual int64_t Skip(int64_t n) = 0;
37 
38  protected:
~InputStream()39   virtual ~InputStream() {}
40 };
41 
42 class PushbackInputStream : public InputStream {
43  public:
44   virtual void Unread(std::vector<uint8_t>* b) = 0;
45   virtual void Unread(std::vector<uint8_t>* b, int32_t offset, int32_t length) = 0;
46 };
47 
48 }  // namespace sfntly
49 
50 #endif  // SFNTLY_CPP_SRC_SFNTLY_PORT_INPUT_STREAM_H_
51