forked from vintagewang/jwrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove stdafx in windows, and add new files
- Loading branch information
1 parent
8efac09
commit 8ecdcd8
Showing
11 changed files
with
151 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
setx BOOST_HOME D:\opensrc\boost_1_49_0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "JWUtil.h" | ||
#include <Windows.h> | ||
|
||
namespace JWUtil | ||
{ | ||
std::string getCurrentExeFilePath() | ||
{ | ||
std::string result; | ||
#ifdef WIN32 | ||
char bufFileName[512 + 1] = {0}; | ||
GetModuleFileNameA(NULL, bufFileName, sizeof(bufFileName) - 1); | ||
result = bufFileName; | ||
#else | ||
#endif | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef _JW_JWUTIL_H__ | ||
#define _JW_JWUTIL_H__ | ||
#include <string> | ||
|
||
namespace JWUtil | ||
{ | ||
std::string getCurrentExeFilePath(); | ||
}; | ||
|
||
#endif // end of _JW_JWUTIL_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "JavaConfig.h" | ||
#include "JWUtil.h" | ||
#include <string> | ||
#include <stdio.h> | ||
#include <boost/property_tree/ptree.hpp> | ||
#include <boost/property_tree/xml_parser.hpp> | ||
#include <boost/typeof/std/utility.hpp> | ||
|
||
using namespace boost::property_tree; | ||
using std::string; | ||
|
||
JavaConfig::JavaConfig() | ||
{ | ||
} | ||
|
||
JavaConfig::~JavaConfig() | ||
{ | ||
} | ||
|
||
JavaConfig* JavaConfig::getInstance() | ||
{ | ||
static JavaConfig *singleton = new JavaConfig(); | ||
return singleton; | ||
} | ||
|
||
bool JavaConfig::load() | ||
{ | ||
ptree pt; | ||
read_xml("jwrapper.xml", pt); | ||
this->javaHome = pt.get<string>("java.javahome"); | ||
this->mainClass = pt.get<string>("java.mainclass"); | ||
|
||
BOOST_AUTO(child, pt.get_child("java.classpaths")); | ||
for(BOOST_AUTO(pos, child.begin()); | ||
pos != child.end(); | ||
++pos) { | ||
this->classPathList.push_back(pos->second.data()); | ||
} | ||
return true; | ||
} | ||
|
||
void JavaConfig::printAll() | ||
{ | ||
printf("JAVA_HOME = [%s]\n", this->javaHome.c_str()); | ||
printf("MAIN CLASS = [%s]\n", this->mainClass.c_str()); | ||
for(size_t i = 0; i < this->classPathList.size(); i++) { | ||
printf("CLASS PATH %2d = [%s]\n", i, this->classPathList[i].c_str()); | ||
} | ||
} | ||
|
||
std::string JavaConfig::getConfigFile() | ||
{ | ||
return JWUtil::getCurrentExeFilePath() + ".xml"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef _JW_JAVA_CONFIG_H__ | ||
#define _JW_JAVA_CONFIG_H__ | ||
#include <string> | ||
#include <map> | ||
#include <vector> | ||
|
||
typedef std::vector<std::string> ClassPathList; | ||
|
||
class JavaConfig | ||
{ | ||
public: | ||
|
||
JavaConfig(); | ||
~JavaConfig(); | ||
static JavaConfig* getInstance(); | ||
|
||
bool load(); | ||
|
||
void printAll(); | ||
|
||
private: | ||
static std::string getConfigFile(); | ||
|
||
private: | ||
std::string javaHome; | ||
std::string mainClass; | ||
ClassPathList classPathList; | ||
}; | ||
|
||
#endif // end of _JW_JAVA_CONFIG_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
#include "stdafx.h" | ||
#include <iostream> | ||
#include <string> | ||
#include <boost/property_tree/ptree.hpp> | ||
#include <boost/property_tree/xml_parser.hpp> | ||
#include <boost/typeof/std/utility.hpp> | ||
using namespace boost::property_tree; | ||
using std::cout; | ||
using std::endl; | ||
using std::string; | ||
#include "JavaConfig.h" | ||
|
||
void test_ptree() | ||
{ | ||
ptree pt; | ||
read_xml("jwrapper.xml", pt); | ||
cout << pt.get<string>("java.javahome") << endl; | ||
cout << pt.get<string>("java.mainclass") << endl; | ||
|
||
BOOST_AUTO(child, pt.get_child("java.classpaths")); | ||
for (BOOST_AUTO(pos, child.begin()); | ||
pos != child.end(); | ||
++pos) | ||
{ | ||
cout << pos->second.data()<< ","; | ||
} | ||
} | ||
//void test_ptree() | ||
//{ | ||
// ptree pt; | ||
// read_xml("jwrapper.xml", pt); | ||
// cout << pt.get<string>("java.javahome") << endl; | ||
// cout << pt.get<string>("java.mainclass") << endl; | ||
// | ||
// BOOST_AUTO(child, pt.get_child("java.classpaths")); | ||
// for(BOOST_AUTO(pos, child.begin()); | ||
// pos != child.end(); | ||
// ++pos) | ||
// { | ||
// cout << pos->second.data() << ","; | ||
// } | ||
//} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
printf("Hello World.\n"); | ||
test_ptree(); | ||
bool result = JavaConfig::getInstance()->load(); | ||
if(result) { | ||
JavaConfig::getInstance()->printAll(); | ||
} | ||
return 0; | ||
} | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters