OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines utility functions for escaping strings. | 5 // This file defines utility functions for escaping strings. |
6 | 6 |
7 #ifndef BASE_JSON_STRING_ESCAPE_H_ | 7 #ifndef BASE_JSON_STRING_ESCAPE_H_ |
8 #define BASE_JSON_STRING_ESCAPE_H_ | 8 #define BASE_JSON_STRING_ESCAPE_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/base_api.h" | 13 #include "base/base_export.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 // Escape |str| appropriately for a JSON string literal, _appending_ the | 18 // Escape |str| appropriately for a JSON string literal, _appending_ the |
19 // result to |dst|. This will create unicode escape sequences (\uXXXX). | 19 // result to |dst|. This will create unicode escape sequences (\uXXXX). |
20 // If |put_in_quotes| is true, the result will be surrounded in double quotes. | 20 // If |put_in_quotes| is true, the result will be surrounded in double quotes. |
21 // The outputted literal, when interpreted by the browser, should result in a | 21 // The outputted literal, when interpreted by the browser, should result in a |
22 // javascript string that is identical and the same length as the input |str|. | 22 // javascript string that is identical and the same length as the input |str|. |
23 BASE_API void JsonDoubleQuote(const std::string& str, | 23 BASE_EXPORT void JsonDoubleQuote(const std::string& str, |
24 bool put_in_quotes, | 24 bool put_in_quotes, |
25 std::string* dst); | 25 std::string* dst); |
26 | 26 |
27 // Same as above, but always returns the result double quoted. | 27 // Same as above, but always returns the result double quoted. |
28 BASE_API std::string GetDoubleQuotedJson(const std::string& str); | 28 BASE_EXPORT std::string GetDoubleQuotedJson(const std::string& str); |
29 | 29 |
30 BASE_API void JsonDoubleQuote(const string16& str, | 30 BASE_EXPORT void JsonDoubleQuote(const string16& str, |
31 bool put_in_quotes, | 31 bool put_in_quotes, |
32 std::string* dst); | 32 std::string* dst); |
33 | 33 |
34 // Same as above, but always returns the result double quoted. | 34 // Same as above, but always returns the result double quoted. |
35 BASE_API std::string GetDoubleQuotedJson(const string16& str); | 35 BASE_EXPORT std::string GetDoubleQuotedJson(const string16& str); |
36 | 36 |
37 } // namespace base | 37 } // namespace base |
38 | 38 |
39 #endif // BASE_JSON_STRING_ESCAPE_H_ | 39 #endif // BASE_JSON_STRING_ESCAPE_H_ |
OLD | NEW |