void 
Application_ClientConfigManager::loadApplicationsList()
{
	wstring line;
	int inserted = 0;
	wchar_t szFullPath[4096];
	GetFullPathName(L"Applications.conf", 4096, szFullPath, NULL);
	wifstream configF (szFullPath);
	if (!configF.is_open())
	{
		printf("Application_ConfigManager: Could not open the application config file: Applications.conf\n");
		supportedApplications = new wchar_t*[1];
		supportedApplications[0] = NULL;
		return;
	}
	while (!configF.eof())
	{
		getline (configF,line);
		if((line.size() > 0) && (line.at(0) != '#'))
		{
			vector<std::wstring> splitLine;			
			for(sf_it it=make_split_iterator(line, token_finder(is_any_of(L"\t")));
				it!=sf_it(); ++it)
			{
				splitLine.push_back(copy_range<std::wstring>(*it));				
			}

			if(splitLine.size() >= 2)
			{
				bool downloadURL = false;
				if(splitLine.size() == 3)
				{
					if(splitLine[2] == L"yes")
						downloadURL = true;
				}
				if(applicationsMap.find(splitLine[0]) == applicationsMap.end())
				{
					APPLICATION* a = new APPLICATION();
					a->name = splitLine[0];
					a->path = splitLine[1];
					a->downloadURL = downloadURL;
					applicationsMap.insert(ApplicationPair(splitLine[0], a));
					inserted++;
				}
			}
		}

	}
	supportedApplications = new wchar_t*[inserted+1];
	int i = 0;
	stdext::hash_map<wstring, PAPPLICATION>::iterator vit;
	for(vit = applicationsMap.begin(); vit != applicationsMap.end(); vit++)
	{
		supportedApplications[i] = new wchar_t[vit->first.length()+1];
		wcscpy_s(supportedApplications[i],vit->first.length()+1, vit->first.c_str());
		i++;
	}
	supportedApplications[i] = NULL;
	configF.close();
}
Exemplo n.º 2
0
    void initialize_date(const std::string &filename)
    {
        std::ifstream file(filename);
        if (!file.is_open())
            throw ai_open_failure(filename);

        file.imbue(std::locale::classic());

        std::string line;
        std::getline(file, line); /* read the header and forget it*/

        uint i = 0;
        while (file) {
            if (!std::getline(file, line))
                break;

            try {
                boost::algorithm::split_iterator <std::string::iterator> i, e;
                i = make_split_iterator(
                    line,
                    token_finder(
                        boost::algorithm::is_any_of(";"),
                        boost::algorithm::token_compress_on));

                std::string name = boost::copy_range <std::string>(*i++);
                std::string sur1 = boost::copy_range <std::string>(*i++);
                std::string sur2 = boost::copy_range <std::string>(*i++);
                std::string dmin = boost::copy_range <std::string>(*i++);
                std::string dmax = boost::copy_range <std::string>(*i++);
                std::string dura = boost::copy_range <std::string>(*i++);

                date.emplace_back(date.size(), name, safihr::stod(sur1),
                                  safihr::stod(sur2), vle::devs::infinity,
                                  ai_convert_date(dmin), ai_convert_date(dmax),
                                  safihr::stod(dura));
            } catch (const std::exception &e) {
                (void)e;
                throw ai_format_failure(i);
            }
            i++;
        }
    }