fixed little logical bug
[qbat.git] / common.cpp
blob32434c4cc1b3ed08fba368b7b5952014d96f71d2
1 //
2 // C++ Implementation: common
3 //
4 // Author: Oliver Groß <z.o.gross@gmx.de>, (C) 2008
5 //
6 // Copyright: See COPYING file that comes with this distribution
7 //
8 #include <fstream>
9 #include "common.h"
11 namespace qbat {
12 using namespace std;
14 string readStringSysFile(const char * fileName) {
15 ifstream inFile;
16 string buffer;
18 inFile.open(fileName);
19 inFile >> buffer;
20 inFile.close();
22 return buffer;
25 int readIntSysFile(const char * fileName) {
26 ifstream inFile;
27 int buffer;
29 inFile.open(fileName);
30 inFile >> buffer;
31 inFile.close();
33 return buffer;
36 int toStatusInt(std::string status) {
37 if (status == "Discharging")
38 return UI_BATTERY_DISCHARGING;
39 else if (status == "Charging")
40 return UI_BATTERY_CHARGING;
41 else if (status == "Full")
42 return UI_BATTERY_FULL;
43 else
44 return 0;