soma-io  5.0.5
soma::PythonWriter Class Reference

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

Collaboration diagram for soma::PythonWriter:

Public Types

typedef void(* Helper) (const carto::GenericObject &, PythonWriter &w, int indent, bool writeInternals)
 
typedef std::map< std::string, HelperHelperSet
 
typedef void(* CatchFunction) (PythonWriter &, std::exception &, const carto::Object &)
 

Public Member Functions

 PythonWriter (const std::string &filename, const carto::SyntaxSet &rules=carto::SyntaxSet(), const HelperSet &helpers=HelperSet())
 
 PythonWriter (const carto::SyntaxSet &rules=carto::SyntaxSet(), const HelperSet &helpers=HelperSet())
 
 PythonWriter (carto::rc_ptr< DataSource > ds, const carto::SyntaxSet &rules=carto::SyntaxSet(), const HelperSet &helpers=HelperSet())
 PythonWriter takes ownership of the DataSource. More...
 
virtual ~PythonWriter ()
 
void open (const std::string &filename)
 
void attach (std::ostream &s)
 attach to an existing (and open) stream More...
 
void attach (carto::rc_ptr< DataSource > ds)
 
void close ()
 
virtual std::string name () const
 
bool operator! () const
 
bool is_open () const
 
carto::rc_ptr< DataSourcedataSource ()
 
const HelperSethelpers () const
 helper functions read basic data type More...
 
HelperSethelpers ()
 
const carto::SyntaxSetsyntaxes () const
 
carto::SyntaxSetsyntaxes ()
 
void write (const carto::GenericObject &object, bool writeInternals=false, bool writevariable=true)
 Writes a generic object to stream. More...
 
void write (const carto::Object &object, bool writeInternals=false, bool writevariable=true)
 
void write (const carto::GenericObject &object, int indent, const std::string &syntax="", const std::string &semantic="", bool writeInternals=false)
 Writes an element according to the syntax. More...
 
void write (const carto::Object &object, int indent, const std::string &syntax="", const std::string &semantic="", bool writeInternals=false)
 Writes an element according to the syntax. More...
 
bool isInternal (const std::string &syntax, const std::string &semantic)
 
void setSingleLineMode (bool x)
 
bool singleLine () const
 
void setCatchFunction (CatchFunction f)
 if set, the catch function is used instead of throwing the regular exception during writing More...
 
char quoteCharacter () const
 
void setQuoteCharacter (char q)
 
std::string noneString () const
 
void setNoneString (const std::string &none)
 
void writeString (DataSource &, std::string)
 utility function More...
 

Static Public Member Functions

template<typename T >
static void genericSequenceHelper (const carto::GenericObject &obj, PythonWriter &w, int ind, bool writeInternals)
 

Protected Member Functions

void init (const HelperSet &helpers)
 

Protected Attributes

carto::SyntaxSet _rules
 
carto::rc_ptr< DataSource_datasource
 
HelperSet _helpers
 
bool _singleLine
 
CatchFunction _catchFunction
 
char _quoteChar
 
std::string _noneString
 

Detailed Description

Definition at line 56 of file pythonwriter.h.

Member Typedef Documentation

◆ CatchFunction

typedef void(* soma::PythonWriter::CatchFunction) (PythonWriter &, std::exception &, const carto::Object &)

Definition at line 62 of file pythonwriter.h.

◆ Helper

typedef void(* soma::PythonWriter::Helper) (const carto::GenericObject &, PythonWriter &w, int indent, bool writeInternals)

Definition at line 59 of file pythonwriter.h.

◆ HelperSet

typedef std::map<std::string, Helper> soma::PythonWriter::HelperSet

Definition at line 61 of file pythonwriter.h.

Constructor & Destructor Documentation

◆ PythonWriter() [1/3]

soma::PythonWriter::PythonWriter ( const std::string &  filename,
const carto::SyntaxSet rules = carto::SyntaxSet(),
const HelperSet helpers = HelperSet() 
)

◆ PythonWriter() [2/3]

soma::PythonWriter::PythonWriter ( const carto::SyntaxSet rules = carto::SyntaxSet(),
const HelperSet helpers = HelperSet() 
)

◆ PythonWriter() [3/3]

soma::PythonWriter::PythonWriter ( carto::rc_ptr< DataSource ds,
const carto::SyntaxSet rules = carto::SyntaxSet(),
const HelperSet helpers = HelperSet() 
)

PythonWriter takes ownership of the DataSource.

◆ ~PythonWriter()

virtual soma::PythonWriter::~PythonWriter ( )
virtual

Member Function Documentation

◆ attach() [1/2]

