diff options
| author | randomdan <randomdan@localhost> | 2010-08-10 23:19:58 +0000 |
|---|---|---|
| committer | randomdan <randomdan@localhost> | 2010-08-10 23:19:58 +0000 |
| commit | 99abe705086af006aa8f56c1ada08203a4dfcf16 (patch) | |
| tree | 57608cf4cf6434a65602524c49e3103898a77eed /project2/urlRows.h | |
| parent | Tidy up hierarchy (diff) | |
| download | project2-99abe705086af006aa8f56c1ada08203a4dfcf16.tar.bz2 project2-99abe705086af006aa8f56c1ada08203a4dfcf16.tar.xz project2-99abe705086af006aa8f56c1ada08203a4dfcf16.zip | |
Minor fixes to text parsers
Add a URL base row implementation
Diffstat (limited to 'project2/urlRows.h')
| -rw-r--r-- | project2/urlRows.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/project2/urlRows.h b/project2/urlRows.h new file mode 100644 index 0000000..f94e149 --- /dev/null +++ b/project2/urlRows.h @@ -0,0 +1,61 @@ +#ifndef URLROWS_H +#define URLROWS_H + +#include <libxml++/nodes/element.h> +#include <boost/shared_ptr.hpp> +#include <map> +#include "view.h" +#include "iterate.h" + +class _UrlRows : public PerRowValues { + public: + _UrlRows(const xmlpp::Element * p); + ~_UrlRows(); + + void execute() const; + unsigned int columnCount() const; + const Glib::ustring & getColumnName(unsigned int col) const; + const Glib::ustring & getCurrentValue(const Glib::ustring & id) const; + const Glib::ustring & getCurrentValue(unsigned int col) const; + virtual void rowReady() const = 0; + + typedef std::set<gunichar> CharSet; + const Glib::ustring url; + + protected: + void addColumn(const Glib::ustring & rawtok) const; + typedef boost::shared_ptr<Glib::ustring> ValPtr; + typedef std::vector<ValPtr> Values; + mutable Values values; + + private: + static size_t _handleData(const char * ptr, size_t size, size_t nmemb, void * stream); + size_t handleData(const char * bytes, size_t bytesLen) const; + gunichar fieldSep; + gunichar quoteChar; + gunichar newline; + std::string encoding; + mutable size_t skipheader; + typedef std::vector<Glib::ustring> Columns; + mutable Columns columns; + + // Used in CURL callback + mutable bool mkCols; + mutable bool inQuotes; + mutable bool prevWasQuote; + mutable Glib::ustring tok; +}; +typedef boost::shared_ptr<_UrlRows> UrlRows; + +typedef _GenericView<_UrlRows> _UrlView; +typedef boost::shared_ptr<_UrlView> UrlView; +typedef std::map<std::string, UrlView> UrlViews; + +typedef _GenericIterate<_UrlRows> _UrlIterate; +typedef boost::shared_ptr<_UrlIterate> UrlIterate; +typedef std::map<std::string, UrlIterate> UrlIterates; + +#endif + + + |
