![]() ![]() |
![]() |
File: [Pegasus] / pegasus / src / Pegasus / Common / Base64.h
(download)
Revision: 1.6, Sun Oct 17 19:39:16 2004 UTC (19 years, 8 months ago) by karl Branch: MAIN CVS Tags: RELEASE_2_4_3, RELEASE_2_4_2, RELEASE_2_4_1-BETA3, RELEASE_2_4_1-BETA2, RELEASE_2_4_1-BETA1, RELEASE_2_4_1, RELEASE_2_4_0-RC3, RELEASE_2_4_0-RC2, RELEASE_2_4_0, RELEASE_2_4-root, RELEASE_2_4-branch, PEP213_SIZE_OPTIMIZATIONS_TAG, PEP213_SIZE_OPTIMIZATIONS, IBM_241_April1405, CHUNKTESTDONE_PEP140 Changes since 1.5: +6 -4 lines BUG#: 2196 TITLE: Copyright update DESCRIPTION: Update all .cpp and .h files for new license and update the doc/license.txt file. Note that there were also a couple of files that had to be fixed because they had violated the comments rules (ex. blank line at head of file or in the case of xmlwriter.cpp a comment line //========= which drove the strip function nuts. These were fixed. This has been compiled and tested on windows. |
//%2004//////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation, The Open Group. // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //============================================================================== // // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org) // // Modified By: // //%///////////////////////////////////////////////////////////////////////////// /** This class encodes binary data to base64 Strings and decodes Strings coded in base64 into the corresponding binary data. The base 64 data representation is based on a 64-character alphabet <pre> Table 1: The Base64 Alphabet Value Encoding Value Encoding Value Encoding Value Encoding 0 A 17 R 34 i 51 z 1 B 18 S 35 j 52 0 2 C 19 T 36 k 53 1 3 D 20 U 37 l 54 2 4 E 21 V 38 m 55 3 5 F 22 W 39 n 56 4 6 G 23 X 40 o 57 5 7 H 24 Y 41 p 58 6 8 I 25 Z 42 q 59 7 9 J 26 a 43 r 60 8 10 K 27 b 44 s 61 9 11 L 28 c 45 t 62 + 12 M 29 d 46 u 63 / 13 N 30 e 47 v 14 O 31 f 48 w (pad) = 15 P 32 g 49 x 16 Q 33 h 50 y </pre> The input file is encoded 6 bits at a time into a single character in the 64-character alphabet. Where padding is required at the end of the file, The padding character is '='. Finally, the output stream should also be broken into lines to improve human readability. We break it at 76 characters and insert a CR/LF into the stream. This increases the length by less than 3%. Since the decoding ingores characters that are outside the 64 character alphabet, the CR,LF and padding character are dropped. */ #ifndef Pegasus_Base64_h #define Pegasus_Base64_h #include <iostream> #include <fstream> #include <cstring> #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Array.h> #include <Pegasus/Common/Linkage.h> PEGASUS_NAMESPACE_BEGIN class PEGASUS_COMMON_LINKAGE Base64 { public: /** encode - Encodes a String into a base-64 "string" @param @return String with the endoced data */ static Array<Sint8> encode(const Array<Uint8>& vby); /** */ static Array<Uint8> decode(const Array<Sint8> str); private: static char _Encode(Uint8 uc); static Uint8 _Decode(char c); static Boolean _IsBase64(char c); }; PEGASUS_NAMESPACE_END #endif /* Pegasus_Base64_h */
No CVS admin address has been configured |
Powered by ViewCVS 0.9.2 |