soma-io  4.7.0
soma::PythonReader Class Reference

#include <soma-io/reader/pythonreader.h>

Classes

struct  Private
 

Public Types

typedef carto::GenericObject *(* Helper) (carto::GenericObject *, const std::string &, PythonReader &)
 
typedef std::map< std::string, HelperHelperSet
 

Public Member Functions

 PythonReader (const std::string &filename, const carto::SyntaxSet &rules=carto::SyntaxSet(), const HelperSet &helpers=HelperSet())
 
 PythonReader (const carto::SyntaxSet &rules=carto::SyntaxSet(), const HelperSet &helpers=HelperSet())
 
 PythonReader (carto::rc_ptr< DataSource > ds, const carto::SyntaxSet &rules=carto::SyntaxSet(), const HelperSet &helpers=HelperSet())
 PythonReader takes ownership of the DataSource. More...
 
virtual ~PythonReader ()
 
virtual carto::GenericObjectread ()
 
virtual void read (carto::GenericObject &)
 attemps to read an already allocated object, if file data matches the object type. More...
 
virtual void read (carto::Object &)
 
void readDictionary (carto::GenericObject &obj)
 reads an already allocated dictionary: just fills it (doesn't clear it) More...
 
void readDictionary2 (carto::GenericObject &obj)
 reads the remaining attributes of a string dictionary More...
 
void readIntDictionary2 (carto::TypedObject< carto::IntDictionary > &obj)
 reads the remaining attributes of an int dictionary More...
 
void open (const std::string &filename) __attribute__((__deprecated__("use attach() instead")))
 
void close ()
 
void attach (std::istream &s, int line_num=1)
 attach to an existing istream More...
 
void attach (carto::rc_ptr< DataSource > ds)
 
void attach (const std::string &filename)
 
carto::rc_ptr< DataSourcedataSource ()
 
virtual std::string name () const
 file name More...
 
int line () const
 
std::string lineString () const
 
bool operator! () const
 status of the stream More...
 
bool is_open () const
 is the stream open? More...
 
bool eof () const
 have we hit EOF? More...
 
const HelperSethelpers () const
 helper functions read basic data type More...
 
HelperSethelpers ()
 
const carto::SyntaxSetsyntaxes () const
 
carto::SyntaxSetsyntaxes ()
 
std::string readUntil (const std::string &s)
 read characters not in s More...
 
void skipUntil (const std::string &s)
 skip characters not in s More...
 
std::string readWhile (const std::string &s)
 read characters in s More...
 
unsigned skipWhile (const std::string &s)
 skip characters in s More...
 
carto::GenericObjectread (carto::GenericObject *parent, const std::string &semantic)
 
std::string readVariableName ()
 
bool readSyntax (std::string &syntax)
 attempts to read the syntax and general type of next element and fills syntax and type accordingly. More...
 
std::string readString (char separator, unsigned &charsread)
 

Static Public Member Functions

static carto::GenericObjectdictHelper (carto::GenericObject *, const std::string &, PythonReader &r)
 utility function, dictionary helper (can be useful in more specialized readers) More...
 
static carto::GenericObjectpropertySetHelper (carto::GenericObject *, const std::string &, PythonReader &r)
 
template<typename T >
static carto::GenericObjectgenericSequenceHelper (carto::GenericObject *, const std::string &, PythonReader &r)
 
template<typename T >
static carto::GenericObjectgenericDictHelper (carto::GenericObject *, const std::string &, PythonReader &r)
 

Protected Member Functions

void init (const HelperSet &helpers)
 

Detailed Description

Definition at line 50 of file pythonreader.h.

Member Typedef Documentation

◆ Helper

typedef carto::GenericObject*(* soma::PythonReader::Helper) (carto::GenericObject *, const std::string &, PythonReader &)

Definition at line 53 of file pythonreader.h.

◆ HelperSet

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

Definition at line 56 of file pythonreader.h.

Constructor & Destructor Documentation

◆ PythonReader() [1/3]

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

◆ PythonReader() [2/3]

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

◆ PythonReader() [3/3]

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

PythonReader takes ownership of the DataSource.

◆ ~PythonReader()

virtual soma::PythonReader::~PythonReader ( )
virtual

Member Function Documentation

◆ attach() [1/3]

void soma::PythonReader::attach ( std::istream &  s,
int  line_num = 1 
)

attach to an existing istream

◆ attach() [2/3]

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

◆ attach() [3/3]

void soma::PythonReader::attach ( const std::string &  filename)

◆ close()

void soma::PythonReader::close ( )

◆ dataSource()

carto::rc_ptr<DataSource> soma::PythonReader::dataSource ( )

◆ dictHelper()

static carto::GenericObject* soma::PythonReader::dictHelper ( carto::GenericObject ,
const std::string &  ,
PythonReader r 
)
static

utility function, dictionary helper (can be useful in more specialized readers)

◆ eof()

bool soma::PythonReader::eof ( ) const

have we hit EOF?

Referenced by genericDictHelper(), and genericSequenceHelper().

◆ genericDictHelper()

template<typename T >
carto::GenericObject * soma::PythonReader::genericDictHelper ( carto::GenericObject ,
const std::string &  ,
PythonReader r 
)
static

◆ genericSequenceHelper()

◆ helpers() [1/2]

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

helper functions read basic data type

◆ helpers() [2/2]

HelperSet& soma::PythonReader::helpers ( )

◆ init()

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

◆ is_open()

bool soma::PythonReader::is_open ( ) const

is the stream open?

◆ line()

int soma::PythonReader::line ( ) const

◆ lineString()

std::string soma::PythonReader::lineString ( ) const

Referenced by genericSequenceHelper().

◆ name()

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

file name

Referenced by genericSequenceHelper().

◆ open()

void soma::PythonReader::open ( const std::string &  filename)
Deprecated:
{obsolete: use attach() instead}

◆ operator!()

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

status of the stream

◆ propertySetHelper()

static carto::GenericObject* soma::PythonReader::propertySetHelper ( carto::GenericObject ,
const std::string &  ,
PythonReader r 
)
static

◆ read() [1/4]

virtual carto::GenericObject* soma::PythonReader::read ( )
virtual

◆ read() [2/4]

virtual void soma::PythonReader::read ( carto::GenericObject )
virtual

attemps to read an already allocated object, if file data matches the object type.

It currently only works for dictionaries

◆ read() [3/4]

virtual void soma::PythonReader::read ( carto::Object )
virtual

◆ read() [4/4]

carto::GenericObject* soma::PythonReader::read ( carto::GenericObject parent,
const std::string &  semantic 
)

◆ readDictionary()

void soma::PythonReader::readDictionary ( carto::GenericObject obj)

reads an already allocated dictionary: just fills it (doesn't clear it)

◆ readDictionary2()

void soma::PythonReader::readDictionary2 ( carto::GenericObject obj)

reads the remaining attributes of a string dictionary

Referenced by genericDictHelper().

◆ readIntDictionary2()

void soma::PythonReader::readIntDictionary2 ( carto::TypedObject< carto::IntDictionary > &  obj)

reads the remaining attributes of an int dictionary

◆ readString()

std::string soma::PythonReader::readString ( char  separator,
unsigned &  charsread 
)

◆ readSyntax()

bool soma::PythonReader::readSyntax ( std::string &  syntax)

attempts to read the syntax and general type of next element and fills syntax and type accordingly.

type will be "dictionary" or "list".

Returns
false in case of failure (no syntax or not able to read it)

◆ readUntil()

std::string soma::PythonReader::readUntil ( const std::string &  s)

read characters not in s

Parameters
scontinue while characters outside s
Returns
accepted characters

◆ readVariableName()

std::string soma::PythonReader::readVariableName ( )

◆ readWhile()

std::string soma::PythonReader::readWhile ( const std::string &  s)

read characters in s

Parameters
scontinue while characters in s
Returns
accepted characters

◆ skipUntil()

void soma::PythonReader::skipUntil ( const std::string &  s)

skip characters not in s

Parameters
scontinue while characters outside s

◆ skipWhile()

unsigned soma::PythonReader::skipWhile ( const std::string &  s)

skip characters in s

Parameters
scontinue while characters in s
Returns
number of characters read

Referenced by genericDictHelper(), and genericSequenceHelper().

◆ syntaxes() [1/2]

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

◆ syntaxes() [2/2]

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

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