1 #ifndef GENESIS_UTILS_IO_OUTPUT_TARGET_H_
2 #define GENESIS_UTILS_IO_OUTPUT_TARGET_H_
81 inline std::shared_ptr<BaseOutputTarget>
to_file(
82 std::string
const& file_name,
85 bool auto_adjust_filename =
true
92 if( auto_adjust_filename && ext !=
"gz" ) {
95 return std::make_shared<GzipOutputTarget>(
96 std::make_shared< FileOutputTarget >( fn, std::ios_base::out | std::ios_base::binary ),
102 if( auto_adjust_filename && ext ==
"gz" ) {
103 fn.erase( fn.size() - 3 );
105 return std::make_shared< FileOutputTarget >( fn );
117 inline std::shared_ptr<BaseOutputTarget>
to_file(
118 std::string
const& file_name,
119 std::ios_base::openmode mode = std::ios_base::out
121 return std::make_shared< FileOutputTarget >( file_name, mode );
133 std::string
const& file_name
152 std::string
const& file_name,
155 std::shared_ptr<ThreadPool> thread_pool =
nullptr,
156 bool auto_adjust_filename =
true
159 throw std::invalid_argument(
160 "Cannot use compression level kNoCompression with a gzip block output."
167 if( auto_adjust_filename && ext !=
"gz" ) {
172 return std::make_shared<GzipBlockOutputTarget>(
173 std::make_shared< FileOutputTarget >( fn, std::ios_base::out | std::ios_base::binary ),
187 std::string& target_string
189 return std::make_shared< StringOutputTarget >( target_string );
204 std::ostream& target_stream,
208 return std::make_shared<GzipOutputTarget>(
209 std::make_shared< StreamOutputTarget >( target_stream ),
213 return std::make_shared< StreamOutputTarget >( target_stream );
223 return std::make_shared< StreamOutputTarget >( std::cout );
233 return std::make_shared< StreamOutputTarget >( std::cerr );
239 #endif // include guard