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

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

Issue 22796004: Simplify WTF::base64Decode() after r154538 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Restore the enum's original name Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/DOMWindowBase64.cpp ('k') | 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 /*
2 * Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 2 * Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 21 matching lines...) Expand all
32 #include "wtf/text/CString.h" 32 #include "wtf/text/CString.h"
33 #include "wtf/text/WTFString.h" 33 #include "wtf/text/WTFString.h"
34 34
35 namespace WTF { 35 namespace WTF {
36 36
37 enum Base64EncodePolicy { 37 enum Base64EncodePolicy {
38 Base64DoNotInsertLFs, 38 Base64DoNotInsertLFs,
39 Base64InsertLFs 39 Base64InsertLFs
40 }; 40 };
41 41
42 enum Base64InvalidCharactersPolicy { 42 enum Base64DecodePolicy {
43 Base64FailOnInvalidCharacterOrExcessPadding,
43 Base64FailOnInvalidCharacter, 44 Base64FailOnInvalidCharacter,
44 Base64IgnoreWhitespace, 45 Base64IgnoreWhitespace,
45 Base64IgnoreInvalidCharacters 46 Base64IgnoreInvalidCharacters
46 }; 47 };
47 48
48 enum Base64PaddingValidationPolicy {
49 Base64NoPaddingValidation,
50 Base64StrictPaddingValidation
51 };
52
53 WTF_EXPORT void base64Encode(const char*, unsigned, Vector<char>&, Base64EncodeP olicy = Base64DoNotInsertLFs); 49 WTF_EXPORT void base64Encode(const char*, unsigned, Vector<char>&, Base64EncodeP olicy = Base64DoNotInsertLFs);
54 WTF_EXPORT void base64Encode(const Vector<char>&, Vector<char>&, Base64EncodePol icy = Base64DoNotInsertLFs); 50 WTF_EXPORT void base64Encode(const Vector<char>&, Vector<char>&, Base64EncodePol icy = Base64DoNotInsertLFs);
55 WTF_EXPORT void base64Encode(const CString&, Vector<char>&, Base64EncodePolicy = Base64DoNotInsertLFs); 51 WTF_EXPORT void base64Encode(const CString&, Vector<char>&, Base64EncodePolicy = Base64DoNotInsertLFs);
56 WTF_EXPORT String base64Encode(const char*, unsigned, Base64EncodePolicy = Base6 4DoNotInsertLFs); 52 WTF_EXPORT String base64Encode(const char*, unsigned, Base64EncodePolicy = Base6 4DoNotInsertLFs);
57 WTF_EXPORT String base64Encode(const Vector<char>&, Base64EncodePolicy = Base64D oNotInsertLFs); 53 WTF_EXPORT String base64Encode(const Vector<char>&, Base64EncodePolicy = Base64D oNotInsertLFs);
58 WTF_EXPORT String base64Encode(const CString&, Base64EncodePolicy = Base64DoNotI nsertLFs); 54 WTF_EXPORT String base64Encode(const CString&, Base64EncodePolicy = Base64DoNotI nsertLFs);
59 55
60 WTF_EXPORT bool base64Decode(const String&, Vector<char>&, Base64InvalidCharacte rsPolicy = Base64FailOnInvalidCharacter, Base64PaddingValidationPolicy = Base64N oPaddingValidation); 56 WTF_EXPORT bool base64Decode(const String&, Vector<char>&, Base64DecodePolicy = Base64FailOnInvalidCharacter);
61 WTF_EXPORT bool base64Decode(const Vector<char>&, Vector<char>&, Base64InvalidCh aractersPolicy = Base64FailOnInvalidCharacter, Base64PaddingValidationPolicy = B ase64NoPaddingValidation); 57 WTF_EXPORT bool base64Decode(const Vector<char>&, Vector<char>&, Base64DecodePol icy = Base64FailOnInvalidCharacter);
62 WTF_EXPORT bool base64Decode(const char*, unsigned, Vector<char>&, Base64Invalid CharactersPolicy = Base64FailOnInvalidCharacter, Base64PaddingValidationPolicy = Base64NoPaddingValidation); 58 WTF_EXPORT bool base64Decode(const char*, unsigned, Vector<char>&, Base64DecodeP olicy = Base64FailOnInvalidCharacter);
63 59
64 inline void base64Encode(const Vector<char>& in, Vector<char>& out, Base64Encode Policy policy) 60 inline void base64Encode(const Vector<char>& in, Vector<char>& out, Base64Encode Policy policy)
65 { 61 {
66 base64Encode(in.data(), in.size(), out, policy); 62 base64Encode(in.data(), in.size(), out, policy);
67 } 63 }
68 64
69 inline void base64Encode(const CString& in, Vector<char>& out, Base64EncodePolic y policy) 65 inline void base64Encode(const CString& in, Vector<char>& out, Base64EncodePolic y policy)
70 { 66 {
71 base64Encode(in.data(), in.length(), out, policy); 67 base64Encode(in.data(), in.length(), out, policy);
72 } 68 }
73 69
74 inline String base64Encode(const Vector<char>& in, Base64EncodePolicy policy) 70 inline String base64Encode(const Vector<char>& in, Base64EncodePolicy policy)
75 { 71 {
76 return base64Encode(in.data(), in.size(), policy); 72 return base64Encode(in.data(), in.size(), policy);
77 } 73 }
78 74
79 inline String base64Encode(const CString& in, Base64EncodePolicy policy) 75 inline String base64Encode(const CString& in, Base64EncodePolicy policy)
80 { 76 {
81 return base64Encode(in.data(), in.length(), policy); 77 return base64Encode(in.data(), in.length(), policy);
82 } 78 }
83 79
84 } // namespace WTF 80 } // namespace WTF
85 81
86 using WTF::Base64EncodePolicy; 82 using WTF::Base64EncodePolicy;
87 using WTF::Base64DoNotInsertLFs; 83 using WTF::Base64DoNotInsertLFs;
88 using WTF::Base64InsertLFs; 84 using WTF::Base64InsertLFs;
89 using WTF::Base64InvalidCharactersPolicy; 85 using WTF::Base64DecodePolicy;
86 using WTF::Base64FailOnInvalidCharacterOrExcessPadding;
90 using WTF::Base64FailOnInvalidCharacter; 87 using WTF::Base64FailOnInvalidCharacter;
91 using WTF::Base64IgnoreWhitespace; 88 using WTF::Base64IgnoreWhitespace;
92 using WTF::Base64IgnoreInvalidCharacters; 89 using WTF::Base64IgnoreInvalidCharacters;
93 using WTF::Base64PaddingValidationPolicy;
94 using WTF::Base64NoPaddingValidation;
95 using WTF::Base64StrictPaddingValidation;
96 using WTF::base64Encode; 90 using WTF::base64Encode;
97 using WTF::base64Decode; 91 using WTF::base64Decode;
98 92
99 #endif // Base64_h 93 #endif // Base64_h
OLDNEW
« no previous file with comments | « Source/core/page/DOMWindowBase64.cpp ('k') | Source/wtf/text/Base64.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698