File: utils.hh

package info (click to toggle)
zbackup 1.5-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 868 kB
  • sloc: cpp: 6,957; ansic: 468; python: 207; makefile: 10
file content (50 lines) | stat: -rw-r--r-- 1,446 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012-2014 Konstantin Isakov <ikm@zbackup.org> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE

#ifndef UTILS_HH_INCLUDED
#define UTILS_HH_INCLUDED

#include <sstream>
#include <string>
#include <vector>

#define VALID_SUFFIXES "Valid suffixes:\n" \
"|--------|----------------|----------|\n" \
"| suffix | multiplier     | name     |\n" \
"|--------|----------------|----------|\n" \
"| B      | 1              | byte     |\n" \
"| KiB    | 1024           | kibibyte |\n" \
"| MiB    | 1024*1024      | mebibyte |\n" \
"| GiB    | 1024*1024*1024 | gibibyte |\n" \
"| KB     | 1000           | kilobyte |\n" \
"| MB     | 1000*1000      | megabyte |\n" \
"| GB     | 1000*1000*1000 | gigabyte |\n" \
"|--------|----------------|----------|\n"

namespace Utils {
using std::string;
using std::vector;

/// Recreate source directory structure in destination
vector< string > findOrRebuild( string const & src,
    string const & dst = std::string(),
    string const & relativePath = std::string() );

unsigned int getScale( char * );

/// Converts 'size' bytes pointed to by 'in' into a hex string
std::string toHex( unsigned char const * in, unsigned size );

std::string toHex( string const & );

template <typename T>
string numberToString( T pNumber )
{
  std::ostringstream oOStrStream;
  oOStrStream << pNumber;
  return oOStrStream.str();
}

}

#endif