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> 100 isThisType(
const boost::filesystem::path& name,
101 bool open =
true)
const = 0;
127 const std::vector<boost::filesystem::path>&
136 const std::vector<boost::filesystem::path>&
148 setId(
const boost::filesystem::path&
id) = 0;
171 close(
bool fileOnly =
false) = 0;
185 const boost::filesystem::path& suffix)
189 boost::filesystem::path filename(name);
190 #if !defined(BOOST_VERSION) || BOOST_VERSION >= 105000 // Boost >= 1.50 191 boost::filesystem::path ext;
192 ext.replace_extension(suffix);
193 #else // Boost < 1.50 195 boost::filesystem::path ext(suffix);
196 std::string suffixString(ext.string());
197 if (!suffixString.empty() && suffixString[0] !=
'.')
198 ext = boost::filesystem::path(std::string(
".") + suffixString);
199 #endif // Boost version 203 boost::filesystem::path filename_ext = filename.extension();
204 boost::filesystem::path current_ext = ext.extension();
205 filename.replace_extension();
206 ext.replace_extension();
208 if (filename_ext.empty() && current_ext.empty())
210 else if (!filename_ext.empty() && !current_ext.empty() &&
211 filename_ext == current_ext)
232 const std::vector<boost::filesystem::path>& suffixes)
234 for (
const auto& suffix : suffixes)
254 const std::vector<boost::filesystem::path>& suffixes,
255 const std::vector<boost::filesystem::path>& compression_suffixes)
260 for (
const auto& suffix : suffixes)
262 for (
const auto& compsuffix : compression_suffixes)
264 boost::filesystem::path fullsuffix(suffix);
265 fullsuffix += boost::filesystem::path(
".");
266 fullsuffix += compsuffix;
287 assertId(
const boost::optional<boost::filesystem::path>&
id,
292 throw std::logic_error(
"Current file should not be null; call setId() first");
294 else if (
id && !notNull)
296 boost::format fmt(
"Current file should be null, but is '%1%'; call close() first");
298 throw std::logic_error(fmt.str());
307 #endif // OME_FILES_FORMATHANDLER_H
Open Microscopy Environment C++.