24 #include "ObjCryst/Quirks/VFNStreamFormat.h" 
   25 #include "ObjCryst/Quirks/VFNDebug.h" 
   35 FormatInt::FormatInt(
const long num,
const int width): mValue(num),mWidth(width) {}
 
   36 FormatInt::~FormatInt(){}
 
   40    return os << setiosflags(ios::right) << setw(fInt.mWidth) <<
 
   50 FormatFloat::FormatFloat(
const REAL num,
const int width,
const int precision)
 
   51          :mValue(num),mWidth(width),mPrecision(precision)
 
   54 FormatFloat::~FormatFloat(){}
 
   58    std::istream::fmtflags old_flags=os.flags();
 
   59    os.setf( std::istream::fixed | std::istream::right | std::istream::showpoint,std::istream::floatfield );
 
   60    std::streamsize old_prec = os.precision(fFloat.mPrecision);
 
   61    std::streamsize old_width = os.width(fFloat.mWidth);
 
   63    os.flags( old_flags );
 
   64    os.precision( old_prec );
 
   74 FormatString::FormatString(
const string &str,
const unsigned int width):
 
   79    if(mString.size() > mWidth) mString.resize(mWidth);
 
   81       for(
unsigned int i=mString.size();i<width;i++) mString += 
" ";
 
   85 FormatString::~FormatString(){}
 
   86 int FormatString::length()
 const {
return mString.length();}
 
   90    return os << fStr.mString ;
 
  101                                     const int precision, 
const int nb):
 
  102 mWidth(width),mPrecision(precision),mNb(nb)
 
  104    mvpVectors.push_back(&fVect);
 
  110                                     const int precision, 
const int nb):
 
  111 mWidth(width),mPrecision(precision),mNb(nb)
 
  113    mvpVectors.push_back(&fVect1);
 
  114    mvpVectors.push_back(&fVect2);
 
  121                                     const int precision, 
const int nb):
 
  122 mWidth(width),mPrecision(precision),mNb(nb)
 
  124    mvpVectors.push_back(&fVect1);
 
  125    mvpVectors.push_back(&fVect2);
 
  126    mvpVectors.push_back(&fVect3);
 
  134                                     const int precision, 
const int nb):
 
  135 mWidth(width),mPrecision(precision),mNb(nb)
 
  137    mvpVectors.push_back(&fVect1);
 
  138    mvpVectors.push_back(&fVect2);
 
  139    mvpVectors.push_back(&fVect3);
 
  140    mvpVectors.push_back(&fVect4);
 
  148                                     const int precision, 
const int nb):
 
  149 mWidth(width),mPrecision(precision),mNb(nb)
 
  151    mvpVectors.push_back(&fVect1);
 
  152    mvpVectors.push_back(&fVect2);
 
  153    mvpVectors.push_back(&fVect3);
 
  154    mvpVectors.push_back(&fVect4);
 
  155    mvpVectors.push_back(&fVect5);
 
  164                                     const int precision, 
const int nb):
 
  165 mWidth(width),mPrecision(precision),mNb(nb)
 
  167    mvpVectors.push_back(&fVect1);
 
  168    mvpVectors.push_back(&fVect2);
 
  169    mvpVectors.push_back(&fVect3);
 
  170    mvpVectors.push_back(&fVect4);
 
  171    mvpVectors.push_back(&fVect5);
 
  172    mvpVectors.push_back(&fVect6);
 
  178                                    const int precision, 
const int nb):
 
  179 mWidth(width),mPrecision(precision),mNb(nb)
 
  181    for(
int i=0;i<nbVect;i++) mvpVectors.push_back(&(pVect[i]));
 
  188                                    const int precision, 
const int nb):
 
  189 mWidth(width),mPrecision(precision),mNb(nb)
 
  191    mvpVectors.push_back(&fVect1);
 
  192    for(
int i=1;i<nbVect;i++) mvpVectors.push_back(&(pVect[i-1]));
 
  198                               const int precision, 
const int nb):
 
  199 mWidth(width),mPrecision(precision),mNb(nb)
 
  208 template<
