soma-io 6.0.6
soma::Writer< T > Class Template Reference

Generic writer for every format of Aims object. More...

#include <soma-io/io/writer.h>

Inheritance diagram for soma::Writer< T >:
Collaboration diagram for soma::Writer< T >:

Public Member Functions

 Writer ()
 
 Writer (carto::rc_ptr< DataSource > ds)
 
 Writer (const std::string &filename)
 
 Writer (std::ostream &stream)
 
virtual ~Writer ()
 
virtual bool write (const T &obj, carto::Object options=carto::none(), int passbegin=1, int passend=4)
 Finds the correct format and writes the object.
 
virtual std::string writtenObjectType () const
 
bool write (const carto::Object &obj, carto::Object options, int passbegin, int passend)
 
- Public Member Functions inherited from soma::GenericWriter
 GenericWriter ()
 
 GenericWriter (carto::rc_ptr< DataSource > ds)
 
 GenericWriter (const std::string &filename)
 
 GenericWriter (std::ostream &stream)
 
virtual ~GenericWriter ()
 
template<typename T>
bool write (const T &obj, carto::Object options=carto::none())
 Finds the correct format and writes the object.
 
const carto::rc_ptr< DataSourcedataSource () const
 
carto::rc_ptr< DataSourcedataSource ()
 
void attach (carto::rc_ptr< DataSource > ds)
 
void attach (const std::string &filename)
 
void attach (std::ostream &stream)
 
void flush ()
 flush the writing DataSource (if still open)
 
void close ()
 close the writing DataSource
 
template<>
bool write (const carto::Object &obj, carto::Object options)
 

Additional Inherited Members

- Protected Attributes inherited from soma::GenericWriter
carto::rc_ptr< DataSourceInfo_datasourceinfo
 

Detailed Description

template<class T>
class soma::Writer< T >

Generic writer for every format of Aims object.

The Writer classes are built on the same model as the Reader classes and share the same FormatDictionary with them to store all known file formats.

See IO system general explanations on how to use Reader and Writer classes.

See also
FormatDictionary Reader

Definition at line 102 of file writer.h.

Constructor & Destructor Documentation

◆ Writer() [1/4]

template<typename T>
soma::Writer< T >::Writer ( )

Definition at line 74 of file writer_d.h.

References soma::GenericWriter::GenericWriter(), and Writer().

Referenced by write(), Writer(), Writer(), Writer(), and Writer().

◆ Writer() [2/4]

template<typename T>
soma::Writer< T >::Writer ( carto::rc_ptr< DataSource > ds)

Definition at line 80 of file writer_d.h.

References soma::GenericWriter::GenericWriter(), and Writer().

◆ Writer() [3/4]

template<typename T>
soma::Writer< T >::Writer ( const std::string & filename)

Definition at line 86 of file writer_d.h.

References soma::GenericWriter::GenericWriter(), and Writer().

◆ Writer() [4/4]

template<typename T>
soma::Writer< T >::Writer ( std::ostream & stream)

Definition at line 92 of file writer_d.h.

References soma::GenericWriter::GenericWriter(), and Writer().

◆ ~Writer()

template<typename T>
soma::Writer< T >::~Writer ( )
virtual

Definition at line 98 of file writer_d.h.

References ~Writer().

Referenced by ~Writer().

Member Function Documentation

◆ write() [1/2]

bool soma::Writer< carto::Object >::write ( const carto::Object & obj,
carto::Object options,
int passbegin,
int passend )
inline

Definition at line 137 of file writer.h.

References soma::GenericWriter::dataSource(), write(), and Writer().

◆ write() [2/2]

template<class T>
bool soma::Writer< T >::write ( const T & obj,
carto::Object options = carto::none(),
int passbegin = 1,
int passend = 4 )
virtual

Finds the correct format and writes the object.

Options can be passed to specify some writing parameters. The most important is the format ("format" property): if it is specified, this format is tried first, so you can use it to force the format, otherwise it will be determined from the filename extension (if available). If no extension and no format are given, the first working format will be used. It is possible to specify which passes to process through passbegin and passend.

  • pass 1 : format hint
  • pass 2 : extension
  • pass 3 : empty extension
  • pass 4 : all writers

Definition at line 121 of file writer_d.h.

References soma::GenericWriter::_datasourceinfo, carto::FileUtil::extension(), carto::rc_ptr< typename T >::get(), carto::io_error::keepExceptionPriority(), carto::io_error::launchExcept(), localMsg, carto::DataTypeCode< class T >::name(), carto::toString(), carto::Object::value(), soma::FormatWriter< T >::write(), write(), soma::FormatDictionary< T >::writeExtensions(), and soma::FormatDictionary< T >::writeFormat().

Referenced by soma::GenericWriter::write(), write(), and write().

◆ writtenObjectType()

template<class T>
std::string soma::Writer< T >::writtenObjectType ( ) const
virtual

Implements soma::GenericWriter.

Definition at line 104 of file writer_d.h.

References carto::DataTypeCode< class T >::name(), and writtenObjectType().

Referenced by writtenObjectType().


The documentation for this class was generated from the following files: