Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 03 08:45:49 2011 +0000
Revision:
0:8d62137f7ff4
For FRIENDs.

Who changed what in which revision?

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