Turi Create  4.0
string_escape.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_FLEXIBLE_TYPE_STRING_ESCAPE_HPP
7 #define TURI_FLEXIBLE_TYPE_STRING_ESCAPE_HPP
8 #include <string>
9 namespace turi {
10 
11 /**
12  * Unescapes a string inplace
13  */
14 void unescape_string(std::string& cal, bool use_escape_char, char escape_char,
15  char quote_char, bool double_quote);
16 
17 /**
18  * Unescapes a string inplace
19  */
20 void unescape_string(std::string& cal, char escape_char,
21  char quote_char, bool double_quote);
22 
23 /**
24  * Unescapes a string inplace, returning the new length
25  */
26 size_t unescape_string(char* cal,
27  size_t length, bool use_escape_char, char escape_char,
28  char quote_char, bool double_quote);
29 /**
30  * Unescapes a string inplace, returning the new length
31  */
32 size_t unescape_string(char* cal,
33  size_t length, char escape_char,
34  char quote_char, bool double_quote);
35 
36 /**
37  * Escapes a string from val into output.
38  * The length of the output string is in returned in output_len.
39  * Note that output.length() may be greater than the output_len.
40  *
41  * \param val The string to escape
42  * \param escape_char The escape character to use (recommended '\\')
43  * \param use_escape_char If true, escape character is used. Note that
44  * if this is false, the resultant string may not always be parseable.
45  * \param quote_char The quote character to use. (recommended '\"')
46  * \param use_quote_char If the output string should be quoted
47  * \param double_quote If double quotes are converted to single quotes.
48  */
49 void escape_string(const std::string& val,
50  char escape_char,
51  bool use_escape_char,
52  char quote_char,
53  bool use_quote_char,
54  bool double_quote,
55  std::string& output,
56  size_t& output_len);
57 
58 } // namespace turi
59 
60 #endif
void unescape_string(std::string &cal, bool use_escape_char, char escape_char, char quote_char, bool double_quote)
void escape_string(const std::string &val, char escape_char, bool use_escape_char, char quote_char, bool use_quote_char, bool double_quote, std::string &output, size_t &output_len)