/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa * All rights reserved. * */ #ifndef headerfile_winix_core_getparser #define headerfile_winix_core_getparser #include "httpsimpleparser.h" #include "requesttypes.h" #include "misc.h" #include "utf8.h" #include "log.h" class GetParser : public HttpSimpleParser { const char * get_string; GetTab * get_tab; std::wstring temp; bool input_as_utf8; protected: virtual int GetChar() { if( !get_string || *get_string == 0 ) return -1; return (int)(unsigned char)*(get_string++); } virtual void Parameter(std::string &, std::string & value) { if( input_as_utf8 ) Ezc::UTF8ToWide(value, temp); else AssignString(value, temp); get_tab->push_back(temp); log << log2 << "Get, value: \"" << temp << "\"" << logend; } public: GetParser() { HttpSimpleParser::separator = '/'; HttpSimpleParser::read_name = false; input_as_utf8 = false; } void UTF8(bool utf) { input_as_utf8 = utf; } // get_string_ can be null void Parse(const char * get_string_, GetTab & get_tab_) { get_string = get_string_; get_tab = &get_tab_; if( get_string && *get_string == separator ) { // skipping one '/' at the beginning ++get_string; } HttpSimpleParser::Parse(); } }; #endif