Skip to content
Snippets Groups Projects
Commit 7fb466c6 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

starting to use boost/format to replace the worst printf constructs

parent 16afed03
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@
#include <math.h>
#include <iostream>
#include <algorithm>
#include <boost/format.hpp>
#include "mystd.h"
#include "olm.h"
......@@ -19,6 +20,7 @@
#include "index.h"
using namespace std;
using boost::format;
namespace NEdif {
CParam* RFind(CEle* e, CCoord OneR);
......@@ -38,53 +40,50 @@ void NEdif::Dir(void)
c = e->C();
d = e->D();
// prepare ztext
char ztext[17];
string ztext;
if( e->P()->nZ() ){
if ( e->P()->ZCo.size()==1 )
sprintf( ztext, "%16s",
e->P()->ZCo[0].str().substr(0,16).c_str() );
ztext = str( format( "%-s16" ) % e->P()->ZCo[0].str() );
else if( e->P()->ZCo.size()==2 )
sprintf( ztext, "%16s",
( e->P()->ZCo[0].str().substr(0,10) + ", " +
e->P()->ZCo[1].str().substr(0,4) ).c_str() );
ztext = str( format( "%-10s, %-4s" ) %
e->P()->ZCo[0].str() %
e->P()->ZCo[1].str() );
else if( e->P()->ZCo.size()==3 )
sprintf( ztext, "%16s",
( e->P()->ZCo[0].str().substr(0,5) + ", " +
e->P()->ZCo[1].str().substr(0,4) + ", " +
e->P()->ZCo[2].str().substr(0,3) ).c_str() );
ztext = str( format( "%-5s, %-4s, %-3s" ) %
e->P()->ZCo[0].str() %
e->P()->ZCo[1].str() %
e->P()->ZCo[2].str() );
else
sprintf( ztext, "%16s",
( e->P()->ZCo[0].str().substr(0,4) + ", " +
e->P()->ZCo[1].str().substr(0,3) + ", " +
e->P()->ZCo[2].str().substr(0,2) + " &c"
).c_str() );
ztext = str( format( "%-3s, %-2s, %-1s &c" ) %
e->P()->ZCo[0].str() %
e->P()->ZCo[1].str() %
e->P()->ZCo[2].str() );
} else {
sprintf( ztext, "" );
ztext = str( format("%-16s") % "" );
}
// prepare xytext
char xytext[33];
string xytext;
if( d ) {
uint npts = e->nPts();
string txtpts;
if (npts)
txtpts = strg(npts);
txtpts = str( format( "%-6d" ) % npts );
else
txtpts = "?";
sprintf( xytext, "%6s %-12s %-12s",
txtpts.c_str(),
e->P()->xco.str().substr(0,12).c_str(),
e->P()->yco.str().substr(0,12).c_str() );
txtpts = " ?";
xytext = txtpts + str( format( "%-12s %-12s" ) %
e->P()->xco.str() %
e->P()->yco.str() );
} else if ( c ) {
snprintf( xytext, 33, "%-32s", c->expr.c_str() );
xytext = c->expr;
}
// print everything
printf( "%3d%1s%-16s %5d %-16s %-32s\n",
iter.SelNo(),
e->P()->as_on_disk ? "=" : " ",
e->P()->name.substr(0,16).c_str(),
e->nScan(),
ztext,
xytext );
cout << format( "%3d%1s%-16s %5d %-16s %-32s\n" ) %
iter.SelNo() %
( e->P()->as_on_disk ? "=" : " " ) %
e->P()->name %
e->nScan() %
ztext %
xytext;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment