ConfigFile class after tests, written Makefiles
parent
e69101fd9f
commit
3aa1273512
|
@ -10,15 +10,15 @@ conf.close();
|
||||||
throw FileException(path, "reading", "Could not open file!");
|
throw FileException(path, "reading", "Could not open file!");
|
||||||
}
|
}
|
||||||
_path = path;
|
_path = path;
|
||||||
string action = "parse";
|
std::string action = "parse";
|
||||||
while(!conf.eof()) {
|
while(!conf.eof()) {
|
||||||
std::string line = "";
|
std::string line = "";
|
||||||
conf >> line;
|
conf >> line;
|
||||||
if(conf) {
|
if(conf) {
|
||||||
if(action == "parse") {
|
if(action == "parse") {
|
||||||
if(line[0] == '[') {
|
if(line[0] == '[') {
|
||||||
int i = 1;
|
unsigned int i = 1;
|
||||||
string sa = "";
|
std::string sa = "";
|
||||||
while(line[i] != ']') {
|
while(line[i] != ']') {
|
||||||
if(i >= line.length()-1 && line[i] != ']') {
|
if(i >= line.length()-1 && line[i] != ']') {
|
||||||
std::string err = "";
|
std::string err = "";
|
||||||
|
|
|
@ -32,3 +32,4 @@ public:
|
||||||
void write(); ///< A function that writes the changes to config file.
|
void write(); ///< A function that writes the changes to config file.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
20
Makefile
20
Makefile
|
@ -1,23 +1,15 @@
|
||||||
all:
|
all:
|
||||||
g++ -o 3m 3m.cpp
|
|
||||||
make -C filetesters
|
make -C filetesters
|
||||||
|
make -C tests
|
||||||
debug:
|
debug:
|
||||||
g++ -o 3m 3m.cpp -g
|
|
||||||
make -C filetesters debug
|
make -C filetesters debug
|
||||||
|
make -C tests debug
|
||||||
clean:
|
clean:
|
||||||
rm 3m
|
|
||||||
make -C filetesters clean
|
make -C filetesters clean
|
||||||
|
make -C tests clean
|
||||||
cleantemp:
|
cleantemp:
|
||||||
rm *~
|
rm *~
|
||||||
make -C filetesters cleantemp
|
make -C filetesters cleantemp
|
||||||
3m:
|
|
||||||
g++ -o 3m 3m.cpp
|
|
||||||
3mdebug:
|
|
||||||
g++ -o 3m 3m.cpp -g
|
|
||||||
3mclean:
|
|
||||||
rm 3m
|
|
||||||
3mcleantemp:
|
|
||||||
rm *~
|
|
||||||
filetesters:
|
filetesters:
|
||||||
make -C filetesters
|
make -C filetesters
|
||||||
ftdebug:
|
ftdebug:
|
||||||
|
@ -26,3 +18,9 @@ ftclean:
|
||||||
make -C filetesters clean
|
make -C filetesters clean
|
||||||
ftcleantemp:
|
ftcleantemp:
|
||||||
make -C filetesters cleantemp
|
make -C filetesters cleantemp
|
||||||
|
tests:
|
||||||
|
make -C tests
|
||||||
|
testsdebug:
|
||||||
|
make -C tests debug
|
||||||
|
testsclean:
|
||||||
|
make -C testsclean
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
#include "../ConfigFile.h"
|
||||||
|
#include "../3mExceptions.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cout << "3m Tests: ConfigFile v. 0.1 (C) 2013 by Phitherek_" << endl;
|
||||||
|
cout << "Give me the settings path: ";
|
||||||
|
string path;
|
||||||
|
cin >> path;
|
||||||
|
try {
|
||||||
|
mmm::ConfigFile conf(path);
|
||||||
|
cout << "Config parsed successfully! Here are the results: " << endl << "localpath: " << conf.getLocalPath() << endl << "modlist: " << conf.getModList() << endl << "repoinfo: " << conf.getRepoInfo() << endl;
|
||||||
|
string localpath, modlist, repoinfo;
|
||||||
|
cout << "Enter new localpath: " << endl;
|
||||||
|
cin >> localpath;
|
||||||
|
cout << "modlist: " << endl;
|
||||||
|
cin >> modlist;
|
||||||
|
cout << "repoinfo: " << endl;
|
||||||
|
cin >> repoinfo;
|
||||||
|
conf.getLocalPath() = localpath;
|
||||||
|
conf.getModList() = modlist;
|
||||||
|
conf.getRepoInfo() = repoinfo;
|
||||||
|
cout << "Generating the config file..." << endl;
|
||||||
|
conf.write();
|
||||||
|
cout << "All OK! Thank you for testing!" << endl;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} catch(mmm::FileException& exc) {
|
||||||
|
cout << "File exception occured: " << exc.what() << endl;
|
||||||
|
return 1;
|
||||||
|
} catch(mmm::ParseException& exc) {
|
||||||
|
cout << "Parse exception occured: " << exc.what() << endl;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
CXXFLAGS=-Wall
|
||||||
|
all:
|
||||||
|
${CXX} ${CXXFLAGS} -o ConfigFileTest ConfigFileTest.cpp ../ConfigFile.cpp ../3mExceptions.cpp
|
||||||
|
debug:
|
||||||
|
${CXX} ${CXXFLAGS} -o ConfigFileTest ConfigFileTest.cpp ../ConfigFile.cpp ../3mExceptions.cpp -g
|
||||||
|
clean:
|
||||||
|
rm -rf ConfigFileTest
|
Loading…
Reference in New Issue