• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

qca

charset.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 1999-2007 The Botan Project. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, for any use, with or without
00005 modification, is permitted provided that the following conditions are met:
00006 
00007 1. Redistributions of source code must retain the above copyright notice, this
00008 list of conditions, and the following disclaimer.
00009 
00010 2. Redistributions in binary form must reproduce the above copyright notice,
00011 this list of conditions, and the following disclaimer in the documentation
00012 and/or other materials provided with the distribution.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED
00015 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00016 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
00017 
00018 IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT,
00019 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00020 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00021 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00022 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00023 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00024 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 */
00026 // LICENSEHEADER_END
00027 namespace QCA { // WRAPNS_LINE
00028 /*************************************************
00029 * Character Set Handling Source File             *
00030 * (C) 1999-2007 The Botan Project                *
00031 *************************************************/
00032 
00033 } // WRAPNS_LINE
00034 #include <botan/charset.h>
00035 namespace QCA { // WRAPNS_LINE
00036 #ifdef BOTAN_TOOLS_ONLY
00037 } // WRAPNS_LINE
00038 #include <botan/exceptn.h>
00039 namespace QCA { // WRAPNS_LINE
00040 #else
00041 } // WRAPNS_LINE
00042 #include <botan/hex.h>
00043 namespace QCA { // WRAPNS_LINE
00044 } // WRAPNS_LINE
00045 #include <botan/base64.h>
00046 namespace QCA { // WRAPNS_LINE
00047 #endif
00048 } // WRAPNS_LINE
00049 #include <botan/libstate.h>
00050 namespace QCA { // WRAPNS_LINE
00051 } // WRAPNS_LINE
00052 #include <cctype>
00053 namespace QCA { // WRAPNS_LINE
00054 } // WRAPNS_LINE
00055 #include <ctype.h>
00056 namespace QCA { // WRAPNS_LINE
00057 
00058 namespace Botan {
00059 
00060 namespace Charset {
00061 
00062 /*************************************************
00063 * Perform character set transcoding              *
00064 *************************************************/
00065 #ifndef BOTAN_TOOLS_ONLY
00066 std::string transcode(const std::string& str,
00067                       Character_Set to, Character_Set from)
00068    {
00069    return global_state().transcode(str, to, from);
00070    }
00071 #endif
00072 
00073 /*************************************************
00074 * Check if a character represents a digit        *
00075 *************************************************/
00076 bool is_digit(char c)
00077    {
00078    if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' ||
00079       c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
00080       return true;
00081    return false;
00082    }
00083 
00084 /*************************************************
00085 * Check if a character represents whitespace     *
00086 *************************************************/
00087 bool is_space(char c)
00088    {
00089    if(c == ' ' || c == '\t' || c == '\n' || c == '\r')
00090       return true;
00091    return false;
00092    }
00093 
00094 /*************************************************
00095 * Convert a character to a digit                 *
00096 *************************************************/
00097 byte char2digit(char c)
00098    {
00099    switch(c)
00100       {
00101       case '0': return 0;
00102       case '1': return 1;
00103       case '2': return 2;
00104       case '3': return 3;
00105       case '4': return 4;
00106       case '5': return 5;
00107       case '6': return 6;
00108       case '7': return 7;
00109       case '8': return 8;
00110       case '9': return 9;
00111       }
00112 
00113    throw Invalid_Argument("char2digit: Input is not a digit character");
00114    }
00115 
00116 /*************************************************
00117 * Convert a digit to a character                 *
00118 *************************************************/
00119 char digit2char(byte b)
00120    {
00121    switch(b)
00122       {
00123       case 0: return '0';
00124       case 1: return '1';
00125       case 2: return '2';
00126       case 3: return '3';
00127       case 4: return '4';
00128       case 5: return '5';
00129       case 6: return '6';
00130       case 7: return '7';
00131       case 8: return '8';
00132       case 9: return '9';
00133       }
00134 
00135    throw Invalid_Argument("digit2char: Input is not a digit");
00136    }
00137 
00138 /*************************************************
00139 * Case-insensitive character comparison          *
00140 *************************************************/
00141 bool caseless_cmp(char a, char b)
00142    {
00143    return (tolower((unsigned char)a) == tolower((unsigned char)b));
00144    }
00145 
00146 }
00147 
00148 #ifndef BOTAN_TOOLS_ONLY
00149 
00150 /*************************************************
00151 * Hex Encoder Lookup Tables                      *
00152 *************************************************/
00153 const byte Hex_Encoder::BIN_TO_HEX_UPPER[16] = {
00154 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43,
00155 0x44, 0x45, 0x46 };
00156 
00157 const byte Hex_Encoder::BIN_TO_HEX_LOWER[16] = {
00158 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63,
00159 0x64, 0x65, 0x66 };
00160 
00161 /*************************************************
00162 * Base64 Encoder Lookup Table                    *
00163 *************************************************/
00164 const byte Base64_Encoder::BIN_TO_BASE64[64] = {
00165 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
00166 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
00167 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D,
00168 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A,
00169 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F };
00170 
00171 /*************************************************
00172 * Hex Decoder Lookup Table                       *
00173 *************************************************/
00174 const byte Hex_Decoder::HEX_TO_BIN[256] = {
00175 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00176 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00177 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00178 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x01, 0x02, 0x03,
00179 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00180 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00181 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00182 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x80,
00183 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00184 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00185 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00186 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00187 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00188 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00189 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00190 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00191 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00192 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00193 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00194 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
00195 
00196 /*************************************************
00197 * Base64 Decoder Lookup Table                    *
00198 *************************************************/
00199 const byte Base64_Decoder::BASE64_TO_BIN[256] = {
00200 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00201 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00202 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00203 0x80, 0x80, 0x80, 0x80, 0x3E, 0x80, 0x80, 0x80, 0x3F, 0x34, 0x35, 0x36, 0x37,
00204 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00205 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
00206 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
00207 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
00208 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D,
00209 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00210 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00211 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00212 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00213 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00214 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00215 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00216 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00217 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00218 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
00219 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
00220 
00221 #endif
00222 
00223 }
00224 } // WRAPNS_LINE

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal