00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <Stiostream.h>
00030 #include "StGlobals.hh"
00031 #include "StGetConfigValue.hh"
00032 #include "StThreeVector.hh"
00033 #include <vector>
00034 #include <unistd.h>
00035 #if !defined(ST_NO_NAMESPACES)
00036 using std::vector;
00037 #endif
00038
00039 int main()
00040 {
00041 const char* filename = "example.conf";
00042
00043 if (access(filename, R_OK)) {
00044 cerr << "Cannot access file '" << filename << "'" << endl;
00045 return 1;
00046 }
00047
00048 double singleValue = 10;
00049 StGetConfigValue(filename, "singleValue", singleValue);
00050 cout << "singleValue = " << singleValue << endl;
00051
00052 float *manyValues = new float[10];
00053 StGetConfigValue(filename, "manyValues", manyValues, 10);
00054 cout << "manyValues = ";
00055 for (int i=0; i<10; i++) cout << manyValues[i] << ' ';
00056 cout << endl;
00057
00058 #ifdef ST_NO_TEMPLATE_DEF_ARGS
00059 vector<double, allocator<double> > vec(10,0);
00060 #else
00061 #ifdef GNU_GCC
00062 vector<double> vec(10);
00063 #else
00064 vector<double> vec(10,0);
00065 #endif // GNU_GCC %$#&
00066 #endif
00067 StGetConfigValue(filename, "vec", vec, 5);
00068 cout << "vec = ";
00069 for (int k=0; k<10; k++) cout << vec[k] << ' ';
00070 cout << endl;
00071
00072 StThreeVector<double> vec3;
00073 StGetConfigValue(filename, "vec3", vec3);
00074 cout << "vec3 = " << vec3 << endl;
00075
00076 #if !defined(__SUNPRO_CC)
00077 string anyName("default");
00078 StGetConfigValue(filename, "anyName", anyName);
00079 cout << "anyName = " << anyName.c_str() << endl;
00080 #endif
00081
00082 float xfoo = 3.14;
00083 StGetConfigValue(filename, "xfoo", xfoo);
00084 cout << "xfoo = " << xfoo << endl;
00085
00086 return 0;
00087 }