1 | #include "molecules.hpp"
|
---|
2 |
|
---|
3 | /** Prints the tabs according to verbosity stored in the temporary constructed class.
|
---|
4 | * \param &ost stream to extend with tabs
|
---|
5 | * \return &ost stream with tabs
|
---|
6 | */
|
---|
7 | ostream& Verbose::print (ostream &ost) const
|
---|
8 | {
|
---|
9 | for (int i=0;i<Verbosity;i++)
|
---|
10 | ost.put('\t');
|
---|
11 | //cout << "Verbose(.) called." << endl;
|
---|
12 | return ost;
|
---|
13 | };
|
---|
14 |
|
---|
15 | /** Operator for the Verbose(arg) call.
|
---|
16 | * Constructs temporary a Verbose class object, wherein the verbosity is stored.
|
---|
17 | * Then << is called, which calls Verbose's print which adds the tabs and returns the stream.
|
---|
18 | * \param &ost stream to extend
|
---|
19 | * \param &m pointer to created Verbose object
|
---|
20 | * \return &ost
|
---|
21 | */
|
---|
22 | ostream& operator<<(ostream& ost,const Verbose& m)
|
---|
23 | {
|
---|
24 | return m.print(ost);
|
---|
25 | };
|
---|
26 |
|
---|
27 |
|
---|
28 | /** Prints the tabs according to verbosity stored in the temporary constructed class.
|
---|
29 | * Note that highest bit is set artificially to give number of bits to print
|
---|
30 | * \param &ost stream to extend with tabs
|
---|
31 | * \return &ost stream with tabs
|
---|
32 | */
|
---|
33 | ostream& Binary::print (ostream &ost) const
|
---|
34 | {
|
---|
35 | int bits = 1, counter = 1;
|
---|
36 | while ((bits = 1 << counter) < BinaryNumber)
|
---|
37 | counter++;
|
---|
38 | for (int i=0;i<counter-1;i++) {
|
---|
39 | if ((BinaryNumber & (1 << i)) == 0)
|
---|
40 | ost.put('0');
|
---|
41 | else
|
---|
42 | ost.put('1');
|
---|
43 | }
|
---|
44 | ost.put('b');
|
---|
45 | //cout << "Binary(.) called." << endl;
|
---|
46 | return ost;
|
---|
47 | };
|
---|
48 |
|
---|
49 | /** Operator for the Binary(arg) call.
|
---|
50 | * Constructs temporary a Verbose class object, wherein the Binary is stored.
|
---|
51 | * Then << is called, which calls Binary's print which adds the tabs and returns the stream.
|
---|
52 | * \param &ost stream to extend
|
---|
53 | * \param &m pointer to created Binary object
|
---|
54 | * \return &ost
|
---|
55 | */
|
---|
56 | ostream& operator<<(ostream& ost,const Binary& m)
|
---|
57 | {
|
---|
58 | return m.print(ost);
|
---|
59 | };
|
---|