- Set a default PCM volume so that something can be heard when driver is
[AROS.git] / test / uae-tmpl / be_val
blob6c8df92c98b0ed013ac6b36fc644432a16a4ea69
1 // #include <map>
2 #include <netinet/in.h>
3 #include "be_conv"
5 // using namespace std;
7 template<class T> // big endian value
8 class be_val
10   public:
11     typedef T value_type;
12     typedef be_val<value_type> my_type;
14 #ifdef DEBUG
15     /* Debugging */
16     inline void print ()
17     {
18       unsigned long *lp = (unsigned long *)((void *) &data);
19       printf ("%08lx", *lp);
20     }
21 #endif
23     be_val () {}
25     // explicit: this constructor is not used
26     //           for automatic type promotion
27     explicit be_val (value_type d) : data (ne2be (d)) {}
29     be_val (const my_type& other)
30     {
31       data = other.data;
32     }
34     operator value_type () const
35     {
36       return static_cast<value_type> (be2ne (data));
37     }
38     const my_type& operator= (const value_type d)
39     {
40       *this = my_type (d);
41       return *this;
42     }
43     const my_type& operator++ () // pre increment operator
44     {
45       value_type tmp = static_cast<value_type> (*this);
46       return *this = my_type (++tmp);
47     }
48     const my_type operator++ (int) // post increment operator
49     {
50       my_type tmp = *this;
51       (*this)++;
52       return tmp;
53     }
54     const my_type& operator-- () // pre increment operator
55     {
56       value_type tmp = static_cast<value_type> (*this);
57       return *this = my_type (--tmp);
58     }
59     const my_type operator-- (int) // post increment operator
60     {
61       my_type tmp = *this;
62       (*this)--;
63       return tmp;
64     }
65     const my_type& operator+= (const my_type& other)
66     {
67       *this = *this + other;
68     }
69     const my_type& operator-= (const my_type& other)
70     {
71       *this = *this - other;
72     }
73     const my_type& operator*= (const my_type& other)
74     {
75       *this = *this * other;
76     }
77     const my_type& operator/= (const my_type& other)
78     {
79       *this = *this / other;
80     }
81     const my_type& operator&= (const my_type& other)
82     {
83       *this = *this & other;
84     }
85     const my_type& operator|= (const my_type& other)
86     {
87       *this = *this | other;
88     }
89     const my_type& operator%= (const my_type& other)
90     {
91       *this = *this % other;
92     }
93     const my_type& operator^= (const my_type& other)
94     {
95       *this = *this ^ other;
96     }
97     const my_type& operator<<= (const my_type& other)
98     {
99       *this = *this << other;
100     }
101     const my_type& operator>>= (const my_type& other)
102     {
103       *this = *this >> other;
104     }
106   protected:
107     value_type data;
110 template<class C>
111 inline const be_val<C> operator+ (const be_val<C>& a, const be_val<C>& b)
113   return be_val<C>(static_cast<C> (a) + static_cast<C> (b));
116 template<class C>
117 inline const be_val<C> operator- (const be_val<C>& a, const be_val<C>& b)
119   return be_val<C>(static_cast<C> (a) - static_cast<C> (b));
122 template<class C>
123 inline const be_val<C> operator* (const be_val<C>& a, const be_val<C>& b)
125   return be_val<C>(static_cast<C> (a) * static_cast<C> (b));
128 template<class C>
129 inline const be_val<C> operator/ (const be_val<C>& a, const be_val<C>& b)
131   return be_val<C>(static_cast<C> (a) / static_cast<C> (b));
134 template<class C>
135 inline const be_val<C> operator% (const be_val<C>& a, const be_val<C>& b)
137   return be_val<C>(static_cast<C> (a) % static_cast<C> (b));
140 template<class C>
141 inline const be_val<C> operator^ (const be_val<C>& a, const be_val<C>& b)
143   return be_val<C>(static_cast<C> (a) ^ static_cast<C> (b));
146 template<class C>
147 inline const be_val<C> operator& (const be_val<C>& a, const be_val<C>& b)
149   return be_val<C>(static_cast<C> (a) & static_cast<C> (b));
152 template<class C>
153 inline const be_val<C> operator| (const be_val<C>& a, const be_val<C>& b)
155   return be_val<C>(static_cast<C> (a) | static_cast<C> (b));
158 template<class C>
159 inline const be_val<C> operator<< (const be_val<C>& a, const be_val<C>& b)
161   return be_val<C>(static_cast<C> (a) << static_cast<C> (b));
164 template<class C>
165 inline const be_val<C> operator>> (const be_val<C>& a, const be_val<C>& b)
167   return be_val<C>(static_cast<C> (a) >> static_cast<C> (b));
170 template<class C>
171 inline bool operator< (const be_val<C>& a, const be_val<C>& b)
173   return static_cast<C> (a) < static_cast<C> (b);
176 template<class C>
177 inline bool operator> (const be_val<C>& a, const be_val<C>& b)
179   return static_cast<C> (a) > static_cast<C> (b);
182 template<class C>
183 inline bool operator<= (const be_val<C>& a, const be_val<C>& b)
185   return static_cast<C> (a) <= static_cast<C> (b);
188 template<class C>
189 inline bool operator>= (const be_val<C>& a, const be_val<C>& b)
191   return static_cast<C> (a) >= static_cast<C> (b);
194 template<class C>
195 inline bool operator== (const be_val<C>& a, const be_val<C>& b)
197   return static_cast<C> (a) == static_cast<C> (b);
200 template<class C>
201 inline bool operator!= (const be_val<C>& a, const be_val<C>& b)
203   return static_cast<C> (a) != static_cast<C> (b);