1464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com/*
2464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * Copyright 2011 Google Inc. All Rights Reserved.
3464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *
4464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * Licensed under the Apache License, Version 2.0 (the "License");
5464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * you may not use this file except in compliance with the License.
6464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * You may obtain a copy of the License at
7464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *
8464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *      http://www.apache.org/licenses/LICENSE-2.0
9464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *
10464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * Unless required by applicable law or agreed to in writing, software
11464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * distributed under the License is distributed on an "AS IS" BASIS,
12464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * See the License for the specific language governing permissions and
14464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * limitations under the License.
15464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com */
16464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
175af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#ifndef SFNTLY_CPP_SRC_SFNTLY_PORT_OUTPUT_STREAM_H_
185af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#define SFNTLY_CPP_SRC_SFNTLY_PORT_OUTPUT_STREAM_H_
19464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
20464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com#include "sfntly/port/type.h"
21464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
22464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comnamespace sfntly {
23464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
24464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com// C++ equivalent to Java's OutputStream class
25464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comclass OutputStream {
26464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com public:
27464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // Make gcc -Wnon-virtual-dtor happy.
28464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  virtual ~OutputStream() {}
29246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com
30246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com  virtual void Close() = 0;
31246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com  virtual void Flush() = 0;
32246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com  virtual void Write(ByteVector* buffer) = 0;
33246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com  virtual void Write(byte_t b) = 0;
3432a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com
3532a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  // Note: C++ port offered both versions of Write() here.  The first one is
3632a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  //       better because it does check bounds.  The second one is there for
3732a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  //       performance concerns.
3832a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  virtual void Write(ByteVector* buffer, int32_t offset, int32_t length) = 0;
3932a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com
4032a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  // Note: Caller is responsible for the boundary of buffer.
4132a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  virtual void Write(byte_t* buffer, int32_t offset, int32_t length) = 0;
42464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com};
43464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
44464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com}  // namespace sfntly
45464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
465af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#endif  // SFNTLY_CPP_SRC_SFNTLY_PORT_OUTPUT_STREAM_H_
47