/[H6]/ConfigFile.cpp
ViewVC logotype

Annotation of /ConfigFile.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (hide annotations) (download)
Wed Sep 6 20:27:24 2006 UTC (17 years, 10 months ago) by torben
File size: 896 byte(s)
Added support for config file
1 torben 47 #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     ifstream file("Udlaan.ini");
20     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