cartographer
io
file_writer.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2016 The Cartographer Authors
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#include "
cartographer/io/file_writer.h
"
18
19
namespace
cartographer
{
20
namespace
io {
21
22
StreamFileWriter::StreamFileWriter
(
const
std::string& filename)
23
: filename_(filename), out_(filename, std::ios::out | std::ios::binary) {}
24
25
StreamFileWriter::~StreamFileWriter
() {}
26
27
bool
StreamFileWriter::Write
(
const
char
*
const
data,
const
size_t
len) {
28
if
(
out_
.bad()) {
29
return
false
;
30
}
31
out_
.write(data, len);
32
return
!
out_
.bad();
33
}
34
35
bool
StreamFileWriter::Close
() {
36
if
(
out_
.bad()) {
37
return
false
;
38
}
39
out_
.close();
40
return
!
out_
.bad();
41
}
42
43
bool
StreamFileWriter::WriteHeader
(
const
char
*
const
data,
const
size_t
len) {
44
if
(
out_
.bad()) {
45
return
false
;
46
}
47
out_
.flush();
48
out_
.seekp(0);
49
return
Write
(data, len);
50
}
51
52
std::string
StreamFileWriter::GetFilename
() {
return
filename_
; }
53
54
}
// namespace io
55
}
// namespace cartographer
file_writer.h
cartographer::io::StreamFileWriter::~StreamFileWriter
~StreamFileWriter() override
Definition:
file_writer.cc:25
cartographer::io::StreamFileWriter::out_
std::ofstream out_
Definition:
file_writer.h:62
cartographer::io::StreamFileWriter::StreamFileWriter
StreamFileWriter(const std::string &filename)
Definition:
file_writer.cc:22
cartographer::io::StreamFileWriter::Write
bool Write(const char *data, size_t len) override
Definition:
file_writer.cc:27
cartographer
Definition:
map_builder_stub.cc:31
cartographer::io::StreamFileWriter::filename_
const std::string filename_
Definition:
file_writer.h:61
cartographer::io::StreamFileWriter::GetFilename
std::string GetFilename() override
Definition:
file_writer.cc:52
cartographer::io::StreamFileWriter::WriteHeader
bool WriteHeader(const char *data, size_t len) override
Definition:
file_writer.cc:43
cartographer::io::StreamFileWriter::Close
bool Close() override
Definition:
file_writer.cc:35
cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58