1 #ifndef OSMIUM_IO_FILE_FORMAT_HPP
2 #define OSMIUM_IO_FILE_FORMAT_HPP
3 
4 /*
5 
6 This file is part of Osmium (https://osmcode.org/libosmium).
7 
8 Copyright 2013-2021 Jochen Topf <jochen@topf.org> and others (see README).
9 
10 Boost Software License - Version 1.0 - August 17th, 2003
11 
12 Permission is hereby granted, free of charge, to any person or organization
13 obtaining a copy of the software and accompanying documentation covered by
14 this license (the "Software") to use, reproduce, display, distribute,
15 execute, and transmit the Software, and to prepare derivative works of the
16 Software, and to permit third-parties to whom the Software is furnished to
17 do so, all subject to the following:
18 
19 The copyright notices in the Software and this entire statement, including
20 the above license grant, this restriction and the following disclaimer,
21 must be included in all copies of the Software, in whole or in part, and
22 all derivative works of the Software, unless such copies or derivative
23 works are solely in the form of machine-executable object code generated by
24 a source language processor.
25 
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS IN THE SOFTWARE.
33 
34 */
35 
36 #include <iosfwd>
37 
38 namespace osmium {
39 
40     namespace io {
41 
42         enum class file_format {
43             unknown   = 0,
44             xml       = 1,
45             pbf       = 2,
46             opl       = 3,
47             json      = 4,
48             o5m       = 5,
49             debug     = 6,
50             blackhole = 7,
51             ids       = 8,
52             last      = 8 // must have the same value as the last real value
53         };
54 
55         enum class read_meta {
56             no  = 0,
57             yes = 1
58         };
59 
60         enum class buffers_type {
61             any    = 0,
62             single = 1
63         };
64 
as_string(const file_format format)65         inline const char* as_string(const file_format format) noexcept {
66             switch (format) {
67                 case file_format::xml:
68                     return "XML";
69                 case file_format::pbf:
70                     return "PBF";
71                 case file_format::opl:
72                     return "OPL";
73                 case file_format::json:
74                     return "JSON";
75                 case file_format::o5m:
76                     return "O5M";
77                 case file_format::debug:
78                     return "DEBUG";
79                 case file_format::blackhole:
80                     return "BLACKHOLE";
81                 case file_format::ids:
82                     return "IDS";
83                 default: // file_format::unknown
84                     break;
85             }
86             return "unknown";
87         }
88 
89         template <typename TChar, typename TTraits>
operator <<(std::basic_ostream<TChar,TTraits> & out,const file_format format)90         inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const file_format format) {
91             return out << as_string(format);
92         }
93 
94     } // namespace io
95 
96 } // namespace osmium
97 
98 #endif // OSMIUM_IO_FILE_FORMAT_HPP
99