moved trim() into its own module to be used by Config
git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@51 8131a0b2-b21c-1c47-bd6a-f003126495bd
This commit is contained in:
1 parent
86e9c1adbc
commit
39092d710b
6 files changed
+45
-15
No files matched your search
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "Config.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
@@ -16,4 +17,17 @@ Config::Entry::Entry(const string & name)
|
||||
|
||||
void Config::read(const char * file)
|
||||
{
|
||||
ifstream ifs(file);
|
||||
if (ifs.is_open())
|
||||
{
|
||||
string line;
|
||||
while (!ifs.eof())
|
||||
{
|
||||
getline(ifs, line);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Warning: Could not open '" << file << "'" << endl;
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ class Config
|
||||
protected:
|
||||
};
|
||||
|
||||
void read(const char * file);
|
||||
std::string port;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
protected:
|
||||
std::vector<Entry> m_entries;
|
||||
void read(const char * file);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,7 @@ OBJS += resources.o
|
||||
OBJS += pport.o
|
||||
OBJS += parseCmdLine.o
|
||||
OBJS += Config.o
|
||||
OBJS += trim.o
|
||||
CXXFLAGS := -O2 -Wall
|
||||
LDFLAGS := -mwindows
|
||||
|
||||
|
||||
+1
-12
@@ -1,20 +1,9 @@
|
||||
|
||||
#include "parseCmdLine.h"
|
||||
#include "trim.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
static std::string trim(const std::string & orig)
|
||||
{
|
||||
const char ws[] = " \t\r\n\v\f";
|
||||
size_t first = orig.find_first_not_of(ws);
|
||||
size_t last = orig.find_last_not_of(ws);
|
||||
if (first == string::npos || last == string::npos)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return string(orig, first, last - first + 1);
|
||||
}
|
||||
|
||||
std::vector<std::string> parseCmdLine(char * cmdline)
|
||||
{
|
||||
enum { WSSKIP, GATHERING, SQUOTE, DQUOTE } state = WSSKIP;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
#include "trim.h"
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
string trim(const string & orig)
|
||||
{
|
||||
const char ws[] = " \t\r\n\v\f";
|
||||
size_t first = orig.find_first_not_of(ws);
|
||||
size_t last = orig.find_last_not_of(ws);
|
||||
if (first == string::npos || last == string::npos)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return string(orig, first, last - first + 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user