ffead.server.doc
PropFileReader.cpp
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * PropFileReader.cpp
18  *
19  * Created on: Aug 18, 2009
20  * Author: sumeet
21  */
22 
23 #include "PropFileReader.h"
24 
25 PropFileReader::PropFileReader()
26 {
27 
28 }
29 PropFileReader::~PropFileReader() {
30  // TODO Auto-generated destructor stub
31 }
32 
33 propMap PropFileReader::getProperties(string filepath)
34 {
35  propMap all;
36  string line;
37  if (filepath=="")
38  {
39  return all;
40  }
41  ifstream myfile (&filepath[0],ios::in | ios::binary);
42  if (myfile.is_open())
43  {
44  strVec vemp;
45  while(getline(myfile,line,'\n'))
46  {
47  if(line!="")
48  {
49  if(line.find("=")!=string::npos)
50  {
51  StringUtil::trim(line);
52  if(line.find("=")!=line.length()-1)
53  {
54  //cout << line.substr(0, line.find("=")) << " = " << line.substr(line.find("=")+1) << endl;
55  all[line.substr(0, line.find("="))] = line.substr(line.find("=")+1);
56  }
57  }
58  }
59  }
60  myfile.close();
61  }
62  return all;
63 }