void soma::PythonWriter::attach ( std::ostream &  s)

attach to an existing (and open) stream

◆ attach() [2/2]

void soma::PythonWriter::attach ( carto::rc_ptr< DataSource ds)

◆ close()

void soma::PythonWriter::close ( )

◆ dataSource()

carto::rc_ptr<DataSource> soma::PythonWriter::dataSource ( )
inline

Definition at line 84 of file pythonwriter.h.

Referenced by genericSequenceHelper().

◆ genericSequenceHelper()

template<typename T >
void soma::PythonWriter::genericSequenceHelper ( const carto::GenericObject obj,
soma::PythonWriter w,
int  ind,
bool  writeInternals 
)
static

◆ helpers() [1/2]

const HelperSet& soma::PythonWriter::helpers ( ) const

helper functions read basic data type

◆ helpers() [2/2]

HelperSet& soma::PythonWriter::helpers ( )

◆ init()

void soma::PythonWriter::init ( const HelperSet helpers)
protected

◆ is_open()

bool soma::PythonWriter::is_open ( ) const

◆ isInternal()

bool soma::PythonWriter::isInternal ( const std::string &  syntax,
const std::string &  semantic 
)

◆ name()

virtual std::string soma::PythonWriter::name ( ) const
virtual

◆ noneString()

std::string soma::PythonWriter::noneString ( ) const
inline

Definition at line 118 of file pythonwriter.h.

◆ open()

void soma::PythonWriter::open ( const std::string &  filename)

◆ operator!()

bool soma::PythonWriter::operator! ( ) const

◆ quoteCharacter()

char soma::PythonWriter::quoteCharacter ( ) const
inline

Definition at line 116 of file pythonwriter.h.

◆ setCatchFunction()

void soma::PythonWriter::setCatchFunction ( CatchFunction  f)

if set, the catch function is used instead of throwing the regular exception during writing

◆ setNoneString()

void soma::PythonWriter::setNoneString ( const std::string &  none)
inline

Definition at line 119 of file pythonwriter.h.

References carto::none().

◆ setQuoteCharacter()

void soma::PythonWriter::setQuoteCharacter ( char  q)
inline

Definition at line 117 of file pythonwriter.h.

◆ setSingleLineMode()

void soma::PythonWriter::setSingleLineMode ( bool  x)
inline

Definition at line 111 of file pythonwriter.h.

◆ singleLine()

bool soma::PythonWriter::singleLine ( ) const
inline

Definition at line 112 of file pythonwriter.h.

◆ syntaxes() [1/2]

const carto::SyntaxSet& soma::PythonWriter::syntaxes ( ) const

◆ syntaxes() [2/2]

carto::SyntaxSet& soma::PythonWriter::syntaxes ( )

◆ write() [1/4]

void soma::PythonWriter::write ( const carto::GenericObject object,
bool  writeInternals = false,
bool  writevariable = true 
)

Writes a generic object to stream.

◆ write() [2/4]

void soma::PythonWriter::write ( const carto::Object object,
bool  writeInternals = false,
bool  writevariable = true 
)

◆ write() [3/4]

void soma::PythonWriter::write ( const carto::GenericObject object,
int  indent,
const std::string &  syntax = "",
const std::string &  semantic = "",
bool  writeInternals = false 
)

Writes an element according to the syntax.

◆ write() [4/4]

void soma::PythonWriter::write ( const carto::Object object,
int  indent,
const std::string &  syntax = "",
const std::string &  semantic = "",
bool  writeInternals = false 
)

Writes an element according to the syntax.

◆ writeString()

void soma::PythonWriter::writeString ( DataSource ,
std::string   
)

utility function

Member Data Documentation

◆ _catchFunction

CatchFunction soma::PythonWriter::_catchFunction
protected

Definition at line 136 of file pythonwriter.h.

◆ _datasource

carto::rc_ptr<DataSource> soma::PythonWriter::_datasource
protected

Definition at line 133 of file pythonwriter.h.

◆ _helpers

HelperSet soma::PythonWriter::_helpers
protected

Definition at line 134 of file pythonwriter.h.

◆ _noneString

std::string soma::PythonWriter::_noneString
protected

Definition at line 138 of file pythonwriter.h.

◆ _quoteChar

char soma::PythonWriter::_quoteChar
protected

Definition at line 137 of file pythonwriter.h.

◆ _rules

carto::SyntaxSet soma::PythonWriter::_rules
protected

Definition at line 132 of file pythonwriter.h.

◆ _singleLine

bool soma::PythonWriter::_singleLine
protected

Definition at line 135 of file pythonwriter.h.


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