38 #ifndef OME_FILES_FORMATHANDLER_H 39 #define OME_FILES_FORMATHANDLER_H 47 #include <boost/filesystem/path.hpp> 48 #include <boost/format.hpp> 49 #include <boost/optional.hpp> 50 #include <boost/version.hpp> 99 isThisType(
const boost::filesystem::path& name,
100 bool open =
true)
const = 0;
126 const std::vector<boost::filesystem::path>&
135 const std::vector<boost::filesystem::path>&
147 setId(
const boost::filesystem::path&
id) = 0;
170 close(
bool fileOnly =
false) = 0;
184 const boost::filesystem::path& suffix)
188 boost::filesystem::path filename(name);
189 #if !defined(BOOST_VERSION) || BOOST_VERSION >= 105000 // Boost >= 1.50 190 boost::filesystem::path ext;
191 ext.replace_extension(suffix);
192 #else // Boost < 1.50 194 boost::filesystem::path ext(suffix);
195 std::string suffixString(ext.string());
196 if (!suffixString.empty() && suffixString[0] !=
'.')
197 ext = boost::filesystem::path(std::string(
".") + suffixString);
198 #endif // Boost version 202 boost::filesystem::path filename_ext = filename.extension();
203 boost::filesystem::path current_ext = ext.extension();
204 filename.replace_extension();
205 ext.replace_extension();
207 if (filename_ext.empty() && current_ext.empty())
209 else if (!filename_ext.empty() && !current_ext.empty() &&
210 filename_ext == current_ext)
231 const std::vector<boost::filesystem::path>& suffixes)
233 for (
const auto& suffix : suffixes)
253 const std::vector<boost::filesystem::path>& suffixes,
254 const std::vector<boost::filesystem::path>& compression_suffixes)
259 for (
const auto& suffix : suffixes)
261 for (
const auto& compsuffix : compression_suffixes)
263 boost::filesystem::path fullsuffix(suffix);
264 fullsuffix += boost::filesystem::path(
".");
265 fullsuffix += compsuffix;
286 assertId(
const boost::optional<boost::filesystem::path>&
id,
291 throw std::logic_error(
"Current file should not be null; call setId() first");
293 else if (
id && !notNull)
295 boost::format fmt(
"Current file should be null, but is '%1%'; call close() first");
297 throw std::logic_error(fmt.str());
306 #endif // OME_FILES_FORMATHANDLER_H
Open Microscopy Environment C++.