soma-io 6.0.6
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, Helper > HelperSet
 

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.
 
virtual ~PythonReader ()
 
virtual carto::GenericObjectread ()
 
virtual void read (carto::GenericObject &)
 attempts to read an already allocated object, if file data matches the object type.
 
virtual void read (carto::Object &)
 
void readDictionary (carto::GenericObject &obj)
 reads an already allocated dictionary: just fills it (doesn't clear it)
 
void readDictionary2 (carto::GenericObject &obj)
 reads the remaining attributes of a string dictionary
 
void readIntDictionary2 (carto::TypedObject< carto::IntDictionary > &obj)
 reads the remaining attributes of an int dictionary
 
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
 
void attach (carto::rc_ptr< DataSource > ds)
 
void attach (const std::string &filename)
 
carto::rc_ptr< DataSourcedataSource ()
 
virtual std::string name () const
 file name
 
int line () const
 
std::string lineString () const
 
bool operator! () const
 status of the stream
 
bool is_open () const
 is the stream open?
 
bool eof () const
 have we hit EOF?
 
const HelperSethelpers () const
 helper functions read basic data type
 
HelperSethelpers ()
 
const carto::SyntaxSetsyntaxes () const
 
carto::SyntaxSetsyntaxes ()
 
std::string readUntil (const std::string &s)
 read characters not in s
 
void skipUntil (const std::string &s)
 skip characters not in s
 
std::string readWhile (const std::string &s)
 read characters in s
 
unsigned skipWhile (const std::string &s)
 skip characters in s
 
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.
 
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)
 
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() )

References helpers().

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

References helpers().

◆ ~PythonReader()

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

Member Function Documentation

◆ attach() [1/3]

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

◆ attach() [2/3]

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

◆ attach() [3/3]

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

attach to an existing istream

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

References PythonReader().

◆ eof()

bool soma::PythonReader::eof ( ) const

have we hit EOF?

Referenced by genericDictHelper(), and genericSequenceHelper().

◆ genericDictHelper()

◆ genericSequenceHelper()

◆ helpers() [1/2]

HelperSet & soma::PythonReader::helpers ( )

◆ helpers() [2/2]

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

helper functions read basic data type

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

◆ init()

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

References helpers().

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

◆ 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

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

It currently only works for dictionaries

◆ read() [3/4]

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

◆ read() [4/4]

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

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

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

◆ syntaxes() [2/2]

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

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