Google OR-Tools
v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
recordio.cc
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
#include "
ortools/sat/recordio.h
"
15
16
#include <cstdint>
17
#include <istream>
18
#include <ostream>
19
20
#include "google/protobuf/message_lite.h"
21
22
namespace
operations_research
{
23
namespace
sat
{
24
25
RecordReader::RecordReader
(std::istream* istream)
26
: istream_(istream), coded_istream_(&istream_) {}
27
28
bool
RecordReader::ReadRecord
(google::protobuf::MessageLite* record) {
29
uint32_t size;
30
if
(!coded_istream_.ReadVarint32(&size))
return
false
;
31
auto
limit = coded_istream_.PushLimit(size);
32
if
(!record->ParseFromCodedStream(&coded_istream_))
return
false
;
33
coded_istream_.PopLimit(limit);
34
return
true
;
35
}
36
37
void
RecordReader::Close
() {}
38
39
RecordWriter::RecordWriter
(std::ostream* ostream)
40
: ostream_(ostream), coded_ostream_(&ostream_) {}
41
42
bool
RecordWriter::WriteRecord
(
const
google::protobuf::MessageLite& record) {
43
coded_ostream_.WriteVarint32(record.ByteSizeLong());
44
return
record.SerializeToCodedStream(&coded_ostream_);
45
}
46
47
void
RecordWriter::Close
() { coded_ostream_.Trim(); }
48
49
}
// namespace sat
50
}
// namespace operations_research
operations_research::sat::RecordReader::RecordReader
RecordReader(std::istream *istream)
Definition
recordio.cc:25
operations_research::sat::RecordReader::ReadRecord
bool ReadRecord(google::protobuf::MessageLite *record)
Definition
recordio.cc:28
operations_research::sat::RecordReader::Close
void Close()
Definition
recordio.cc:37
operations_research::sat::RecordWriter::WriteRecord
bool WriteRecord(const google::protobuf::MessageLite &record)
Definition
recordio.cc:42
operations_research::sat::RecordWriter::Close
void Close()
Definition
recordio.cc:47
operations_research::sat::RecordWriter::RecordWriter
RecordWriter(std::ostream *ostream)
Definition
recordio.cc:39
operations_research::sat
Definition
routing_sat.cc:45
operations_research
OR-Tools root namespace.
Definition
binary_indexed_tree.h:21
recordio.h
ortools
sat
recordio.cc
Generated by
1.15.0