Dependencies:   mbed

Committer:
iva2k
Date:
Mon Jun 14 03:24:33 2010 +0000
Revision:
1:3ee499525aa5
Parent:
0:e614f7875b60

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iva2k 0:e614f7875b60 1
iva2k 0:e614f7875b60 2 /*
iva2k 0:e614f7875b60 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
iva2k 0:e614f7875b60 4
iva2k 0:e614f7875b60 5 Permission is hereby granted, free of charge, to any person obtaining a copy
iva2k 0:e614f7875b60 6 of this software and associated documentation files (the "Software"), to deal
iva2k 0:e614f7875b60 7 in the Software without restriction, including without limitation the rights
iva2k 0:e614f7875b60 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
iva2k 0:e614f7875b60 9 copies of the Software, and to permit persons to whom the Software is
iva2k 0:e614f7875b60 10 furnished to do so, subject to the following conditions:
iva2k 0:e614f7875b60 11
iva2k 0:e614f7875b60 12 The above copyright notice and this permission notice shall be included in
iva2k 0:e614f7875b60 13 all copies or substantial portions of the Software.
iva2k 0:e614f7875b60 14
iva2k 0:e614f7875b60 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
iva2k 0:e614f7875b60 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
iva2k 0:e614f7875b60 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
iva2k 0:e614f7875b60 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
iva2k 0:e614f7875b60 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
iva2k 0:e614f7875b60 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
iva2k 0:e614f7875b60 21 THE SOFTWARE.
iva2k 0:e614f7875b60 22 */
iva2k 0:e614f7875b60 23
iva2k 0:e614f7875b60 24 #ifndef HTTP_MAP_H
iva2k 0:e614f7875b60 25 #define HTTP_MAP_H
iva2k 0:e614f7875b60 26
iva2k 0:e614f7875b60 27 #include "../HTTPData.h"
iva2k 0:e614f7875b60 28 #include "mbed.h"
iva2k 0:e614f7875b60 29
iva2k 0:e614f7875b60 30 #include <map>
iva2k 0:e614f7875b60 31 using std::map;
iva2k 0:e614f7875b60 32
iva2k 0:e614f7875b60 33 typedef map<string, string> Dictionary;
iva2k 0:e614f7875b60 34
iva2k 0:e614f7875b60 35 class HTTPMap : public HTTPData, public Dictionary //Key/Value pairs
iva2k 0:e614f7875b60 36 {
iva2k 0:e614f7875b60 37 public:
iva2k 0:e614f7875b60 38 HTTPMap(const string& keyValueSep = "=", const string& pairSep = "&");
iva2k 0:e614f7875b60 39 virtual ~HTTPMap();
iva2k 0:e614f7875b60 40
iva2k 0:e614f7875b60 41 /* string& operator[](const string& key);
iva2k 0:e614f7875b60 42 int count();*/
iva2k 0:e614f7875b60 43
iva2k 0:e614f7875b60 44 virtual void clear();
iva2k 0:e614f7875b60 45
iva2k 0:e614f7875b60 46 protected:
iva2k 0:e614f7875b60 47 virtual int read(char* buf, int len);
iva2k 0:e614f7875b60 48 virtual int write(const char* buf, int len);
iva2k 0:e614f7875b60 49
iva2k 0:e614f7875b60 50 virtual string getDataType(); //Internet media type for Content-Type header
iva2k 0:e614f7875b60 51 virtual void setDataType(const string& type); //Internet media type from Content-Type header
iva2k 0:e614f7875b60 52
iva2k 0:e614f7875b60 53 virtual bool getIsChunked(); //For Transfer-Encoding header
iva2k 0:e614f7875b60 54 virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
iva2k 0:e614f7875b60 55
iva2k 0:e614f7875b60 56 virtual int getDataLen(); //For Content-Length header
iva2k 0:e614f7875b60 57 virtual void setDataLen(int len); //From Content-Length header
iva2k 0:e614f7875b60 58
iva2k 0:e614f7875b60 59 private:
iva2k 0:e614f7875b60 60 void generateString();
iva2k 0:e614f7875b60 61 void parseString();
iva2k 0:e614f7875b60 62 //map<string, string> m_map;
iva2k 0:e614f7875b60 63 string m_buf;
iva2k 0:e614f7875b60 64 int m_len;
iva2k 0:e614f7875b60 65 bool m_chunked;
iva2k 0:e614f7875b60 66
iva2k 0:e614f7875b60 67 string m_keyValueSep;
iva2k 0:e614f7875b60 68 string m_pairSep;
iva2k 0:e614f7875b60 69 };
iva2k 0:e614f7875b60 70
iva2k 0:e614f7875b60 71 #endif