aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/myriad.cpp59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/tools/myriad.cpp b/src/tools/myriad.cpp
index 346cd85..0dd9840 100644
--- a/src/tools/myriad.cpp
+++ b/src/tools/myriad.cpp
@@ -94,6 +94,49 @@ Bu::Formatter &operator>>( Bu::Formatter &f, Mode & /*e*/ )
94 return f; 94 return f;
95} 95}
96 96
97void printMap( const Bu::BitString &bs )
98{
99 for( int j = 0; j < bs.getSize(); j++ )
100 {
101 if( j>0 && (j%50) == 0 )
102 Bu::println("");
103 if( bs.getBit( j ) )
104 Bu::print("#");
105 else
106 Bu::print("-");
107 }
108 Bu::println("\n");
109}
110
111void printMap( const Bu::Array<int32_t> &bm )
112{
113 int iBigest = 0;
114 for( int j = 0; j < bm.getSize(); j++ )
115 {
116 if( iBigest < bm[j] )
117 iBigest = bm[j];
118 }
119 int iWidth = Bu::String("%1").arg( iBigest ).end().getSize();
120 Bu::String sEmpty;
121 for( int j = 0; j < iWidth; j++ )
122 {
123 sEmpty += '-';
124 }
125 int iBreakAt = 60/(iWidth+1);
126 for( int j = 0; j < bm.getSize(); j++ )
127 {
128 if( j>0 && (j%iBreakAt) == 0 )
129 Bu::println("");
130
131 if( bm[j] < 0 )
132 Bu::print("%1 ").arg( sEmpty, Bu::Fmt(2).right().fill(' '));
133 else
134 Bu::print("%1 ").arg( bm[j], Bu::Fmt(2).right().fill(' '));
135
136 }
137 Bu::println("\n");
138}
139
97int main( int argc, char *argv[] ) 140int main( int argc, char *argv[] )
98{ 141{
99 Options opts( argc, argv ); 142 Options opts( argc, argv );
@@ -168,6 +211,8 @@ int main( int argc, char *argv[] )
168 File fOut( opts.sFile, File::Write|File::Read ); 211 File fOut( opts.sFile, File::Write|File::Read );
169 Myriad m( fOut ); 212 Myriad m( fOut );
170 m.erase( opts.iStream ); 213 m.erase( opts.iStream );
214 printMap( m.buildBlockUseMap() );
215 printMap( m.buildBlockMap() );
171 } 216 }
172 break; 217 break;
173 218
@@ -273,17 +318,8 @@ int main( int argc, char *argv[] )
273 { 318 {
274 File fIn( opts.sFile, File::Write|File::Read ); 319 File fIn( opts.sFile, File::Write|File::Read );
275 Myriad m( fIn ); 320 Myriad m( fIn );
276/* Bu::BitString bs = m.getBlocksUsed(); 321 printMap( m.buildBlockUseMap() );
277 for( int j = 0; j < bs.getSize(); j++ ) 322 printMap( m.buildBlockMap() );
278 {
279 if( j>0 && (j%50) == 0 )
280 Bu::println("");
281 if( bs.getBit( j ) )
282 Bu::print("#");
283 else
284 Bu::print("-");
285 }*/
286 Bu::println("\n");
287 } 323 }
288 break; 324 break;
289 325
@@ -295,4 +331,3 @@ int main( int argc, char *argv[] )
295 331
296 return 0; 332 return 0;
297} 333}
298