Formatter.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  * Formatter.h
8  *
9  * @author mikee47 <mike@sillyhouse.net> Nov 2020
10  *
11  ****/
12 
13 #pragma once
14 
15 #include <WString.h>
16 #include <Data/WebConstants.h>
17 #include <Data/BitSet.h>
18 
19 namespace Format
20 {
21 enum class Option {
22  unicode, //< Use unicode escapes \uNNNN, otherwise hex \xNN
23  utf8,
26  backslash,
27 };
29 
36 unsigned escapeControls(String& value, Options options);
37 
41 class Formatter
42 {
43 public:
47  virtual void escape(String& value) const = 0;
48 
52  virtual void quote(String& value) const = 0;
53 
57  virtual void unQuote(String& value) const = 0;
58 
63  virtual MimeType mimeType() const = 0;
64 };
65 
66 } // namespace Format
Manage a set of bit values using enumeration.
Definition: BitSet.h:45
Virtual class to perform format-specific String adjustments.
Definition: Formatter.h:42
virtual void unQuote(String &value) const =0
Remove any quotes from a value.
virtual void quote(String &value) const =0
Convert a value into quoted string.
virtual MimeType mimeType() const =0
Corresponding MIME type for this format.
virtual void escape(String &value) const =0
Perform any necessary text escaping so output is valid.
The String class.
Definition: WString.h:133
MimeType
Definition: WebConstants.h:53
Definition: Formatter.h:20
unsigned escapeControls(String &value, Options options)
Escape standard control codes such as \n (below ASCII 0x20)
Option
Definition: Formatter.h:21
@ utf8
Convert extended ASCII to UTF8.