HttpParams.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * HttpParams.h
8  *
9  * @author: 2018 - Mikee47 <mike@sillyhouse.net>
10  *
11  * Class to manage HTTP URI query parameters
12  *
13  * The HttpParams class was an empty HashMap class living in 'Structures.h'.
14  * It has been expanded to incorporate escaping and unescaping.
15  * Custom URL parsing code has been replaced with the yuarel library https://github.com/jacketizer/libyuarel
16  *
17  ****/
18 
19 #pragma once
20 
21 #include "WString.h"
22 #include "WHashMap.h"
23 #include "Printable.h"
24 
34 class HttpParams : public HashMap<String, String>
35 {
36 public:
37  HttpParams() = default;
38 
39  HttpParams(const HttpParams& params)
40  {
41  *this = params;
42  }
43 
45  {
46  parseQuery(query.begin());
47  }
48 
54  void parseQuery(char* query);
55 
57  String toString() const;
58 
59  operator String() const
60  {
61  return toString();
62  }
63 
65  {
66  clear();
67  setMultiple(params);
68  return *this;
69  }
70 
71  // Printable
72  size_t printTo(Print& p) const;
73 
78  void debugPrintTo(Print& p) const;
79 };
HashMap class template.
Definition: WHashMap.h:42
void clear()
Definition: WHashMap.h:382
void setMultiple(const HashMap< String, String > &map)
Definition: WHashMap.h:389
Handles the query portion of a URI.
Definition: HttpParams.h:35
HttpParams(String query)
Definition: HttpParams.h:44
HttpParams & operator=(const HttpParams &params)
Definition: HttpParams.h:64
HttpParams()=default
HttpParams(const HttpParams &params)
Definition: HttpParams.h:39
size_t printTo(Print &p) const
void parseQuery(char *query)
Called from URL class to process query section of a URI.
void debugPrintTo(Print &p) const
Printable output for debugging.
String toString() const
Return full escaped content for incorporation into a URI.
Provides formatted output to stream.
Definition: Print.h:37
The String class.
Definition: WString.h:137
char * begin()
Get a modifiable pointer to String content.
Definition: WString.h:626