Update, latest source code for the 2 c++ utilities

This commit is contained in:
Glen De Cauwsemaecker 2014-03-25 01:07:09 +01:00
parent e16c0dc66a
commit b3c28028c8
2 changed files with 18 additions and 10 deletions
scripts/windows/coco-dev-setup/src

View file

@ -50,6 +50,7 @@ void SetArrayVariable(
void FillArray( void FillArray(
const std::vector<tstring> & info, const std::vector<tstring> & info,
const tstring & name, const tstring & name,
const tstring & id_array_name,
const tstring & file, const tstring & file,
int & id int & id
) )
@ -87,9 +88,13 @@ void FillArray(
{ {
size_t pos = line.find(L'=') + 1; size_t pos = line.find(L'=') + 1;
SetArrayVariable( SetArrayVariable(
name, id++, name, id,
line.substr(pos, line.size() - pos) line.substr(pos, line.size() - pos)
); );
SetArrayVariable(
id_array_name, id++,
line.substr(cpos, pos - 3)
);
++counter; ++counter;
} }
else if(line.find(*it) != tstring::npos) else if(line.find(*it) != tstring::npos)
@ -113,23 +118,26 @@ int _tmain(int argc, _TCHAR* argv[])
if(argc == 1) if(argc == 1)
return ErrorReport(L"Please specify a localisation file."); return ErrorReport(L"Please specify a localisation file.");
else if(argc == 2) else if(argc == 2)
return ErrorReport(L"Please specify the name of the array"); return ErrorReport(L"Please specify the name of the array.");
else if(argc == 3) else if(argc == 3)
return ErrorReport(L"Please specify the counter parameter"); return ErrorReport(L"Please specify the name of the name-array.");
else if(argc == 4) else if(argc == 4)
return ErrorReport(L"Please specify the counter parameter.");
else if(argc == 5)
return ErrorReport(L"Please specify one or more categories you are looking for."); return ErrorReport(L"Please specify one or more categories you are looking for.");
tstring file, name, counter_name; tstring file, name, counter_name, id_array_name;
file = argv[1]; file = argv[1];
name = argv[2]; name = argv[2];
counter_name = argv[3]; id_array_name = argv[3];
counter_name = argv[4];
int id = 1; int id = 1;
for(int i = 4 ; i < argc ; ++i) for(int i = 5 ; i < argc ; ++i)
{ {
std::vector<tstring> information; std::vector<tstring> information;
GetHashInfo(argv[i], information); GetHashInfo(argv[i], information);
FillArray(information, name, file, id); FillArray(information, name, id_array_name, file, id);
} }
tcout << L"set \"" << counter_name << L"=" << (id - 1) << L"\""; tcout << L"set \"" << counter_name << L"=" << (id - 1) << L"\"";

View file

@ -36,7 +36,7 @@ void GetHashInfo(tstring id, std::vector<std::wstring> & info) {
std::wstring GetText(const std::vector<tstring> & info, const tstring & file) std::wstring GetText(const std::vector<tstring> & info, const tstring & file)
{ {
if(info.size() == 0) return DEF_URL; if(info.size() == 0) return L"Info Size is 0.";
auto it = info.begin(); auto it = info.begin();
auto last = info.end() - 1; auto last = info.end() - 1;
@ -51,7 +51,7 @@ std::wstring GetText(const std::vector<tstring> & info, const tstring & file)
tcout << file.c_str() << std::endl; tcout << file.c_str() << std::endl;
tcout << strerror(errno) << std::endl; tcout << strerror(errno) << std::endl;
#endif #endif
return DEF_URL; return L"File couldn't be opened.";
} }
tstring line; tstring line;
@ -79,7 +79,7 @@ std::wstring GetText(const std::vector<tstring> & info, const tstring & file)
} }
infile.close(); infile.close();
return DEF_URL; return L"Var couldn't be found.";
} }
int _tmain(int argc, _TCHAR* argv[]) int _tmain(int argc, _TCHAR* argv[])