soma-io  5.1.2
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. More...
 
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. More...
 
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) More...
 
void close ()
 close the writing DataSource More...
 
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 73 of file writer_d.h.

◆ Writer() [2/4]

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

Definition at line 79 of file writer_d.h.

◆ Writer() [3/4]

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

Definition at line 85 of file writer_d.h.

◆ Writer() [4/4]

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

Definition at line 91 of file writer_d.h.

◆ ~Writer()

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

Definition at line 97 of file writer_d.h.

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::Writer< T >::write().

◆ 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 120 of file writer_d.h.

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

Referenced by soma::Writer< T >::write(), and soma::GenericWriter::write().

◆ writtenObjectType()

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

Implements soma::GenericWriter.

Definition at line 103 of file writer_d.h.

References carto::DataTypeCode< class >::name().


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