11#include " Project.h"
22#include < stdio.h>
33using namespace pugi ;
4+ using namespace std ;
45
56//
67// Expose over .dll boundary
@@ -9,6 +10,42 @@ template class __declspec(dllexport) std::allocator<char>;
910template class __declspec (dllexport) std::basic_string<char , std::char_traits<char >, std::allocator<char > >;
1011
1112
13+ template <class T , class I >
14+ bool vectorContains (const vector<T>& v, I& t)
15+ {
16+ bool found = (std::find (v.begin (), v.end (), t) != v.end ());
17+ return found;
18+ }
19+
20+
21+ void Project::AddPlatform (const char * platform)
22+ {
23+ if (!vectorContains (platforms, platform))
24+ platforms.push_back (platform);
25+ }
26+
27+
28+ void Project::AddPlatforms (initializer_list<string> _platforms)
29+ {
30+ platforms.reserve (_platforms.size ());
31+ for (initializer_list<string>::iterator i = _platforms.begin (); i != _platforms.end (); i++)
32+ AddPlatform (i->c_str ());
33+ }
34+
35+ void Project::AddConfiguration (const char * configuration)
36+ {
37+ if (!vectorContains (configurations, configuration))
38+ configurations.push_back (configuration);
39+ }
40+
41+ void Project::AddConfigurations (std::initializer_list<std::string> _configurations)
42+ {
43+ configurations.reserve (_configurations.size ());
44+ for (initializer_list<string>::iterator i = _configurations.begin (); i != _configurations.end (); i++)
45+ AddConfiguration (i->c_str ());
46+ }
47+
48+
1249bool Project::Load (const wchar_t * file)
1350{
1451 xml_parse_result res = load_file (file, parse_default | parse_declaration | parse_ws_pcdata_single);
@@ -20,10 +57,11 @@ bool Project::Load(const wchar_t* file)
2057
2158 for (xml_node conf : node.children ())
2259 {
23- Configuration c;
24- c.ConfigurationName = as_utf8 (conf.child (L" Configuration" ).text ().get ());
25- c.PlatformName = as_utf8 (conf.child (L" Platform" ).text ().get ());
26- Configurations.push_back (c);
60+ const wchar_t * xmltag[] = { L" Configuration" , L" Platform" };
61+ void (Project::*func [])(const char *) = { &Project::AddConfiguration, &Project::AddPlatform };
62+
63+ for ( int i = 0 ; i < _countof (xmltag); i++)
64+ (this ->*func[i])( as_utf8 (conf.child (xmltag[i]).text ().get ()).c_str () );
2765 }
2866
2967 return true ;
0 commit comments