Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: third_party/WebKit/Source/wtf/text/Base64.h

Issue 2764283002: Move files in wtf/ to platform/wtf/ (Part 10). (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/BUILD.gn ('k') | third_party/WebKit/Source/wtf/text/Base64.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 * Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 2 // Use of this source code is governed by a BSD-style license that can be
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 3 // found in the LICENSE file.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 4
27 #ifndef Base64_h 5 #include "platform/wtf/text/Base64.h"
28 #define Base64_h
29 6
30 #include "wtf/Vector.h" 7 // The contents of this header was moved to platform/wtf as part of
31 #include "wtf/WTFExport.h" 8 // WTF migration project. See the following post for details:
32 #include "wtf/text/CString.h" 9 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/tLdAZCTlcAA/bYXVT8gY CAAJ
33 #include "wtf/text/WTFString.h"
34
35 namespace WTF {
36
37 enum Base64EncodePolicy { Base64DoNotInsertLFs, Base64InsertLFs };
38
39 enum Base64DecodePolicy { Base64DoNotValidatePadding, Base64ValidatePadding };
40
41 WTF_EXPORT void base64Encode(const char*,
42 unsigned,
43 Vector<char>&,
44 Base64EncodePolicy = Base64DoNotInsertLFs);
45 WTF_EXPORT void base64Encode(const Vector<char>&,
46 Vector<char>&,
47 Base64EncodePolicy = Base64DoNotInsertLFs);
48 WTF_EXPORT void base64Encode(const CString&,
49 Vector<char>&,
50 Base64EncodePolicy = Base64DoNotInsertLFs);
51 WTF_EXPORT String base64Encode(const char*,
52 unsigned,
53 Base64EncodePolicy = Base64DoNotInsertLFs);
54 WTF_EXPORT String base64Encode(const Vector<char>&,
55 Base64EncodePolicy = Base64DoNotInsertLFs);
56 WTF_EXPORT String base64Encode(const Vector<unsigned char>&,
57 Base64EncodePolicy = Base64DoNotInsertLFs);
58 WTF_EXPORT String base64Encode(const CString&,
59 Base64EncodePolicy = Base64DoNotInsertLFs);
60
61 WTF_EXPORT bool base64Decode(
62 const String&,
63 Vector<char>&,
64 CharacterMatchFunctionPtr shouldIgnoreCharacter = 0,
65 Base64DecodePolicy = Base64DoNotValidatePadding);
66 WTF_EXPORT bool base64Decode(
67 const Vector<char>&,
68 Vector<char>&,
69 CharacterMatchFunctionPtr shouldIgnoreCharacter = 0,
70 Base64DecodePolicy = Base64DoNotValidatePadding);
71 WTF_EXPORT bool base64Decode(
72 const char*,
73 unsigned,
74 Vector<char>&,
75 CharacterMatchFunctionPtr shouldIgnoreCharacter = 0,
76 Base64DecodePolicy = Base64DoNotValidatePadding);
77 WTF_EXPORT bool base64Decode(
78 const UChar*,
79 unsigned,
80 Vector<char>&,
81 CharacterMatchFunctionPtr shouldIgnoreCharacter = 0,
82 Base64DecodePolicy = Base64DoNotValidatePadding);
83
84 // Given an encoding in either base64 or base64url, returns a normalized
85 // encoding in plain base64.
86 WTF_EXPORT String normalizeToBase64(const String&);
87
88 WTF_EXPORT String base64URLEncode(const char*,
89 unsigned,
90 Base64EncodePolicy = Base64DoNotInsertLFs);
91
92 inline void base64Encode(const Vector<char>& in,
93 Vector<char>& out,
94 Base64EncodePolicy policy) {
95 base64Encode(in.data(), in.size(), out, policy);
96 }
97
98 inline void base64Encode(const CString& in,
99 Vector<char>& out,
100 Base64EncodePolicy policy) {
101 base64Encode(in.data(), in.length(), out, policy);
102 }
103
104 inline String base64Encode(const Vector<char>& in, Base64EncodePolicy policy) {
105 return base64Encode(in.data(), in.size(), policy);
106 }
107
108 inline String base64Encode(const Vector<unsigned char>& in,
109 Base64EncodePolicy policy) {
110 return base64Encode(reinterpret_cast<const char*>(in.data()), in.size(),
111 policy);
112 }
113
114 inline String base64Encode(const CString& in, Base64EncodePolicy policy) {
115 return base64Encode(in.data(), in.length(), policy);
116 }
117
118 } // namespace WTF
119
120 using WTF::Base64EncodePolicy;
121 using WTF::Base64DoNotInsertLFs;
122 using WTF::Base64InsertLFs;
123 using WTF::Base64DecodePolicy;
124 using WTF::Base64DoNotValidatePadding;
125 using WTF::Base64ValidatePadding;
126 using WTF::base64Encode;
127 using WTF::base64Decode;
128
129 #endif // Base64_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/BUILD.gn ('k') | third_party/WebKit/Source/wtf/text/Base64.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698