ConfigFile class after tests, written Makefiles
This commit is contained in:
parent
e69101fd9f
commit
3aa1273512
@ -10,15 +10,15 @@ conf.close();
|
||||
throw FileException(path, "reading", "Could not open file!");
|
||||
}
|
||||
_path = path;
|
||||
string action = "parse";
|
||||
std::string action = "parse";
|
||||
while(!conf.eof()) {
|
||||
std::string line = "";
|
||||
conf >> line;
|
||||
if(conf) {
|
||||
if(action == "parse") {
|
||||
if(line[0] == '[') {
|
||||
int i = 1;
|
||||
string sa = "";
|
||||
unsigned int i = 1;
|
||||
std::string sa = "";
|
||||
while(line[i] != ']') {
|
||||
if(i >= line.length()-1 && line[i] != ']') {
|
||||
std::string err = "";
|
||||
|
@ -32,3 +32,4 @@ public:
|
||||
void write(); ///< A function that writes the changes to config file.
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
20
Makefile
20
Makefile
@ -1,23 +1,15 @@
|
||||
all:
|
||||
g++ -o 3m 3m.cpp
|
||||
make -C filetesters
|
||||
make -C tests
|
||||
debug:
|
||||
g++ -o 3m 3m.cpp -g
|
||||
make -C filetesters debug
|
||||
make -C tests debug
|
||||
clean:
|
||||
rm 3m
|
||||
make -C filetesters clean
|
||||
make -C tests clean
|
||||
cleantemp:
|
||||
rm *~
|
||||
make -C filetesters cleantemp
|
||||
3m:
|
||||
g++ -o 3m 3m.cpp
|
||||
3mdebug:
|
||||
g++ -o 3m 3m.cpp -g
|
||||
3mclean:
|
||||
rm 3m
|
||||
3mcleantemp:
|
||||
rm *~
|
||||
filetesters:
|
||||
make -C filetesters
|
||||
ftdebug:
|
||||
@ -26,3 +18,9 @@ ftclean:
|
||||
make -C filetesters clean
|
||||
ftcleantemp:
|
||||
make -C filetesters cleantemp
|
||||
tests:
|
||||
make -C tests
|
||||
testsdebug:
|
||||
make -C tests debug
|
||||
testsclean:
|
||||
make -C testsclean
|
||||
|
37
tests/ConfigFileTest.cpp
Normal file
37
tests/ConfigFileTest.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
7
tests/Makefile
Normal file
7
tests/Makefile
Normal file
@ -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…
x
Reference in New Issue
Block a user