00001 //---------------------------------------------------------------------------// 00002 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu// 00003 // // 00004 // MAJORANA Simulation // 00005 // // 00006 // This code implementation is the intellectual property of the // 00007 // MAJORANA Collaboration. It is based on Geant4, an intellectual // 00008 // property of the RD44 GEANT4 collaboration. // 00009 // // 00010 // ********************* // 00011 // // 00012 // Neither the authors of this software system, nor their employing // 00013 // institutes, nor the agencies providing financial support for this // 00014 // work make any representation or warranty, express or implied, // 00015 // regarding this software system or assume any liability for its use. // 00016 // By copying, distributing or modifying the Program (or any work based // 00017 // on on the Program) you indicate your acceptance of this statement, // 00018 // and all its terms. // 00019 // // 00020 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu// 00021 //---------------------------------------------------------------------------// 00022 // 00023 // $Id: MJDatabaseUtil.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 00024 // 00025 // CLASS IMPLEMENTATION: MJDatabaseUtil.cc 00026 // 00027 //---------------------------------------------------------------------------// 00033 // 00034 //---------------------------------------------------------------------------// 00044 //---------------------------------------------------------------------------// 00045 // 00046 00047 00048 //---------------------------------------------------------------------------// 00049 00050 #include "database/MJDatabaseUtil.hh" //Present MJ Class Headers 00051 #include "database/MJDatabaseConnection.hh" 00052 00053 //---------------------------------------------------------------------------// 00054 00055 MJDatabaseUtil::MJDatabaseUtil() 00056 { 00057 string pgver = MJDatabaseConnection::getPGVersion(); 00058 00059 } 00060 MJDatabaseUtil::MJDatabaseUtil(const MJDatabaseUtil & other) 00061 { 00062 00063 } 00064 00065 MJDatabaseUtil::~MJDatabaseUtil() 00066 { 00067 } 00068 void 00069 MJDatabaseUtil::byteswap(unsigned char *b, int n) 00070 { 00071 00072 register int i = 0; 00073 register int j = n-1; 00074 while (i<j) 00075 { 00076 std::swap(b[i], b[j]); 00077 i++, j--; 00078 } 00079 } 00080 00081 void 00082 MJDatabaseUtil::fillArray(char *&ar, char* mem) 00083 { 00084 int nEle = getNoEle(mem); 00085 ar = new char[nEle]; 00086 char* start = getstart(mem); 00087 int elementsize = getElementSize(); 00088 for(int i=0; i<nEle; i++){ 00089 int size = c_Int(start); 00090 ar[i] = *(char*)(start + elementsize); 00091 start += size + elementsize; 00092 } 00093 } 00094 00095 void 00096 MJDatabaseUtil::fillArray(char **&ar, char* mem) 00097 { 00098 int nEle = getNoEle(mem); 00099 ar = new char*[nEle]; 00100 char* start = getstart(mem); 00101 int elementsize = getElementSize(); 00102 for(int i=0; i<nEle; i++){ 00103 int size = c_Int(start); 00104 ar[i] =new char[size]; 00105 strncpy(ar[i], (char*)(start + elementsize), size+1); 00106 start += size + elementsize; 00107 } 00108 } 00109