Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
recordio.h
Go to the documentation of this file.
1// Copyright 2010-2025 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef ORTOOLS_SAT_RECORDIO_H_
15#define ORTOOLS_SAT_RECORDIO_H_
16
17#include <istream>
18#include <ostream>
19
20#include "google/protobuf/io/coded_stream.h"
21#include "google/protobuf/io/zero_copy_stream_impl.h"
22#include "google/protobuf/message_lite.h"
23
24namespace operations_research {
25namespace sat {
26
27// Reads a sequence of serialized protos from a stream, written by a
28// RecordWriter.
30 public:
31 explicit RecordReader(std::istream* istream);
32 // This class is neither copyable nor movable.
33 RecordReader(const RecordReader&) = delete;
35
36 bool ReadRecord(google::protobuf::MessageLite* record);
37 void Close();
38
39 private:
40 google::protobuf::io::IstreamInputStream istream_;
41 google::protobuf::io::CodedInputStream coded_istream_;
42};
43
44// Writes a sequence of serialized protos to a stream.
46 public:
47 explicit RecordWriter(std::ostream* ostream);
48 // This class is neither copyable nor movable.
49 RecordWriter(const RecordWriter&) = delete;
51
52 bool WriteRecord(const google::protobuf::MessageLite& record);
53 void Close();
54
55 private:
56 google::protobuf::io::OstreamOutputStream ostream_;
57 google::protobuf::io::CodedOutputStream coded_ostream_;
58};
59
60} // namespace sat
61} // namespace operations_research
62
63#endif // ORTOOLS_SAT_RECORDIO_H_
RecordReader(std::istream *istream)
Definition recordio.cc:25
RecordReader & operator=(const RecordReader &)=delete
RecordReader(const RecordReader &)=delete
bool ReadRecord(google::protobuf::MessageLite *record)
Definition recordio.cc:28
bool WriteRecord(const google::protobuf::MessageLite &record)
Definition recordio.cc:42
RecordWriter(const RecordWriter &)=delete
RecordWriter & operator=(const RecordWriter &)=delete
RecordWriter(std::ostream *ostream)
Definition recordio.cc:39
OR-Tools root namespace.