soma-io 6.0.6
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, Helper > HelperSet
 
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.
 
virtual ~PythonWriter ()
 
void open (const std::string &filename)
 
void attach (std::ostream &s)
 attach to an existing (and open) stream
 
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
 
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.
 
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.
 
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.
 
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
 
char quoteCharacter () const
 
void setQuoteCharacter (char q)
 
std::string noneString () const
 
void setNoneString (const std::string &none)
 
void writeString (DataSource &, std::string)
 utility function
 

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() )

References helpers().

Referenced by writeString().

◆ PythonWriter() [2/3]

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

References helpers().

◆ 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.

References helpers().

◆ ~PythonWriter()

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

Member Function Documentation

◆ attach() [1/2]

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

◆ attach() [2/2]

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

attach to an existing (and open) stream

◆ close()

void soma::PythonWriter::close ( )

◆ dataSource()

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

Definition at line 84 of file pythonwriter.h.

References _datasource.

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]

HelperSet & soma::PythonWriter::helpers ( )

◆ helpers() [2/2]

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

helper functions read basic data type

Referenced by init(), PythonWriter(), PythonWriter(), and PythonWriter().

◆ init()

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

References helpers().

◆ 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.

References _noneString.

◆ 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.

References _quoteChar.

◆ 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 _noneString.

◆ setQuoteCharacter()

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

Definition at line 117 of file pythonwriter.h.

References _quoteChar.

◆ setSingleLineMode()

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

Definition at line 111 of file pythonwriter.h.

References _singleLine.

◆ singleLine()

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

Definition at line 112 of file pythonwriter.h.

References _singleLine.

◆ syntaxes() [1/2]

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

◆ syntaxes() [2/2]

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

◆ 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::GenericObject & object,
int indent,
const std::string & syntax = "",
const std::string & semantic = "",
bool writeInternals = false )

Writes an element according to the syntax.

◆ write() [3/4]

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

◆ 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

References genericSequenceHelper(), and PythonWriter().

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.

Referenced by dataSource().

◆ _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.

Referenced by noneString(), and setNoneString().

◆ _quoteChar

char soma::PythonWriter::_quoteChar
protected

Definition at line 137 of file pythonwriter.h.

Referenced by quoteCharacter(), and setQuoteCharacter().

◆ _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.

Referenced by setSingleLineMode(), and singleLine().


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