|
a/src/bincimapmime/convert.h |
|
b/src/bincimapmime/convert.h |
|
... |
|
... |
23 |
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
|
23 |
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
|
24 |
* --------------------------------------------------------------------
|
24 |
* --------------------------------------------------------------------
|
25 |
*/
|
25 |
*/
|
26 |
#ifndef convert_h_included
|
26 |
#ifndef convert_h_included
|
27 |
#define convert_h_included
|
27 |
#define convert_h_included
|
|
|
28 |
#include <stddef.h>
|
28 |
#include <string>
|
29 |
#include <string>
|
29 |
#include <vector>
|
30 |
#include <vector>
|
30 |
#include <iomanip>
|
31 |
#include <iomanip>
|
31 |
#include <iostream>
|
32 |
#include <iostream>
|
32 |
|
33 |
|
|
... |
|
... |
91 |
{
|
92 |
{
|
92 |
const char hexchars[] = "0123456789abcdef";
|
93 |
const char hexchars[] = "0123456789abcdef";
|
93 |
std::string tmp;
|
94 |
std::string tmp;
|
94 |
for (std::string::const_iterator i = s.begin();
|
95 |
for (std::string::const_iterator i = s.begin();
|
95 |
i != s.end() && i + 1 != s.end(); i += 2) {
|
96 |
i != s.end() && i + 1 != s.end(); i += 2) {
|
96 |
int n;
|
97 |
ptrdiff_t n;
|
97 |
unsigned char c = *i;
|
98 |
unsigned char c = *i;
|
98 |
unsigned char d = *(i + 1);
|
99 |
unsigned char d = *(i + 1);
|
99 |
|
100 |
|
100 |
const char *t;
|
101 |
const char *t;
|
101 |
if ((t = strchr(hexchars, c)) == 0)
|
102 |
if ((t = strchr(hexchars, c)) == 0)
|
|
... |
|
... |
120 |
inline std::string toImapString(const std::string &s_in)
|
121 |
inline std::string toImapString(const std::string &s_in)
|
121 |
{
|
122 |
{
|
122 |
for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) {
|
123 |
for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) {
|
123 |
unsigned char c = (unsigned char)*i;
|
124 |
unsigned char c = (unsigned char)*i;
|
124 |
if (c <= 31 || c >= 127 || c == '\"' || c == '\\')
|
125 |
if (c <= 31 || c >= 127 || c == '\"' || c == '\\')
|
125 |
return "{" + toString(s_in.length()) + "}\r\n" + s_in;
|
126 |
return "{" + toString((unsigned long)s_in.length()) + "}\r\n" + s_in;
|
126 |
}
|
127 |
}
|
127 |
|
128 |
|
128 |
return "\"" + s_in + "\"";
|
129 |
return "\"" + s_in + "\"";
|
129 |
}
|
130 |
}
|
130 |
|
131 |
|
|
... |
|
... |
143 |
}
|
144 |
}
|
144 |
|
145 |
|
145 |
//----------------------------------------------------------------------
|
146 |
//----------------------------------------------------------------------
|
146 |
inline void chomp(std::string &s_in, const std::string &chars = " \t\r\n")
|
147 |
inline void chomp(std::string &s_in, const std::string &chars = " \t\r\n")
|
147 |
{
|
148 |
{
|
148 |
int n = s_in.length();
|
149 |
std::string::size_type n = s_in.length();
|
149 |
while (n > 1 && chars.find(s_in[n - 1]) != std::string::npos)
|
150 |
while (n > 1 && chars.find(s_in[n - 1]) != std::string::npos)
|
150 |
s_in.resize(n-- - 1);
|
151 |
s_in.resize(n-- - 1);
|
151 |
}
|
152 |
}
|
152 |
|
153 |
|
153 |
//----------------------------------------------------------------------
|
154 |
//----------------------------------------------------------------------
|
|
... |
|
... |
288 |
BincStream &operator << (unsigned int t);
|
289 |
BincStream &operator << (unsigned int t);
|
289 |
BincStream &operator << (int t);
|
290 |
BincStream &operator << (int t);
|
290 |
BincStream &operator << (char t);
|
291 |
BincStream &operator << (char t);
|
291 |
|
292 |
|
292 |
//--
|
293 |
//--
|
293 |
std::string popString(unsigned int size);
|
294 |
std::string popString(std::string::size_type size);
|
294 |
|
295 |
|
295 |
//--
|
296 |
//--
|
296 |
char popChar(void);
|
297 |
char popChar(void);
|
297 |
void unpopChar(char c);
|
298 |
void unpopChar(char c);
|
298 |
void unpopStr(const std::string &s);
|
299 |
void unpopStr(const std::string &s);
|