NetServices Stack source
Dependents: HelloWorld ServoInterfaceBoardExample1 4180_Lab4
url.h
00001 00002 /* 00003 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy 00006 of this software and associated documentation files (the "Software"), to deal 00007 in the Software without restriction, including without limitation the rights 00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 THE SOFTWARE. 00022 */ 00023 00024 #ifndef URL_H 00025 #define URL_H 00026 00027 #include "core/ipaddr.h" 00028 00029 #include <string> 00030 using std::string; 00031 00032 #include "mbed.h" 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 char *url_encode(char *str); 00039 char *url_decode(char *str); 00040 00041 #ifdef __cplusplus 00042 } 00043 #endif 00044 00045 class Url 00046 { 00047 public: 00048 static string encode(const string& url) 00049 { 00050 char* c_res = url_encode( (char*) url.c_str() ); 00051 string res(c_res); 00052 free(c_res); //Alloc'ed in url_encode() 00053 return res; 00054 } 00055 00056 static string decode(const string& url) 00057 { 00058 char* c_res = url_decode( (char*) url.c_str() ); 00059 string res(c_res); 00060 free(c_res); //Alloc'ed in url_decode() 00061 return res; 00062 } 00063 00064 Url(); 00065 00066 string getProtocol(); 00067 string getHost(); 00068 bool getHostIp(IpAddr* ip); //If host is in IP form, return true & proper object by ptr 00069 uint16_t getPort(); 00070 string getPath(); 00071 00072 void setProtocol(string protocol); 00073 void setHost(string host); 00074 void setPort(uint16_t port); 00075 void setPath(string path); 00076 00077 void fromString(string str); 00078 string toString(); 00079 00080 private: 00081 string m_protocol; 00082 string m_host; 00083 uint16_t m_port; 00084 string m_path; 00085 00086 }; 00087 00088 #endif /* LWIP_UTILS_H */
Generated on Tue Jul 12 2022 11:52:58 by 1.7.2