Skip to content

Commit

Permalink
Make -[vMAT_Array dump] output slightly more legible; now at least it…
Browse files Browse the repository at this point in the history
… does columns.
  • Loading branch information
kaelin committed Apr 8, 2013
1 parent 312171d commit c42f597
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions vMAT/vMAT_Array+UnaryOps.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ - (vMAT_Array *)mtrans;
template <typename T>
struct render {
NSMutableString * dump;
render(NSMutableString * dump) : dump(dump) { }
void operator()(T a) const
const int columns;
long count;
render(NSMutableString * dump, int columns) : dump(dump), columns(columns), count(0) { }
void operator()(T a)
{
stringstream out;
out.width(13);
out.fill(' ');
out << a;
[dump appendFormat:@"%s ", out.str().c_str()];
if (++count % columns == 0) out << "\n";
else out << " ";
[dump appendFormat:@"%s", out.str().c_str()];
}
};

Expand All @@ -51,7 +57,8 @@ void operator()(T a) const
NSMutableString * dump = [NSMutableString stringWithString:prefix];
[dump appendString:@" = \n"];
vector<T> vecA(A, A + vMAT_Size_prod(sizeA));
for_each(vecA.begin(), vecA.end(), render<T>(dump));
render<T> renderer(dump, sizeA[0]);
for_each(vecA.begin(), vecA.end(), renderer);
return dump;
}

Expand Down

0 comments on commit c42f597

Please sign in to comment.