StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AligmentTest.C
1 #include "StArchInfo.h"
2 #include <iostream>
3 using namespace std;
4 int AligmentTest() {
5  cout << "Checking aligments . . . " << endl;
6 
7  cout << " char=" << StArchInfo::align<char>()
8  << " short=" << StArchInfo::align<short>()
9  << " int=" << StArchInfo::align<int>()
10  << " long=" << StArchInfo::align<long>()
11  << " long long=" << StArchInfo::align<long long>()
12  << " float=" << StArchInfo::align<float>()
13  << " double=" << StArchInfo::align<double>()
14  << endl;
15 
16  cout << " char=" << StArchInfo::align(char(0))
17  << " short=" << StArchInfo::align(short(0))
18  << " int=" << StArchInfo::align (int(0))
19  << " long=" << StArchInfo::align (long(0))
20  << " long long=" << StArchInfo::align ((long long)(0))
21  << " float=" << StArchInfo::align (float(0))
22  << " double=" << StArchInfo::align (double(0))
23  << endl;
24 
25  int iProbe;
26  float fProbe;
27  short sProbe;
28  char charProbe;
29  char cProbe[8];
30  double dProbe;
31  long lProbe;
32  long long llProbe;
33 
34  cout << " char=" << StArchInfo::align (charProbe)
35  << " short=" << StArchInfo::align (sProbe)
36  << " int=" << StArchInfo::align (iProbe)
37  << " long=" << StArchInfo::align (lProbe)
38  << " long long=" << StArchInfo::align (llProbe)
39  << " float=" << StArchInfo::align (fProbe)
40  << " double=" << StArchInfo::align (dProbe)
41  << endl;
42 
43 
44  cout << "Checking paddings - the number of the bytes to be added to some type to align the other type properly. . . " << endl;
45 
46  cout
47  << " int to get the char=" << StArchInfo::padding<char>(iProbe) << endl
48  << " int to get the char=" << StArchInfo::padding(iProbe,char(0)) << endl
49  << " float to get the short=" << StArchInfo::padding<short>(fProbe) << endl
50  << " float to get the short=" << StArchInfo::padding(fProbe,short(0)) << endl
51  << " short to get the int=" << StArchInfo::padding<int>(sProbe) << endl
52  << " short to get the int=" << StArchInfo::padding(sProbe,int(0)) << endl
53  << " char to get the long=" << StArchInfo::padding<long>(cProbe[0]) << endl
54  << " char to get the long=" << StArchInfo::padding(cProbe[0],long(0)) << endl
55  << " double to get the long long=" << StArchInfo::padding<long long>(dProbe) << endl
56  << " long to get the float=" << StArchInfo::padding<float>(lProbe) << endl
57  << " long to get the float=" << StArchInfo::padding(lProbe,float(0)) << endl
58  << " char to get the long=" << StArchInfo::padding<long>(cProbe[0]) << endl
59  << " char to get the long=" << StArchInfo::padding(cProbe[0],long(0)) << endl
60  << " char to get the long=" << StArchInfo::padding<long>(cProbe[1]) << endl
61  << " char to get the long=" << StArchInfo::padding(cProbe[1],long(0)) << endl
62  << " char to get the long=" << StArchInfo::padding<long>(cProbe[2]) << endl
63  << " char to get the long=" << StArchInfo::padding(cProbe[2],long(0)) << endl
64  << " char to get the long=" << StArchInfo::padding<long>(cProbe[3]) << endl
65  << " char to get the long=" << StArchInfo::padding(cProbe[3],long(0)) << endl
66  << " char to get the long=" << StArchInfo::padding<long>(cProbe[4]) << endl
67  << " char to get the long=" << StArchInfo::padding(cProbe[4],long(0)) << endl
68  << " char to get the long=" << StArchInfo::padding<long>(cProbe) << endl
69  << " char to get the long=" << StArchInfo::padding(cProbe,long(0)) << endl
70  << " long long to get the double=" << StArchInfo::padding<double>(llProbe) << endl
71  << " long long to get the double=" << StArchInfo::padding(llProbe,double(0)) << endl
72  ;
73 
74 
75  return StArchInfo::align(long(0));
76 }
static int align()
This is an overloaded member function, provided for convenience.
Definition: StArchInfo.h:51
static int padding(const T &offset)
Returns the number of bytes to be added to the offset of the T type to get the C type proper aligned...
Definition: StArchInfo.h:67