• 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_OUTPUT_STREAM_H_
18 #define SFNTLY_CPP_SRC_SFNTLY_PORT_OUTPUT_STREAM_H_
19 
20 #include "sfntly/port/type.h"
21 
22 namespace sfntly {
23 
24 // C++ equivalent to Java's OutputStream class
25 class OutputStream {
26  public:
27   // Make gcc -Wnon-virtual-dtor happy.
~OutputStream()28   virtual ~OutputStream() {}
29 
30   virtual void Close() = 0;
31   virtual void Flush() = 0;
32   virtual void Write(ByteVector* buffer) = 0;
33   virtual void Write(byte_t b) = 0;
34 
35   // Note: C++ port offered both versions of Write() here.  The first one is
36   //       better because it does check bounds.  The second one is there for
37   //       performance concerns.
38   virtual void Write(ByteVector* buffer, int32_t offset, int32_t length) = 0;
39 
40   // Note: Caller is responsible for the boundary of buffer.
41   virtual void Write(byte_t* buffer, int32_t offset, int32_t length) = 0;
42 };
43 
44 }  // namespace sfntly
45 
46 #endif  // SFNTLY_CPP_SRC_SFNTLY_PORT_OUTPUT_STREAM_H_
47