~ubuntu-branches/ubuntu/quantal/aria2/quantal

« back to all changes in this revision

Viewing changes to src/util.h

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2011-11-08 20:25:08 UTC
  • mfrom: (2.5.7 sid)
  • Revision ID: package-import@ubuntu.com-20111108202508-scfph8rj6tz0cckk
Tags: 1.13.0-1
* New upstream version:
  + Depends on libgcrypt11 (>= 1.5.0-3) (Closes: #642989)

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
inline uint64_t hton64(uint64_t x) { return byteswap64(x); }
87
87
#endif // !WORDS_BIGENDIAN
88
88
 
 
89
#ifdef __MINGW32__
 
90
std::wstring utf8ToWChar(const std::string& src);
 
91
 
 
92
std::wstring utf8ToWChar(const char* str);
 
93
 
 
94
std::string utf8ToNative(const std::string& src);
 
95
 
 
96
std::string wCharToUtf8(const std::wstring& wsrc);
 
97
 
 
98
std::string nativeToUtf8(const std::string& src);
 
99
#else // !__MINGW32__
 
100
# define utf8ToWChar(src) src
 
101
# define utf8ToNative(src) src
 
102
#endif // !__MINGW32__
 
103
 
89
104
namespace util {
90
105
 
91
106
void divide
157
172
 
158
173
std::string percentEncode(const std::string& target);
159
174
 
 
175
std::string percentEncodeMini(const std::string& target);
 
176
 
160
177
bool inRFC3986ReservedChars(const char c);
161
178
 
162
179
bool inRFC3986UnreservedChars(const char c);
246
263
 
247
264
std::string abbrevSize(int64_t size);
248
265
 
249
 
template<typename InputIterator>
 
266
template<typename InputIterator, typename Output>
250
267
void toStream
251
 
(InputIterator first, InputIterator last, std::ostream& os)
 
268
(InputIterator first, InputIterator last, Output& os)
252
269
{
253
 
  os << _("Files:") << "\n";
254
 
  os << "idx|path/length" << "\n";
255
 
  os << "===+===========================================================================" << "\n";
 
270
  os.printf("%s\n"
 
271
            "idx|path/length\n"
 
272
            "===+===========================================================================\n", _("Files:"));
256
273
  int32_t count = 1;
257
274
  for(; first != last; ++first, ++count) {
258
 
    os << std::setw(3) << count << "|" << (*first)->getPath() << "\n";
259
 
    os << "   |" << util::abbrevSize((*first)->getLength()) << "B ("
260
 
       << util::uitos((*first)->getLength(), true) << ")\n";
261
 
    os << "---+---------------------------------------------------------------------------" << "\n";
 
275
    os.printf("%3d|%s\n"
 
276
              "   |%sB (%s)\n"
 
277
              "---+---------------------------------------------------------------------------\n",
 
278
              count,
 
279
              (*first)->getPath().c_str(),
 
280
              util::abbrevSize((*first)->getLength()).c_str(),
 
281
              util::uitos((*first)->getLength(), true).c_str());
262
282
  }
263
283
}
264
284