sipxtacklib  Version 3.3
NetBase64Codec.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005-2007 SIPfoundry Inc.
3 // License by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004 Pingtel Corp.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // Copyright (C) 2007 SIPez, LLC.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
12 
13 #ifndef _NetBase64Codec_h_
14 #define _NetBase64Codec_h_
15 
16 // SYSTEM INCLUDES
17 
18 // APPLICATION INCLUDES
19 #include "utl/UtlString.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 // FORWARD DECLARATIONS
29 
30 
32 
42 {
43 /* //////////////////////////// PUBLIC //////////////////////////////////// */
44  public:
45 
46 /* ============================ CREATORS ================================== */
47 
48  // ================================================================
53 
56  static void encode(int dataSize,
57  const char data[],
58  int& encodedDataSize,
59  char encodedData[]
60  );
61 
63  static void encode(int dataSize,
64  const char data[],
65  UtlString& encodedData
66  );
67 
69  static void encode(const UtlString& data,
70  UtlString& encodedData
71  )
72  {
73  NetBase64Codec::encode(data.length(),data.data(),encodedData);
74  };
75 
77  static int encodedSize(int dataSize);
78 
80 
81  // ================================================================
88 
91  static bool isValid(int encodedDataSize,
92  const char encodedData[]
93  )
94  {
95  return validEncodingBytes(encodedDataSize, encodedData) > 0;
96  }
97 
98 
100  static bool isValid(const UtlString& encodedData
101  )
102  {
103  return validEncodingBytes(encodedData.length(), encodedData.data()) > 0;
104  }
105 
107  static bool decode(int encodedDataSize,
108  const char encodedData[],
109  int& dataSize,
110  char data[]
111  );
113 
115  static bool decode(const UtlString& encodedData,
116  UtlString& data
117  );
119 
121  static int decodedSize(int encodedDataSize,
122  const char encodedData[]
123  );
125 
127  static int decodedSize(const UtlString& encodedData
128  )
129  {
131  return decodedSize(encodedData.length(), encodedData.data());
132  }
133 
134 
135  private:
136 
137  static const char* Base64Codes;
138 
139  inline static char decodeChar(const char encoded);
140 
142  static size_t validEncodingBytes(int encodedDataSize,
143  const char encodedData[]
144  );
145 
147 
148  // @cond INCLUDENOCOPY
149  NetBase64Codec();
150  //:Default constructor (disabled)
151 
152 
153  virtual
154  ~NetBase64Codec();
155 
156  NetBase64Codec(const NetBase64Codec& rNetBase64Codec);
157  //:Copy constructor (disabled)
158 
159  NetBase64Codec& operator=(const NetBase64Codec& rhs);
160  //:Assignment operator (disabled)
161 
162  // @endcond
163 };
164 
165 #endif // _NetBase64Codec_h_
Provides methods for translating to and from base64 encoding.
Definition: NetBase64Codec.h:41
static int decodedSize(const UtlString &encodedData)
Compute the number of output binary octets for given set of encoded octets.
Definition: NetBase64Codec.h:127
static bool decode(int encodedDataSize, const char encodedData[], int &dataSize, char data[])
Decode from the character encodedData to the binary data array.
Definition: NetBase64Codec.cpp:168
static bool isValid(const UtlString &encodedData)
Definition: NetBase64Codec.h:100
static void encode(int dataSize, const char data[], int &encodedDataSize, char encodedData[])
Encode from one array into another.
Definition: NetBase64Codec.cpp:54
static bool isValid(int encodedDataSize, const char encodedData[])
Definition: NetBase64Codec.h:91
static int encodedSize(int dataSize)
Definition: NetBase64Codec.cpp:107
static void encode(const UtlString &data, UtlString &encodedData)
Encode from one UtlString into another.
Definition: NetBase64Codec.h:69
static int decodedSize(int encodedDataSize, const char encodedData[])
Compute the number of output binary octets for given set of encoded octets.
Definition: NetBase64Codec.cpp:224

sipXtackLib home page