• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_LIB_IO_INPUTSTREAM_INTERFACE_H_
17 #define TENSORFLOW_CORE_LIB_IO_INPUTSTREAM_INTERFACE_H_
18 
19 #include <string>
20 #include "tensorflow/core/lib/core/status.h"
21 #include "tensorflow/core/platform/types.h"
22 
23 namespace tensorflow {
24 namespace io {
25 
26 // An interface that defines input streaming operations.
27 class InputStreamInterface {
28  public:
InputStreamInterface()29   InputStreamInterface() {}
~InputStreamInterface()30   virtual ~InputStreamInterface() {}
31 
32   // Reads the next bytes_to_read from the file. Typical return codes:
33   //  * OK - in case of success.
34   //  * OUT_OF_RANGE - not enough bytes remaining before end of file.
35   virtual Status ReadNBytes(int64 bytes_to_read, string* result) = 0;
36 
37   // Skips bytes_to_skip before next ReadNBytes. bytes_to_skip should be >= 0.
38   // Typical return codes:
39   //  * OK - in case of success.
40   //  * OUT_OF_RANGE - not enough bytes remaining before end of file.
41   virtual Status SkipNBytes(int64 bytes_to_skip);
42 
43   // Return the offset of the current byte relative to the beginning of the
44   // file.
45   // If we Skip / Read beyond the end of the file, this should return the length
46   // of the file.
47   // If there are any errors, this must return -1.
48   virtual int64 Tell() const = 0;
49 
50   // Resets the stream to the beginning.
51   virtual Status Reset() = 0;
52 };
53 
54 }  // namespace io
55 }  // namespace tensorflow
56 
57 #endif  // TENSORFLOW_CORE_LIB_IO_INPUTSTREAM_INTERFACE_H_
58