24 #if defined(DEVEL_LOTHAR)
26 #endif // DEVEL_LOTHAR
36 aw_message(
"Valid Names container was not removed from database\nProtection level 6 needed");
39 aw_message(
"Valid Names container was removed from database\nThink again before saving");
44 std::cout <<
"DeleteValidNames was selected" << std::endl;
52 typedef vector<string> StrL;
53 typedef vector<Desco> DescList;
64 ifstream namesFile(fileName);
65 if (!namesFile.is_open()) {
66 throw string(
"cannot open file \"") + fileName +
"\" to read";
68 namesFile.unsetf(ios::skipws);
70 istream_iterator<char> inIter(namesFile), theEnd;
72 std::cout <<
"Reading valid names from '" << fileName <<
"'\n";
74 for (; inIter != theEnd; ++inIter) {
75 if (*inIter ==
'\r')
continue;
76 if (*inIter ==
'\n') {
77 if (!tmpString.empty()) {
78 fileContent.push_back(tmpString);
86 if (!tmpString.empty()) fileContent.push_back(tmpString);
90 for (it = fileContent.begin(); it != fileContent.end(); ++it) {
92 string nameStart (
"ABIOTROPHIA");
93 if (it->find(nameStart.c_str(), 0, 11) != string::npos) {
97 std::cout <<
string(
"valid name: ") << myDesc.getFirstName() << std::endl
98 <<
string(
"other name: \t\t") << myDesc.getSecondName() << std::endl;
100 myDescs.push_back(myDesc);
106 std::cout <<
string(
"valid name: ") << myDesc.getFirstName() << std::endl
107 <<
string(
"other name: \t\t") << myDesc.getSecondName() << std::endl;
109 myDescs.push_back(myDesc);
118 error =
"Container for Valid Names already exists\n Please delete old Valid Names first";
124 DescList::iterator di;
125 for (di = myDescs.begin(); di != myDescs.end() && !
error; ++di) {
126 if (di->getType() < 10) {
131 if (!error) error =
GBT_write_string(gb_pair,
"NEWNAME", di->getFirstName().c_str());
133 const char* typeStr =
NULp;
134 switch (di->getType()) {
135 case 0: typeStr =
"VALGEN";
break;
136 case 1: typeStr =
"HETGEN";
break;
137 case 2: typeStr =
"HOMGEN";
break;
138 case 3: typeStr =
"RENGEN";
break;
139 case 4: typeStr =
"CORGEN";
break;
140 case 5: typeStr =
"VALSPEC";
break;
141 case 6: typeStr =
"HETSPEC";
break;
142 case 7: typeStr =
"HOMSPEC";
break;
143 case 8: typeStr =
"RENSPEC";
break;
144 case 9: typeStr =
"CORSPEC";
break;
157 catch (
string& err) {
aw_message(err.c_str()); }
158 catch (...) {
aw_message(
"Unknown exception"); }
168 if (!gb_validNamesCont) err =
"No valid names imported yet";
177 if (!fullName) err =
"Species has no fullname";
181 for (
GBDATA *gb_validNamePair =
GB_entry(gb_validNamesCont,
"pair");
182 gb_validNamePair && !err;
190 nt_assert(strcmp(typeString,
"NOTYPE") != 0);
198 if (!err && ((strcmp(fullName, validName) == 0)||(strcmp(fullName, depName) == 0))) {
GB_ERROR GB_begin_transaction(GBDATA *gbd)
GB_ERROR GB_commit_transaction(GBDATA *gbd)
return string(buffer, length)
GBDATA * GB_nextEntry(GBDATA *entry)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
void NT_importValidNames(AW_window *)
Desco determineType(const string &descriptionString)
GB_ERROR GB_delete(GBDATA *&source)
GB_ERROR GB_await_error()
GBDATA * GB_create_container(GBDATA *father, const char *key)
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
static void error(const char *msg)
GB_CSTR GB_path_in_ARBLIB(const char *relative_path)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
char * GB_read_string(GBDATA *gbd)
void NT_deleteValidNames(AW_window *)
GBDATA * GBT_first_species(GBDATA *gb_main)
GB_ERROR GB_write_security_delete(GBDATA *gbd, unsigned long level)
void aw_message(const char *msg)
GBDATA * GBT_next_species(GBDATA *gb_species)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GBDATA * GB_entry(GBDATA *father, const char *key)
void NT_suggestValidNames(AW_window *)