Coverage Report

Created: 2025-11-24 06:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/sentencepiece/src/filesystem.h
Line
Count
Source
1
// Copyright 2016 Google Inc.
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
#ifndef FILESYSTEM_H_
16
#define FILESYSTEM_H_
17
18
#include <stdio.h>
19
20
#include <fstream>
21
#include <memory>
22
#include <string>
23
24
#include "common.h"
25
#include "sentencepiece_processor.h"
26
#include "third_party/absl/strings/string_view.h"
27
28
namespace sentencepiece {
29
namespace filesystem {
30
class ReadableFile {
31
 public:
32
0
  ReadableFile() {}
33
0
  explicit ReadableFile(absl::string_view filename, bool is_binary = false) {}
34
0
  virtual ~ReadableFile() {}
35
36
  virtual util::Status status() const = 0;
37
  virtual bool ReadLine(std::string *line) = 0;
38
  virtual bool ReadAll(std::string *line) = 0;
39
};
40
41
class WritableFile {
42
 public:
43
0
  WritableFile() {}
44
0
  explicit WritableFile(absl::string_view filename, bool is_binary = false) {}
45
0
  virtual ~WritableFile() {}
46
47
  virtual util::Status status() const = 0;
48
  virtual bool Write(absl::string_view text) = 0;
49
  virtual bool WriteLine(absl::string_view text) = 0;
50
};
51
52
std::unique_ptr<ReadableFile> NewReadableFile(absl::string_view filename,
53
                                              bool is_binary = false);
54
std::unique_ptr<WritableFile> NewWritableFile(absl::string_view filename,
55
                                              bool is_binary = false);
56
57
}  // namespace filesystem
58
}  // namespace sentencepiece
59
#endif  // FILESYSTEM_H_