00001 #ifndef MISC_H 00002 #define MISC_H 00003 /* 00004 * ALMA - Atacama Large Millimeter Array 00005 * (c) European Southern Observatory, 2002 00006 * (c) Associated Universities Inc., 2002 00007 * Copyright by ESO (in the framework of the ALMA collaboration), 00008 * Copyright by AUI (in the framework of the ALMA collaboration), 00009 * All rights reserved. 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Lesser General Public 00013 * License as published by the Free software Foundation; either 00014 * version 2.1 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00024 * MA 02111-1307 USA 00025 * 00026 * 00027 * File Misc.h 00028 */ 00029 00030 #include <string> 00031 using namespace std; 00032 00033 namespace asdm { 00048 bool directoryExists(const char* dir); 00049 00058 bool createDirectory(const char* dir); 00059 00067 bool createPath(const char* path); 00068 00069 00073 #define ByteSwap5(x) ByteSwap((unsigned char *) &x,sizeof(x)) 00074 void ByteSwap(unsigned char * b, int n); 00075 00080 class ByteOrder { 00081 public: 00082 static const ByteOrder* Little_Endian; /*< A unique object to represent a little endian byte order. */ 00083 static const ByteOrder* Big_Endian; /*< A unique object to represent a big endian byte order. */ 00084 static const ByteOrder* Machine_Endianity; /*< A unique object storing the endianity of the machine. */ 00085 00094 string toString() const ; 00095 00103 static const ByteOrder* fromString(const string & s); 00104 00105 private: 00106 string name_; 00107 int endianity_; 00108 00109 ByteOrder(const string & name, int endianity); 00110 virtual ~ByteOrder(); 00111 static const ByteOrder* machineEndianity(); 00112 }; 00113 00121 string uniqSlashes(const string& s); 00122 } // end namespace asdm 00123 #endif // MISC_H