-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhuman_readable_format.cc
More file actions
116 lines (97 loc) · 3.08 KB
/
Copy pathhuman_readable_format.cc
File metadata and controls
116 lines (97 loc) · 3.08 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (C) 2011 Red Hat, Inc. All rights reserved.
//
// This file is part of the thin-provisioning-tools source.
//
// thin-provisioning-tools is free software: you can redistribute it
// and/or modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// thin-provisioning-tools is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with thin-provisioning-tools. If not, see
// <http://www.gnu.org/licenses/>.
#include "human_readable_format.h"
#include <iostream>
using namespace std;
using namespace thin_provisioning;
//----------------------------------------------------------------
namespace {
class hr_emitter : public emitter {
public:
hr_emitter(ostream &out)
: out_(out) {
}
void begin_superblock(string const &uuid,
uint64_t time,
uint64_t trans_id,
uint32_t data_block_size,
uint64_t nr_data_blocks,
boost::optional<uint64_t> metadata_snap) {
out_ << "begin superblock: \"" << uuid << "\""
<< ", " << time
<< ", " << trans_id
<< ", " << data_block_size
<< ", " << nr_data_blocks;
if (metadata_snap)
out_ << ", " << metadata_snap;
out_ << endl;
}
void end_superblock() {
out_ << "end superblock" << endl;
}
void begin_device(uint32_t dev_id,
uint64_t mapped_blocks,
uint64_t trans_id,
uint64_t creation_time,
uint64_t snap_time) {
out_ << "device: " << dev_id << endl
<< "mapped_blocks: " << mapped_blocks << endl
<< "transaction: " << trans_id << endl
<< "creation time: " << creation_time << endl
<< "snap time: " << snap_time << endl;
}
void end_device() {
out_ << endl;
}
void begin_named_mapping(string const &name) {
out_ << "begin named mapping"
<< endl;
}
void end_named_mapping() {
out_ << "end named mapping"
<< endl;
}
void identifier(string const &name) {
out_ << "identifier: " << name << endl;
}
void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) {
out_ << " (" << origin_begin
<< ".." << origin_begin + len - 1
<< ") -> (" << data_begin
<< ".." << data_begin + len - 1
<< "), "
<< time
<< endl;
}
void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) {
out_ << " " << origin_block
<< " -> " << data_block
<< ", " << time
<< endl;
}
private:
ostream &out_;
};
}
//----------------------------------------------------------------
thin_provisioning::emitter::ptr
thin_provisioning::create_human_readable_emitter(ostream &out)
{
return emitter::ptr(new hr_emitter(out));
}
//----------------------------------------------------------------