Esempio n. 1
0
void Token::constructTerms() {
	string aux;
	iterador = candidates.begin();
	while (iterador != candidates.end()) {
		aux = trim_copy(*iterador, " \'{}[]-+.,*/%$?<>=^#&!_`");
		aux = replaceMultiByteChars(aux, '_');
		if (!isdigit(aux[0]))
			aux = caseNotDigit(aux);
		else
			if ((isdigit(aux[0])))
				aux = caseDigit(aux);
		aux = trim_copy(aux, " @\'{}[]-+.*/?<>=^$%#&!_");
		if (aux == "") {
			iterador = candidates.erase(iterador);
		} else {
			string_type tipo = whatIsIt(aux);
			if ((tipo == ALPHANUMERIC1)	|| (tipo == TEXT)) {
				stringToLower(aux);
				stemOfPlural(aux);
			}
			*iterador = aux;
			iterador++;
		}
	}
	iterador = candidates.begin();
	_currentPosition = 0;
	_count = candidates.size();
}
Esempio n. 2
0
void StateManager::pushState(const std::string &s)
{
	std::string state = s;
	stringToLower(state);

	if (canChangeState())
	{
		if (states_full())
		{
			debugLog("state stack overflow!!");
			return;
		}
		StateData *s = new StateData;
		s->name = state;
		states[++statesTopIndex] = s;

		applyState(state);

		if (stateObjects[state])
		{
			s->stateObject = stateObjects[state];
			stateObjects[state]->applyState();
		}
		
		stateChangeFlag = true;
	}
}
Esempio n. 3
0
void stringToLowerUserData(std::string &s)
{
	// don't lowercase the userdata path.
	const std::string userdata = core->getUserDataFolder();
	const size_t len = userdata.length();
	const bool match = (s.length() > len) &&
	                   ((s[len] == '/') || (s[len] == '\\')) &&
	                   !strncmp(userdata.c_str(), s.c_str(), len);
	if (!match)
		stringToLower(s);
	else
	{
		s = s.substr(len);
		stringToLower(s);
		s = userdata + s;
	}
}
Esempio n. 4
0
// hackish
// intended to be used only for paths which are known to start with the mod path,
// but can deal with it if this is not the case
std::string localisePathInternalModpath(const std::string &path)
{
	std::string tmp = path;
	stringToLower(tmp);

	if(!strncmp(tmp.c_str(), s_modpath.c_str(), s_modpath.length()))
		return localisePath(path, s_modpath);

	return localisePath(path);
}
Esempio n. 5
0
/// Determine if the parameter is a string parameter
DICE_LIB_DLL_EXPORT
bool is_string_param(const std::string & in){
  // change the string to lower case (string param names are lower)
  std::string lower = in;
  stringToLower(lower);
  for(int_t i=0;i<num_valid_correlation_params;++i){
    if(lower==valid_correlation_params[i].name_ && valid_correlation_params[i].type_==STRING_PARAM)
      return true;
  }
  return false;
}
void loadParticleCallback(const std::string &filename, intptr_t param)
{
	ParticleEffect *e = new ParticleEffect();

	std::string ident;
	int first = filename.find_last_of('/')+1;
	ident = filename.substr(first, filename.find_last_of('.')-first);
	stringToLower(ident);

	e->bankLoad(ident, ParticleManager::particleBankPath);

	particleBank[ident] = e;
}
void ParticleManager::loadParticleEffectFromBank(const std::string &name, ParticleEffect *load)
{
	std::string realName = name;
	stringToLower(realName);
	ParticleEffect *fx = particleBank[realName];

	if (fx)
		fx->transfer(load);
	else
	{
		std::ostringstream os;
		os << "Did not find PE [" << name << "] in particle bank";
		debugLog(os.str());
	}
}
Esempio n. 8
0
bool
CloudEditorWidget::isColored (const std::string &fileName) const
{
  pcl::PCLPointCloud2 cloud2;
  pcl::PCDReader reader;
  reader.readHeader(fileName, cloud2);
  std::vector< pcl::PCLPointField > fs = cloud2.fields;
  for(unsigned int i = 0; i < fs.size(); ++i)
  {
    std::string name(fs[i].name);
    stringToLower(name);
    if ((name.compare("rgb") == 0) || (name.compare("rgba") == 0))
      return true;
  }
  return false;
}
Esempio n. 9
0
tax_id taxonname2taxid(string taxon_string, map<string, tax_id> * NameToNCBI) {

	assert(NameToNCBI);

	map<string, tax_id>::iterator map_it;
	tax_id taxid;

	stringToLower(taxon_string);

	while (taxon_string.length() > 3) {


		map_it = NameToNCBI->find(taxon_string);

		taxid = 0;
		if (map_it != NameToNCBI->end()) {
			taxid = (*map_it).second;
			return taxid;
			//cout << "tax: " <<  taxid << endl;
		} else {

			size_t last_space = taxon_string.find_last_of(' ');
			if (last_space != string::npos) {
				//cout << "taxon_string: (" << taxon_string << ")"<<endl;
				taxon_string = taxon_string.substr(0, last_space);
				//cout << "taxon_string: (" << taxon_string << ")"<<endl;
				//exit(0);
			} else {
				return 0;
			}

			//cout << line<< endl;
			//cout << "(" << taxon_string << ")" << endl;
			//cout << "tax: not found !!!! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << endl;
			//unknown_count++;
			//exit(1);
		}

	}


	return 0;

}
Esempio n. 10
0
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
    SetActiveWindow();      // activate us first !

    UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
    if (nFiles == 1)
    {
        //if only 1 file with .zpk extension, open it as a package
        TCHAR szFileName[_MAX_PATH];
        ::DragQueryFile(hDropInfo, 0, szFileName, _MAX_PATH);
        zp::String filename = szFileName;
        size_t length = filename.length();
        zp::String lowerExt;
        if (length >= 4)
        {
            zp::String temp = filename.substr(length - 4, 4);
            stringToLower(lowerExt, temp);
        }
        if (lowerExt == _T(".zpk"))
        {
            CWinApp* pApp = AfxGetApp();
            pApp->OpenDocumentFile(szFileName);
            return;
        }
    }

    //more than 1 file, try to add to package
    std::vector<zp::String> filenames(nFiles);
    for (UINT i = 0; i < nFiles; i++)
    {
        TCHAR szFileName[_MAX_PATH];
        ::DragQueryFile(hDropInfo, i, szFileName, _MAX_PATH);
        filenames[i] = szFileName;
    }
    CzpEditorDoc* doc = (CzpEditorDoc*)GetActiveDocument();
    if (doc != NULL)
    {
        doc->addFilesToPackage(filenames);
    }
    ::DragFinish(hDropInfo);

    //CFrameWndEx::OnDropFiles(hDropInfo);
}
Esempio n. 11
0
void StateManager::registerStateObject(StateObject *stateObject, const std::string &name)
{
	//const char *c = typeid(*stateObject).name();

	stateObject->name = name;
	stringToLower(stateObject->name);

	//getNameFromDerivedClassTypeName(c);
	if (stateObject->name.empty())
	{
		fatalError("StateManager::registerStateObject - Empty name.");
	}

	if (!stateObjects[stateObject->name])
		stateObjects[stateObject->name] = stateObject;
		/*
	if (c)
		free((void*)c);
		*/
}
Esempio n. 12
0
void doSingleFile(const std::string &path, const std::string &type, std::string filename, void callback(const std::string &filename, int param), int param)
{
	if (filename.size()>4)
	{
		std::string search = filename;
		stringToLower(search);
		std::string filetype = filename.substr(search.size()-4, search.size());
		//stringToUpper(filetype);
		//debugLog("comparing: " + filetype + " and: " + type);
		//if (filetype==type)
		debugLog("checking:" + search + " for type:" + type);
		if (search.find(type)!=std::string::npos)
		{
			debugLog("callback");
			callback(path+filename, param);
		}
		else
		{
			debugLog("not the same");
		}
	}
}
Esempio n. 13
0
void StateManager::pushState(const std::string &s)
{
	std::string state = s;
	stringToLower(state);

	if (canChangeState())
	{
		StateData *s = new StateData;
		s->name = state;
		states.push (s);

		applyState(state);

		if (stateObjects[state])
		{
			s->stateObject = stateObjects[state];
			stateObjects[state]->applyState();
		}
		
		stateChangeFlag = true;
	}
}
Esempio n. 14
0
void setLocalisationModPath(const std::string& s)
{
	s_modpath = s;
	stringToLower(s_modpath);
}
Esempio n. 15
0
void forEachFile(std::string path, std::string type, void callback(const std::string &filename, intptr_t param), intptr_t param)
{
	if (path.empty()) return;


#ifdef BBGE_BUILD_VFS
	ttvfs::VFSDir *vd = vfs.GetDir(path.c_str(), true); // add to tree if it wasn't loaded before
	if(!vd)
	{
		debugLog("Path '" + path + "' does not exist");
		return;
	}
	vd->load(false);
	vfscallback_s dat;
	dat.path = &path;
	dat.ext = type.length() ? type.c_str() : NULL;
	dat.param = param;
	dat.callback = callback;
	vd->forEachFile(forEachFile_vfscallback, &dat, true);

	return;
	// -------------------------------------
#endif

	stringToLower(type);
	path = core->adjustFilenameCase(path);
	debugLog("forEachFile - path: " + path + " type: " + type);

#if defined(BBGE_BUILD_UNIX)
	DIR *dir=0;
	dir = opendir(path.c_str());
	if (dir)
	{
	    dirent *file=0;
		while ( (file=readdir(dir)) != NULL )
		{
		    if (file->d_name && strlen(file->d_name) > 4)
		    {
                debugLog(file->d_name);
                char *extension=strrchr(file->d_name,'.');
                if (extension)
                {
                    debugLog(extension);
                    if (extension!=NULL)
                    {
                        if (strcasecmp(extension,type.c_str())==0)
                        {
                            callback(path + std::string(file->d_name), param);
                        }
                    }
                }
		    }
		}
		closedir(dir);
	}
	else
	{
	    debugLog("FAILED TO OPEN DIR");
	}
#endif

#ifdef BBGE_BUILD_WINDOWS
    BOOL            fFinished;
    HANDLE          hList;
    TCHAR           szDir[MAX_PATH+1];
    WIN32_FIND_DATA FileData;

	int end = path.size()-1;
	if (path[end] != '/')
		path[end] += '/';

    // Get the proper directory path
	// \\ %s\\*



	if (type.find('.')==std::string::npos)
	{
		type = "." + type;
	}


	//std::string add = "%s*" + type;

	//sprintf(szDir, "%s*", path.c_str());
	sprintf(szDir, "%s\\*", path.c_str());

	stringToUpper(type);

    // Get the first file
    hList = FindFirstFile(szDir, &FileData);
    if (hList == INVALID_HANDLE_VALUE)
    {
        //printf("No files found\n\n");
		debugLog("No files of type " + type + " found in path " + path);
    }
    else
    {
        // Traverse through the directory structure
        fFinished = FALSE;
        while (!fFinished)
        {
            // Check the object is a directory or not
            //printf("%*s%s\n", indent, "", FileData.cFileName);
			std::string filename = FileData.cFileName;
			//debugLog("found: " + filename);
			if (filename.size()>4)
			{

				std::string filetype = filename.substr(filename.size()-4, filename.size());
				stringToUpper(filetype);
				//debugLog("comparing: " + filetype + " and: " + type);
				if (filetype==type)
				{
					callback(path+filename, param);
				}
			}


            if (!FindNextFile(hList, &FileData))
            {
				/*
                if (GetLastError() == ERROR_NO_MORE_FILES)
                {
                    fFinished = TRUE;
                }
				*/
				fFinished = TRUE;
            }
        }
    }

    FindClose(hList);
#endif
}
Esempio n. 16
0
map<string, tax_id> * init_NCBI_NAMES(const char * names) {

	map<string, tax_id> * NameToNCBI = new map<string, tax_id>;


	ifstream myfile (names);
	if (myfile.is_open())
	{

		string line;

		while (! myfile.eof() )	{

			std::getline(myfile,line );


			if (line.length() == 0) {
				continue;
			}



			size_t pipe1 = line.find_first_of ( '|', 0);
			if (pipe1==string::npos) {
				cerr << "Error: init_NCBI_NAMES" << endl;
				exit(EXIT_FAILURE);
			}

			size_t pipe2 = line.find_first_of ( '|', pipe1+1);
			if (pipe2==string::npos) {
				cerr << "Error: init_NCBI_NAMES" << endl;
				exit(EXIT_FAILURE);
			}

			size_t pipe3 = line.find_first_of ( '|', pipe2+1);
			if (pipe3==string::npos) {
				cerr << "Error: init_NCBI_NAMES" << endl;
				exit(EXIT_FAILURE);
			}

			size_t pipe4 = line.find_first_of ( '|', pipe3+1);
			if (pipe4==string::npos) {
				cerr << "Error: init_NCBI_NAMES" << endl;
				exit(EXIT_FAILURE);
			}


			//if ((pipe4-pipe3) >= 17 && line.substr(pipe3, 17).compare("|\tscientific name")==0 ){

				//cout << line << endl;
				tax_id tax_id = str2int(line);
				//cout << tax_id << endl;

				int name_start = pipe1+2;
				int name_end = pipe2-1;

				string name = line.substr(name_start, name_end-name_start);
				stringToLower(name);
				(*NameToNCBI)[name]=tax_id;
				//cout << "-" << name << "-"<<endl;
			//}

			//string tax_id = line.substr(0, l_start);



		}

		myfile.close();
	}

	else {
		cerr << "Error: Unable to open file " << names << endl;
		exit(1);
	}

	return NameToNCBI;
}