/[H8]/trunk/h8server/ConfigFile.cpp
ViewVC logotype

Annotation of /trunk/h8server/ConfigFile.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103 - (hide annotations) (download)
Sun May 27 13:32:36 2007 UTC (17 years ago) by kevin
File size: 903 byte(s)
case 0 problem
1 kevin 87 #include "StdAfx.h"
2     #include ".\configfile.h"
3    
4     #include <iostream>
5     #include <fstream>
6    
7     using namespace std;
8    
9     ConfigFile::ConfigFile(void)
10     {
11     }
12    
13     ConfigFile::~ConfigFile(void)
14     {
15     }
16    
17     void ConfigFile::Read()
18     {
19 kevin 103 ifstream file("Config-torben.ini");
20 kevin 87 if (!file.is_open())
21     throw("Could not open file");
22    
23     char buf[200];
24     while (!file.eof() ) {
25     file.getline(buf,200);
26     CString tmp(buf);
27    
28     if (tmp.GetAt(0) == '#')
29     continue;
30    
31     int pos = tmp.Find('=');
32     if (pos>0) {
33     CString key = tmp.Left(pos).Trim().MakeLower();;
34     CString value = tmp.Right(tmp.GetLength()-pos-1).Trim();
35    
36     if (key == "driver")
37     driver = value;
38     else if (key == "host")
39     host = value;
40     else if (key == "username")
41     username = value;
42     else if (key == "password")
43     password = value;
44     else if (key == "database")
45     database = value;
46     }
47    
48     }
49    
50     file.close();
51     }

  ViewVC Help
Powered by ViewVC 1.1.20