class T> ostream& operator<< (ostream &os, const FormatVertVector<T> &fVect)
 
  210    VFN_DEBUG_MESSAGE(
"ostream& operator<<(os,FormatVertVector<T>)",3)
 
  213    std::istream::fmtflags old_flags=os.flags();
 
  214    os.setf( 
std::istream::fixed | 
std::istream::right | 
std::istream::showpoint);
 
  215    std::streamsize old_prec = os.precision(fVect.mPrecision);
 
  216    std::streamsize old_width = os.width();
 
  218    if(nb==0)nb=(fVect.mvpVectors[0])->numElements();
 
  221       for(j=0;j<fVect.mvpVectors.size();j++)
 
  223          os <<setw(fVect.mWidth)<< (*fVect.mvpVectors[j])(i) << 
" ";
 
  227    os.flags( old_flags );
 
  228    os.precision( old_prec );
 
  230    VFN_DEBUG_MESSAGE(
"ostream& operator<<(os,FormatVertVector<T>):End",2)
 
  242                                     const 
int precision):
 
  243 mWidth(width),mPrecision(precision)
 
  250 template<
class T> ostream& operator<< (ostream &os, const FormatHorizVector<T> &fVect)
 
  253    std::istream::fmtflags old_flags=os.flags();
 
  254    os.setf( std::istream::fixed | std::istream::right | std::istream::showpoint);
 
  255    std::streamsize old_prec = os.precision(fVect.mPrecision);
 
  256    std::streamsize old_width = os.width();
 
  257    for(i=0;i<(*(fVect.mpVectors)).numElements();i++)
 
  259       os <<setw(fVect.mWidth)<< (*(fVect.mpVectors))(i) << 
" ";
 
  262    os.flags( old_flags );
 
  263    os.precision( old_prec );
 
  280 mWidth(width),mPrecision(precision),mNb(nb)
 
  282    mvpVectors.push_back(&h);
 
  283    mvpVectors.push_back(&k);
 
  284    mvpVectors.push_back(&l);
 
  294 mWidth(width),mPrecision(precision),mNb(nb)
 
  296    mvpVectors.push_back(&h);
 
  297    mvpVectors.push_back(&k);
 
  298    mvpVectors.push_back(&l);
 
  299    mvpVectors.push_back(&m);
 
  310 mWidth(width),mPrecision(precision),mNb(nb)
 
  312    mvpVectors.push_back(&h);
 
  313    mvpVectors.push_back(&k);
 
  314    mvpVectors.push_back(&l);
 
  315    mvpVectors.push_back(&m);
 
  316    mvpVectors.push_back(&n);
 
  328 mWidth(width),mPrecision(precision),mNb(nb)
 
  330    mvpVectors.push_back(&h);
 
  331    mvpVectors.push_back(&k);
 
  332    mvpVectors.push_back(&l);
 
  333    mvpVectors.push_back(&m);
 
  334    mvpVectors.push_back(&n);
 
  335    mvpVectors.push_back(&o);
 
  348 mWidth(width),mPrecision(precision),mNb(nb)
 
  350    mvpVectors.push_back(&h);
 
  351    mvpVectors.push_back(&k);
 
  352    mvpVectors.push_back(&l);
 
  353    mvpVectors.push_back(&m);
 
  354    mvpVectors.push_back(&n);
 
  355    mvpVectors.push_back(&o);
 
  356    mvpVectors.push_back(&p);
 
  370 mWidth(width),mPrecision(precision),mNb(nb)
 
  372    mvpVectors.push_back(&h);
 
  373    mvpVectors.push_back(&k);
 
  374    mvpVectors.push_back(&l);
 
  375    mvpVectors.push_back(&m);
 
  376    mvpVectors.push_back(&n);
 
  377    mvpVectors.push_back(&o);
 
  378    mvpVectors.push_back(&p);
 
  379    mvpVectors.push_back(&q);
 
  394 mWidth(width),mPrecision(precision),mNb(nb)
 
  396    mvpVectors.push_back(&h);
 
  397    mvpVectors.push_back(&k);
 
  398    mvpVectors.push_back(&l);
 
  399    mvpVectors.push_back(&m);
 
  400    mvpVectors.push_back(&n);
 
  401    mvpVectors.push_back(&o);
 
  402    mvpVectors.push_back(&p);
 
  403    mvpVectors.push_back(&q);
 
  404    mvpVectors.push_back(&r);
 
  420 mWidth(width),mPrecision(precision),mNb(nb)
 
  422    mvpVectors.push_back(&h);
 
  423    mvpVectors.push_back(&k);
 
  424    mvpVectors.push_back(&l);
 
  425    mvpVectors.push_back(&m);
 
  426    mvpVectors.push_back(&n);
 
  427    mvpVectors.push_back(&o);
 
  428    mvpVectors.push_back(&p);
 
  429    mvpVectors.push_back(&q);
 
  430    mvpVectors.push_back(&r);
 
  431    mvpVectors.push_back(&s);
 
  448 mWidth(width),mPrecision(precision),mNb(nb)
 
  450    mvpVectors.push_back(&h);
 
  451    mvpVectors.push_back(&k);
 
  452    mvpVectors.push_back(&l);
 
  453    mvpVectors.push_back(&m);
 
  454    mvpVectors.push_back(&n);
 
  455    mvpVectors.push_back(&o);
 
  456    mvpVectors.push_back(&p);
 
  457    mvpVectors.push_back(&q);
 
  458    mvpVectors.push_back(&r);
 
  459    mvpVectors.push_back(&s);
 
  460    mvpVectors.push_back(&t);
 
  478 mWidth(width),mPrecision(precision),mNb(nb)
 
  480    mvpVectors.push_back(&h);
 
  481    mvpVectors.push_back(&k);
 
  482    mvpVectors.push_back(&l);
 
  483    mvpVectors.push_back(&m);
 
  484    mvpVectors.push_back(&n);
 
  485    mvpVectors.push_back(&o);
 
  486    mvpVectors.push_back(&p);
 
  487    mvpVectors.push_back(&q);
 
  488    mvpVectors.push_back(&r);
 
  489    mvpVectors.push_back(&s);
 
  490    mvpVectors.push_back(&t);
 
  491    mvpVectors.push_back(&u);
 
  496                               const int precision, 
const int nb):
 
  497 mWidth(width),mPrecision(precision),mNb(nb)
 
  505 template<
class T> ostream& operator<< (ostream& os, const FormatVertVectorHKLFloats<T> &fVect)
 
  509    std::istream::fmtflags old_flags=os.flags();
 
  510    os.setf( std::istream::fixed | std::istream::right | std::istream::showpoint);
 
  511    std::streamsize old_prec = os.precision(fVect.mPrecision);
 
  512    std::streamsize old_width = os.width();
 
  514    if(nb==0) nb=(fVect.mvpVectors[0])->numElements();
 
  519          os <<setw(fVect.mWidth-fVect.mPrecision)<< (int) ((*fVect.mvpVectors[j])(i)) << 
" ";
 
  521       for(j=3;j<fVect.mvpVectors.size();j++)
 
  523          os <<setw(fVect.mWidth)<<(*fVect.mvpVectors[j])(i) << 
" ";
 
  527    os.flags( old_flags );
 
  528    os.precision( old_prec );
 
  536 template ostream& operator<< (ostream&,const FormatVertVector<REAL>&);
 
  538 template ostream& operator<< (ostream&,const FormatHorizVector<REAL>&);
 
  540 template ostream& operator<< (ostream&,const FormatVertVectorHKLFloats<REAL>&);
 
  542 template ostream& operator<< (ostream&,const FormatVertVector<long>&);
 
  544 template ostream& operator<< (ostream&,const FormatHorizVector<long>&);
 
  546 template ostream& operator<< (ostream&,const FormatVertVectorHKLFloats<long>&);
 
output a number as a formatted integer: 
ostream & operator<<(ostream &os, const XMLCrystTag &tag)
Output an XMLCrystTag to a stream. 
Output vectors as column arrays, with the first 3 columns printed as integers. 
output one or several vectors as (a) column(s): 
Format vector as horiz array: 
Vector library (Blitz++ mimic) for ObjCryst++. 
output a number as a formatted float: 
output a string with a fixed length (adding necessary space or removing excess characters) : ...