File indexing completed on 2025-04-19 09:09:52
0001 #ifndef ATOOLS_Org_IO_Handler_H
0002 #define ATOOLS_Org_IO_Handler_H
0003
0004 #include <string>
0005 #include <fstream>
0006 #include <map>
0007 #include <vector>
0008 #include "ATOOLS/Org/My_File.H"
0009
0010 namespace ATOOLS {
0011
0012 typedef std::map<std::string,std::string> Variable_Map;
0013 typedef Variable_Map::iterator Variable_Iterator;
0014
0015
0016 class IO_Handler {
0017 My_Out_File m_outfile;
0018 My_In_File m_infile;
0019 std::string m_outfilename;
0020 std::string m_infilename;
0021
0022 std::string m_buffer;
0023 Variable_Map m_vars;
0024
0025 std::vector<char> m_seps, m_coms;
0026
0027 unsigned long m_nx, m_ny;
0028 public:
0029 IO_Handler();
0030
0031 ~IO_Handler();
0032
0033
0034 int SetFileName(std::string);
0035 int SetFileNameRO(std::string);
0036
0037
0038 void SetSeparator(char);
0039 void AddSeparator(char);
0040 void SetComment(char);
0041 void AddComment(char);
0042
0043 template <class Type>
0044 int ValueInput(std::string name, Type &);
0045
0046
0047 template <class Type>
0048 IO_Handler & operator<<(const Type &);
0049
0050
0051 template <class Type>
0052 IO_Handler & operator>>(Type &);
0053
0054
0055
0056
0057
0058 template <class Type>
0059 void MatrixOutput(const std::string name,Type ** const ,const int nx,const int ny);
0060
0061 template <class Type>
0062 void ArrayOutput(const std::string name,const Type *,const int nx,bool writesize=1);
0063
0064 template <class Type>
0065 void Output(const std::string name,const Type &);
0066
0067
0068
0069
0070
0071 template <class Type>
0072 Type ** MatrixInput(const std::string name=std::string(""), int nx=-1, int ny=-1);
0073
0074 template <class Type>
0075 Type * ArrayInput(const std::string name=std::string(""), int nx=-1);
0076
0077 template <class Type>
0078 Type Input(const std::string name=std::string(""));
0079
0080
0081 std::ifstream & GetIFstream() { return *m_infile; }
0082 std::ofstream & GetOFstream() { return *m_outfile; }
0083
0084 unsigned long Nx() const { return m_nx; }
0085 unsigned long Ny() const { return m_ny; }
0086
0087
0088
0089 void FillIn(const std::string &);
0090 void Shorten(std::string&);
0091 };
0092 }
0093
0094 #endif