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 
31 class HttpParams : public HashMap<String, String>, public Printable
32 {
33 public:
34  HttpParams() = default;
35 
36  HttpParams(const HttpParams& params)
37  {
38  *this = params;
39  }
40 
42  {
43  parseQuery(query.begin());
44  }
45 
51  void parseQuery(char* query);
52 
54  String toString() const;
55 
56  operator String() const
57  {
58  return toString();
59  }
60 
62  {
63  clear();
64  setMultiple(params);
65  return *this;
66  }
67 
68  // Printable
69  size_t printTo(Print& p) const override;
70 
75  void debugPrintTo(Print& p) const;
76 };
HttpParams & operator=(const HttpParams &params)
Definition: HttpParams.h:61
Definition: HttpParams.h:31
HashMap class template.
Definition: WHashMap.h:37
HttpParams(String query)
Definition: HttpParams.h:41
void clear()
Definition: WHashMap.h:308
The String class.
Definition: WString.h:136
Provides formatted output to stream.
Definition: Print.h:36
char * begin()
Get a modifiable pointer to String content.
Definition: WString.h:606
String toString() const
Return full escaped content for incorporation into a URI.
HttpParams()=default
void debugPrintTo(Print &p) const
Printable output for debugging.
void parseQuery(char *query)
Called from URL class to process query section of a URI.
Definition: Printable.h:42
void setMultiple(const HashMap< String, String > &map)
Definition: WHashMap.h:324
HttpParams(const HttpParams &params)
Definition: HttpParams.h:36
size_t printTo(Print &p) const override