#include #include #include #include #include #include "dictobject.h" using namespace std; // Notes // - triple quoted python strings. hmmmm. hopefully, we don't encounter them. // // - currently we do not distinguish between strings and numbers. // so, the new rules are, all keys are strings and values are left in their // respective formats. // // To Do: // - make the collection of extraction and parsing functions into // a class, so that we can use an Abstract Method or Factory to // abstract the parsing. since, one day we might have different // implementations, such as reading marshalled data. // // - move the formatting method out from DictObject and Into this class. // // - Pass this soon to be class, into a DictObject. possibly? // need to think about this design a little more. // // The goal is to seperate out all parsing and formatting things // from the DictObject class. but allow a using relationship // beween the DictObject class and this new class while // keeping a loose coupling through abstraction. // #ifndef PYTEXTSERIALIZER #define PYTEXTSERIALIZER string ltrim(string s); string rtrim(string s); string trim(string s); string extractPyString(string s); DictObject* extractPyValue(string s); string extractPyDict(string s); DictObject* parsePyDict(string s); class PyTextSerializer { public: DictObject* load(string filename); string format(DictObject *da, string indent=""); void write(DictObject *da, string filename); }; #endif