Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JManip.cc File Reference

Example program to test I/O manipulators. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "JLang/JManip.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Example program to test I/O manipulators.

Author
mdejong

Definition in file JManip.cc.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 54 of file JManip.cc.

55 {
56  using namespace std;
57  using namespace JPP;
58 
59  int debug;
60 
61  try {
62 
63  JParser<> zap;
64 
65  zap['d'] = make_field(debug) = 1;
66 
67  zap(argc, argv);
68  }
69  catch(const exception &error) {
70  FATAL(error.what() << endl);
71  }
72 
73  for (int value = 1; value < 1000000000; value *= 10) {
74  cout << "CENTER <" << CENTER(12) << value << ">" << endl;
75  }
76 
77  for (int value = 1; value < 1000000000; value *= 10) {
78  cout << "FILL <" << FILL(12,'.') << value << ">" << FILL() << endl;
79  }
80 
81  for (int value = 1; value < 1000000000; value *= 10) {
82  cout << "RIGHT <" << RIGHT(12) << value << ">" << endl;
83  }
84 
85  for (int value = 1; value < 1000000000; value *= 10) {
86  cout << "LEFT <" << LEFT(12) << value << ">" << endl;
87  }
88 
89  for (double value = 0.123456; value < 100000; value *= 10) {
90  cout << "FIXED <" << FIXED(12,6) << value << ">" << endl;
91  }
92 
93 
94  {
95  const double c = 12.34;
96 
97  const A a(c);
98  const B b(c);
99 
100  cout << "A "; print(cout, getFormat<A>()); cout << " <" << a << ">" << endl;
101  cout << "c "; cout << setw(5) << " "; cout << " <" << c << ">" << endl;
102  cout << "B "; print(cout, getFormat<B>()); cout << " <" << b << ">" << endl;
103  cout << "c "; cout << setw(5) << " "; cout << " <" << c << ">" << endl;
104 
105  setFormat<A>(JFormat_t(7, 3, std::ios::fixed));
106  setFormat<B>(JFormat_t(7, 3, std::ios::fixed));
107 
108  cout << "A "; print(cout, getFormat<A>()); cout << " <" << a << ">" << endl;
109  cout << "c "; cout << setw(5) << " "; cout << " <" << c << ">" << endl;
110  cout << "B "; print(cout, getFormat<B>()); cout << " <" << b << ">" << endl;
111  cout << "c "; cout << setw(5) << " "; cout << " <" << c << ">" << endl;
112  }
113 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445
Auxiliary data structure for alignment of data.
Definition: JManip.hh:365
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:327
#define FATAL(A)
Definition: JMessage.hh:67
then JCalibrateToT a
Definition: JTuneHV.sh:103
Data structure for format specifications.
Definition: JManip.hh:521
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A