34 #ifndef SOMAIO_WRITER_PYTHONWRITER_D_H
35 #define SOMAIO_WRITER_PYTHONWRITER_D_H
52 const T & x = obj.GenericObject::value<T>();
63 const char & x = obj.GenericObject::value<
char>();
74 const unsigned char & x = obj.GenericObject::value<
unsigned char>();
147 bool writeInternals )
152 const std::map<T, carto::Object>
153 & x = obj.GenericObject::value<std::map<T, carto::Object> >();
154 typename std::map<T, carto::Object>::const_iterator im, em = x.end();
155 bool first =
true, hassyntax =
false;
156 std::string ind, ind2;
164 for( i=0; i<indent-1; ++i )
191 synt = sx->GenericObject::value<std::string>();
207 for( im=x.begin(); im!=em; ++im )
219 w.
write( key, indent,
"",
"", writeInternals );
221 w.
write( im->second, indent,
"",
"", writeInternals );
231 int indent,
bool writeInternals )
240 bool first =
true, hassyntax =
false;
241 std::string ind, ind2;
249 for( i=0; i<indent-1; ++i )
275 synt = sx->GenericObject::value<std::string>();
293 while( im->isValid() )
298 if( ( writeInternals || !w.
isInternal(
"", key ) )
299 && ( key !=
"__syntax__" || !hassyntax ) )
311 w.
write( im->currentValue(), indent,
"", key, writeInternals );
316 long key = im->intKey();
327 w.
write( *im->currentValue(), indent,
"",
"", writeInternals );
339 bool writeInternals )
342 const std::map<carto::Object, carto::Object> & x
343 = obj.
value<std::map<carto::Object, carto::Object> >();
344 std::map<carto::Object, carto::Object>::const_iterator im, em = x.end();
345 bool first =
true, hassyntax =
false;
346 std::string ind, ind2;
354 for( i=0; i<indent-1; ++i )
380 synt = sx->GenericObject::value<std::string>();
396 for( im=x.begin(); im!=em; ++im )
406 w.
write( im->first, indent,
"",
"", writeInternals );
408 w.
write( im->second, indent,
"",
"", writeInternals );
418 int indent,
bool writeInternals )
433 w.
write( it->currentValue(), indent,
"",
"", writeInternals );
446 bool writeInternals )
466 de = ix->currentValue();
467 genericHelper<typename T::value_type>( *de, w, ind, writeInternals );
virtual bool getProperty(const std::string &key, Object &value) const=0
virtual Object objectIterator() const=0
Object reference(Object &value)
virtual double getScalar() const=0
virtual std::string getString() const=0
virtual bool hasSyntax() const=0
virtual std::string getSyntax() const=0
GenericObject * get() const
static bool write(DataSource &ds, const T &item)
Abstraction layer for various data sources (file, buffer, socket...).
virtual int putch(int ch)=0
void writeString(DataSource &, std::string)
utility function
carto::rc_ptr< DataSource > dataSource()
static void genericSequenceHelper(const carto::GenericObject &obj, PythonWriter &w, int ind, bool writeInternals)
void write(const carto::GenericObject &object, bool writeInternals=false, bool writevariable=true)
Writes a generic object to stream.
bool isInternal(const std::string &syntax, const std::string &semantic)