OLD | NEW |
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 22 matching lines...) Expand all Loading... |
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 Base64DecodePolicy { | 42 enum Base64DecodePolicy { |
43 Base64FailOnInvalidCharacterOrExcessPadding, | 43 Base64DoNotValidatePadding, |
44 Base64FailOnInvalidCharacter, | 44 Base64ValidatePadding |
45 Base64IgnoreWhitespace, | |
46 Base64IgnoreInvalidCharacters | |
47 }; | 45 }; |
48 | 46 |
49 WTF_EXPORT void base64Encode(const char*, unsigned, Vector<char>&, Base64EncodeP
olicy = Base64DoNotInsertLFs); | 47 WTF_EXPORT void base64Encode(const char*, unsigned, Vector<char>&, Base64EncodeP
olicy = Base64DoNotInsertLFs); |
50 WTF_EXPORT void base64Encode(const Vector<char>&, Vector<char>&, Base64EncodePol
icy = Base64DoNotInsertLFs); | 48 WTF_EXPORT void base64Encode(const Vector<char>&, Vector<char>&, Base64EncodePol
icy = Base64DoNotInsertLFs); |
51 WTF_EXPORT void base64Encode(const CString&, Vector<char>&, Base64EncodePolicy =
Base64DoNotInsertLFs); | 49 WTF_EXPORT void base64Encode(const CString&, Vector<char>&, Base64EncodePolicy =
Base64DoNotInsertLFs); |
52 WTF_EXPORT String base64Encode(const char*, unsigned, Base64EncodePolicy = Base6
4DoNotInsertLFs); | 50 WTF_EXPORT String base64Encode(const char*, unsigned, Base64EncodePolicy = Base6
4DoNotInsertLFs); |
53 WTF_EXPORT String base64Encode(const Vector<char>&, Base64EncodePolicy = Base64D
oNotInsertLFs); | 51 WTF_EXPORT String base64Encode(const Vector<char>&, Base64EncodePolicy = Base64D
oNotInsertLFs); |
54 WTF_EXPORT String base64Encode(const CString&, Base64EncodePolicy = Base64DoNotI
nsertLFs); | 52 WTF_EXPORT String base64Encode(const CString&, Base64EncodePolicy = Base64DoNotI
nsertLFs); |
55 | 53 |
56 WTF_EXPORT bool base64Decode(const String&, Vector<char>&, Base64DecodePolicy =
Base64FailOnInvalidCharacter); | 54 WTF_EXPORT bool base64Decode(const String&, Vector<char>&, CharacterMatchFunctio
nPtr shouldIgnoreCharacter = 0, Base64DecodePolicy = Base64DoNotValidatePadding)
; |
57 WTF_EXPORT bool base64Decode(const Vector<char>&, Vector<char>&, Base64DecodePol
icy = Base64FailOnInvalidCharacter); | 55 WTF_EXPORT bool base64Decode(const Vector<char>&, Vector<char>&, CharacterMatchF
unctionPtr shouldIgnoreCharacter = 0, Base64DecodePolicy = Base64DoNotValidatePa
dding); |
58 WTF_EXPORT bool base64Decode(const char*, unsigned, Vector<char>&, Base64DecodeP
olicy = Base64FailOnInvalidCharacter); | 56 WTF_EXPORT bool base64Decode(const char*, unsigned, Vector<char>&, CharacterMatc
hFunctionPtr shouldIgnoreCharacter = 0, Base64DecodePolicy = Base64DoNotValidate
Padding); |
59 WTF_EXPORT bool base64Decode(const UChar*, unsigned, Vector<char>&, Base64Decode
Policy = Base64FailOnInvalidCharacter); | 57 WTF_EXPORT bool base64Decode(const UChar*, unsigned, Vector<char>&, CharacterMat
chFunctionPtr shouldIgnoreCharacter = 0, Base64DecodePolicy = Base64DoNotValidat
ePadding); |
60 | 58 |
61 inline void base64Encode(const Vector<char>& in, Vector<char>& out, Base64Encode
Policy policy) | 59 inline void base64Encode(const Vector<char>& in, Vector<char>& out, Base64Encode
Policy policy) |
62 { | 60 { |
63 base64Encode(in.data(), in.size(), out, policy); | 61 base64Encode(in.data(), in.size(), out, policy); |
64 } | 62 } |
65 | 63 |
66 inline void base64Encode(const CString& in, Vector<char>& out, Base64EncodePolic
y policy) | 64 inline void base64Encode(const CString& in, Vector<char>& out, Base64EncodePolic
y policy) |
67 { | 65 { |
68 base64Encode(in.data(), in.length(), out, policy); | 66 base64Encode(in.data(), in.length(), out, policy); |
69 } | 67 } |
70 | 68 |
71 inline String base64Encode(const Vector<char>& in, Base64EncodePolicy policy) | 69 inline String base64Encode(const Vector<char>& in, Base64EncodePolicy policy) |
72 { | 70 { |
73 return base64Encode(in.data(), in.size(), policy); | 71 return base64Encode(in.data(), in.size(), policy); |
74 } | 72 } |
75 | 73 |
76 inline String base64Encode(const CString& in, Base64EncodePolicy policy) | 74 inline String base64Encode(const CString& in, Base64EncodePolicy policy) |
77 { | 75 { |
78 return base64Encode(in.data(), in.length(), policy); | 76 return base64Encode(in.data(), in.length(), policy); |
79 } | 77 } |
80 | 78 |
81 } // namespace WTF | 79 } // namespace WTF |
82 | 80 |
83 using WTF::Base64EncodePolicy; | 81 using WTF::Base64EncodePolicy; |
84 using WTF::Base64DoNotInsertLFs; | 82 using WTF::Base64DoNotInsertLFs; |
85 using WTF::Base64InsertLFs; | 83 using WTF::Base64InsertLFs; |
86 using WTF::Base64DecodePolicy; | 84 using WTF::Base64DecodePolicy; |
87 using WTF::Base64FailOnInvalidCharacterOrExcessPadding; | 85 using WTF::Base64DoNotValidatePadding; |
88 using WTF::Base64FailOnInvalidCharacter; | 86 using WTF::Base64ValidatePadding; |
89 using WTF::Base64IgnoreWhitespace; | |
90 using WTF::Base64IgnoreInvalidCharacters; | |
91 using WTF::base64Encode; | 87 using WTF::base64Encode; |
92 using WTF::base64Decode; | 88 using WTF::base64Decode; |
93 | 89 |
94 #endif // Base64_h | 90 #endif // Base64_h |
OLD | NEW |