Cryptography Reference
In-Depth Information
// ...
private:
// ...
static long flagsindex;
static LintInit setup;
// ...
};
Setting the variable setup as static has the effect that this variable exists only
once for all LINT objects and thus the associated constructor LintInit() is called
only once.
We would like now to pause for a moment and consider what all this effort
nets us. Setting the output format could just as well be managed via a status
variable, which as a member of LINT would be much simpler to deal with. The
decisive advantage of the method that we have chosen is that the output format
can be set for each output stream separately and independently of the others (cf.
[Pla2], page 125), which could not be accomplished with an internal LINT status
variable. This is done through the power of the class ios , whose mechanisms we
employ for such purposes.
Now that the preliminaries have been taken care of, we can define the status
functions as member functions of LINT . These are displayed in Table 15-1.
We shall consider as an example of the implementation of the status functions
the function LINT::setf() , which returns the current value of the status variable
as a long with reference to an output stream:
long LINT::setf (ostream& s, long flag)
{
long t = s.iword (flagsindex);
// the flags for the basis of the numerical representation
// are mutually exclusive
if (flag & LINT::lintdec)
{
s.iword (flagsindex) = (t & ˜ LINT::linthex & ˜ LINT::lintoct
& ˜ LINT::lintbin) | LINT::lintdec;
flag ˆ = LINT::lintdec;
}
if (flag & LINT::linthex)
{
s.iword (flagsindex) = (t & ˜ LINT::lintdec & ˜ LINT::lintoct
& ˜ LINT::lintbin) | LINT::linthex;
flag ˆ = LINT::linthex;
}
if (flag & LINT::lintoct)
{
 
Search WWH ::




Custom Search