STIR  6.3.0
write_to_file.h
Go to the documentation of this file.
1 //
2 //
3 #ifndef __stir_IO_write_to_file_H__
4 #define __stir_IO_write_to_file_H__
5 /*
6  Copyright (C) 2015, University College London
7  This file is part of STIR.
8 
9  SPDX-License-Identifier: Apache-2.0
10 
11  See STIR/LICENSE.txt for details
12 */
23 #include "stir/Succeeded.h"
24 #include "stir/error.h"
25 
26 START_NAMESPACE_STIR
27 
29 
44 template <class DataT>
45 inline std::string
46 write_to_file(const std::string& filename, const DataT& data)
47 {
48  std::string filename_used(filename);
49 
50  if (OutputFileFormat<typename DataT::hierarchy_base_type>::default_sptr()->write_to_file(filename_used, data) != Succeeded::yes)
51  {
52  error("Error writing data to file '" + filename + "'");
53  }
54  return filename_used;
55 }
56 
57 END_NAMESPACE_STIR
58 
59 #endif
Declaration of class stir::Succeeded.
Declaration of stir::error()
Declaration of class stir::OutputFileFormat.
std::string write_to_file(const std::string &filename, const DataT &data)
Function that writes data to file using the default OutputFileFormat.
Definition: write_to_file.h:46
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition: error.cxx:42
Base class for classes that create output files.
Definition: OutputFileFormat.h:55