3 bool checknum(std::string s)
5 std::istringstream iss(s);
6 std::ostringstream oss;
19 std::string StringClear(std::string in, std::vector<std::string> no)
23 for (int i=0; i<no.size(); i++)
25 std::string viejo = no.at(i);
27 while (found!=std::string::npos)
30 int inicio = int(found);
31 in.replace(found,viejo.length(),"");
38 std::string StringReplace(std::string in, std::string viejo, std::string nuevo)
42 // different member versions of find in the same order as above:
44 while (found!=std::string::npos)
47 int inicio = int(found);
48 in.replace(found,viejo.length(),nuevo);
54 std::vector < std::string > StringSplit(std::string str, std::string delim)
56 std::vector<std::string> results;
58 while( (cutAt = (int)str.find_first_of(delim)) != str.npos )
62 results.push_back(str.substr(0,cutAt));
64 str = str.substr(cutAt+1);
68 results.push_back(str);
73 std::string generateFileName(std::string input, int number, std::string prefix)
77 int position = input.find( "\\" ); // find first space
78 while ( position != std::string::npos )
80 input.replace( position, 1, "/" );
81 position = input.find( "\\", position + 1 );
84 bool comienza_con_slash = false;
86 if (input.at(0) == '/')
87 comienza_con_slash = true;
89 std::vector< std::string > partes = StringSplit(input, "/");
91 std::stringstream number_str;
93 std::string number_str_texto = number_str.str();
96 int tamanio = number_str_texto.size();
97 int diferencia = ceros-tamanio;
98 for (int i=0; i<diferencia ; i++)
99 number_str_texto="0"+number_str_texto;
101 std::string rta = partes[0];
103 for (unsigned int i=1; i<partes.size(); i++)
105 if (i==partes.size()-1)
107 std::vector<std::string> partes_punto;
108 partes_punto = StringSplit(partes[i], ".");
110 La extension es: partes_punto[partes_punto.size()-1]
112 std::string oldname = "";
113 for (unsigned int h=0; h<partes_punto.size();h++)
115 oldname += partes_punto.at(h)+"_";
117 if (partes_punto.size() > 1)
118 rta+="/"+prefix+"_"+oldname+"_"+number_str_texto+"."+partes_punto[partes_punto.size()-1];
120 rta+="/"+prefix+"_"+oldname+"_"+number_str_texto;
127 if (comienza_con_slash)
132 bool existFile(std::string myFileName)
135 inp.open(myFileName.c_str(), std::ifstream::in);
145 std::string guessName(std::string nombre)
148 int max_iter = 10000;
150 while(iterador < max_iter)
152 std::string nuevo = generateFileName(nombre, iterador, "Data");
154 if (existFile(nuevo))
160 std::cout << nuevo << std::endl;
164 std::cout << nombre << std::endl;
168 std::string guessExistent(std::string nombre, int* actual, bool* hay)
170 std::string nada = "";
171 if (actual == NULL || hay == NULL)
173 int iterador = *actual;
176 while(iterador < max_iter)
178 std::string nuevo = generateFileName(nombre, iterador, "Data");
180 if (existFile(nuevo))