1#ifndef OSMIUM_IO_FILE_HPP
2#define OSMIUM_IO_FILE_HPP
55 inline std::vector<std::string> split(
const std::string& in,
const char delim) {
56 std::vector<std::string> result;
57 std::stringstream ss(in);
59 while (std::getline(ss, item, delim)) {
60 result.push_back(item);
114 if (protocol ==
"http" || protocol ==
"https") {
152 std::vector<std::string> options = detail::split(
format,
',');
156 if (!options.empty() && options[0].find_first_of(
'=') == std::string::npos) {
158 options.erase(options.begin());
161 for (
auto& option : options) {
162 const size_t pos = option.find_first_of(
'=');
163 if (pos == std::string::npos) {
166 const std::string value{option.substr(pos + 1)};
172 if (get(
"history") ==
"true") {
174 }
else if (get(
"history") ==
"false") {
180 std::vector<std::string> suffixes = detail::split(name,
'.');
182 if (suffixes.empty()) {
188 if (suffixes.back() ==
"gz") {
191 }
else if (suffixes.back() ==
"bz2") {
196 if (suffixes.empty()) {
202 if (suffixes.back() ==
"pbf") {
205 }
else if (suffixes.back() ==
"xml") {
208 }
else if (suffixes.back() ==
"opl") {
211 }
else if (suffixes.back() ==
"json") {
214 }
else if (suffixes.back() ==
"o5m") {
217 }
else if (suffixes.back() ==
"o5c") {
220 set(
"o5c_change_format",
true);
222 }
else if (suffixes.back() ==
"debug") {
225 }
else if (suffixes.back() ==
"blackhole") {
228 }
else if (suffixes.back() ==
"ids") {
233 if (suffixes.empty()) {
237 if (suffixes.back() ==
"osm") {
242 }
else if (suffixes.back() ==
"osh") {
248 }
else if (suffixes.back() ==
"osc") {
253 set(
"xml_change_format",
true);
266 std::string msg{
"Could not detect file format"};
268 msg +=
" from format string '";
273 msg +=
" for stdin/stdout";
275 msg +=
" for filename '";
bool m_has_multiple_object_versions
Definition: file.hpp:87
std::string m_filename
Definition: file.hpp:76
size_t buffer_size() const noexcept
Definition: file.hpp:147
File(std::string filename="", std::string format="")
Definition: file.hpp:103
bool has_multiple_object_versions() const noexcept
Definition: file.hpp:303
File & set_compression(file_compression compression) noexcept
Definition: file.hpp:298
size_t m_buffer_size
Definition: file.hpp:79
file_compression m_file_compression
Definition: file.hpp:85
const File & check() const
Definition: file.hpp:264
File & set_has_multiple_object_versions(bool value) noexcept
Definition: file.hpp:307
File & filename(const std::string &filename)
Definition: file.hpp:312
file_format m_file_format
Definition: file.hpp:83
File & set_format(file_format format) noexcept
Definition: file.hpp:289
std::string m_format_string
Definition: file.hpp:81
File(const char *buffer, size_t size, const std::string &format="")
Definition: file.hpp:134
void detect_format_from_suffix(const std::string &name)
Definition: file.hpp:179
const std::string & filename() const noexcept
Definition: file.hpp:321
const char * m_buffer
Definition: file.hpp:78
void parse_format(const std::string &format)
Definition: file.hpp:151
file_compression compression() const noexcept
Definition: file.hpp:294
file_format format() const noexcept
Definition: file.hpp:285
const char * buffer() const noexcept
Definition: file.hpp:143
Definition: options.hpp:58
file_format
Definition: file_format.hpp:42
file_compression
Definition: file_compression.hpp:42
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
Definition: location.hpp:555