Home | History | Annotate | Download | only in port
      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   // Make gcc -Wnon-virtual-dtor happy.
     28   virtual ~InputStream() {}
     29 
     30   virtual int32_t Available() = 0;
     31   virtual void Close() = 0;
     32   virtual void Mark(int32_t readlimit) = 0;
     33   virtual bool MarkSupported() = 0;
     34   virtual int32_t Read() = 0;
     35   virtual int32_t Read(ByteVector* b) = 0;
     36   virtual int32_t Read(ByteVector* b, int32_t offset, int32_t length) = 0;
     37   virtual void Reset() = 0;
     38   virtual int64_t Skip(int64_t n) = 0;
     39 };
     40 
     41 class PushbackInputStream : public InputStream {
     42  public:
     43   virtual void Unread(ByteVector* b) = 0;
     44   virtual void Unread(ByteVector* b, int32_t offset, int32_t length) = 0;
     45 };
     46 
     47 }  // namespace sfntly
     48 
     49 #endif  // SFNTLY_CPP_SRC_SFNTLY_PORT_INPUT_STREAM_H_
     50