void mitk::GIFGreyLevelSizeZone::AddArguments(mitkCommandLineParser &parser) { std::string name = GetOptionPrefix(); parser.addArgument(GetLongName(), name, mitkCommandLineParser::Bool, "Use Grey Level Size Zone", "Calculates the size zone based features.", us::Any()); AddQuantifierArguments(parser); }
std::string GameFile::GetUniqueIdentifier() const { std::vector<std::string> info; if (!GetGameID().empty()) info.push_back(GetGameID()); if (GetRevision() != 0) info.push_back("Revision " + std::to_string(GetRevision())); std::string name = GetLongName(DiscIO::Language::English); if (name.empty()) { // Use the file name as a fallback. Not necessarily consistent, but it's the best we have name = m_file_name; } int disc_number = GetDiscNumber() + 1; std::string lower_name = name; std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); if (disc_number > 1 && lower_name.find(StringFromFormat("disc %i", disc_number)) == std::string::npos && lower_name.find(StringFromFormat("disc%i", disc_number)) == std::string::npos) { std::string disc_text = "Disc "; info.push_back(disc_text + std::to_string(disc_number)); } if (info.empty()) return name; std::ostringstream ss; std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", ")); ss << info.back(); return name + " (" + ss.str() + ")"; }
/////////////////////////////////////////////////////////////////////// // Function: MainArg // // Author: $author$ // Date: 4/4/2009 /////////////////////////////////////////////////////////////////////// virtual int MainArg (int args, int argn, const char *arg, int argc, const char** argv, const char** env) { const char* name; LONG length; int level; if ((arg = MainArgParam(argn, arg, argc, argv))) { if ((0 > (level = atoi(arg))) || ((int)(sizeof(EvDebugLevels)*8) < level)) { SET_EV_DEBUG_LEVELS(DEFAULT_EV_DEBUG_LEVELS); DBE("() invalid debug level %d\n", level); } else SET_EV_DEBUG_LEVELS(level); } else { if ((name = GetLongName(length))) printf("%s: %x\n", name, GET_EV_DEBUG_LEVELS()); } return argn; }
void mitk::GIFFirstOrderStatistics::AddArguments(mitkCommandLineParser &parser) { std::string name = GetOptionPrefix(); parser.addArgument(GetLongName(), name, mitkCommandLineParser::Bool, "Use Volume-Statistic", "calculates volume based features", us::Any()); AddQuantifierArguments(parser); }
std::string GameFile::GetUniqueIdentifier() const { const DiscIO::Language lang = DiscIO::Language::English; std::vector<std::string> info; if (!GetGameID().empty()) info.push_back(GetGameID()); if (GetRevision() != 0) info.push_back("Revision " + std::to_string(GetRevision())); std::string name(GetLongName(lang)); if (name.empty()) name = GetName(); int disc_number = GetDiscNumber() + 1; std::string lower_name = name; std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); if (disc_number > 1 && lower_name.find(StringFromFormat("disc %i", disc_number)) == std::string::npos && lower_name.find(StringFromFormat("disc%i", disc_number)) == std::string::npos) { std::string disc_text = "Disc "; info.push_back(disc_text + std::to_string(disc_number)); } if (info.empty()) return name; std::ostringstream ss; std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", ")); ss << info.back(); return name + " (" + ss.str() + ")"; }
const std::string& GameFile::GetName(bool long_name) const { const std::string& name = long_name ? GetLongName() : GetShortName(); if (!name.empty()) return name; // No usable name, return filename (better than nothing) return m_file_name; }
int ReadConfigValue(int SettingIndex) { char line[100], ValueName[64], *token, *temp; struct TSetting *Setting; FILE *fp; GetLongName(SettingIndex, ValueName, sizeof(ValueName)); Setting = &(Settings[SettingIndex]); if ((fp = fopen(ConfigFilename, "r" ) ) != NULL) { while (fgets(line, sizeof(line), fp) != NULL) { line[strcspn(line, "\r")] = '\0'; // Get rid of CR if there is one token = strtok(line, "=" ); if (strcasecmp(ValueName, token ) == 0) { temp = strtok( NULL, "\n"); switch (Setting->SettingType) { case stString: strncpy(Setting->StringValuePtr, temp, Setting->MaxValueLength-1); break; case stInteger: *(Setting->IntValuePtr) = atoi(temp); break; case stDouble: // So we can handle bandwidths such as "20K8", convert "K" to decimal point if (strchr(temp, 'K') != NULL) { *strchr(temp, 'K') = '.'; } *(Setting->DoubleValuePtr) = atof(temp); break; case stBoolean: *(Setting->IntValuePtr) = (*temp == '1') || (*temp == 'Y') || (*temp == 'y') || (*temp == 't') || (*temp == 'T'); break; case stNone: break; } fclose(fp); return 1; } } fclose(fp); } return 0; }
void mitk::GIFVolumetricStatistics::CalculateFeaturesUsingParameters(const Image::Pointer & feature, const Image::Pointer &mask, const Image::Pointer &, FeatureListType &featureList) { auto parsedArgs = GetParameter(); if (parsedArgs.count(GetLongName())) { MITK_INFO << "Start calculating Volumetric Features::...."; auto localResults = this->CalculateFeatures(feature, mask); featureList.insert(featureList.end(), localResults.begin(), localResults.end()); MITK_INFO << "Finished calculating volumetric features...."; } }
void mitk::GIFFirstOrderStatistics::CalculateFeaturesUsingParameters(const Image::Pointer & feature, const Image::Pointer &, const Image::Pointer &maskNoNAN, FeatureListType &featureList) { auto parsedArgs = GetParameter(); if (parsedArgs.count(GetLongName())) { InitializeQuantifierFromParameters(feature, maskNoNAN); MITK_INFO << "Start calculating first order features ...."; auto localResults = this->CalculateFeatures(feature, maskNoNAN); featureList.insert(featureList.end(), localResults.begin(), localResults.end()); MITK_INFO << "Finished calculating first order features...."; } }
int FindSettingByName(char *ValueNameToFind) { char ValueName[64]; int SettingIndex; for (SettingIndex=0; SettingIndex<SettingsCount; SettingIndex++) { GetLongName(SettingIndex, ValueName, sizeof(ValueName)); if (strcasecmp(ValueNameToFind, ValueName) == 0) { // Found return SettingIndex; } } return -1; }
void mitk::GIFGreyLevelSizeZone::CalculateFeaturesUsingParameters(const Image::Pointer & feature, const Image::Pointer &, const Image::Pointer &maskNoNAN, FeatureListType &featureList) { auto parsedArgs = GetParameter(); std::string name = GetOptionPrefix(); if (parsedArgs.count(GetLongName())) { InitializeQuantifierFromParameters(feature, maskNoNAN); MITK_INFO << "Start calculating Grey leve size zone ..."; auto localResults = this->CalculateFeatures(feature, maskNoNAN); featureList.insert(featureList.end(), localResults.begin(), localResults.end()); MITK_INFO << "Finished calculating Grey level size zone ..."; } }
{ *strchr( temp, 'K' ) = '.'; } *( Setting->DoubleValuePtr ) = atof( temp ); break; case stBoolean: *( Setting->IntValuePtr ) = ( *temp == '1' ) || ( *temp == 'Y' ) || ( *temp == 'y' ) || ( *temp == 't' ) || ( *temp == 'T' ); break; case stNone: break; } fclose( fp ); return 1; } } fclose( fp ); }
DOS_Drive_Cache::CFileInfo* DOS_Drive_Cache::FindDirInfo(const char* path, char* expandedPath) { // statics static char split[2] = { CROSS_FILESPLIT,0 }; char dir [CROSS_LEN]; char work [CROSS_LEN]; const char* start = path; const char* pos; CFileInfo* curDir = dirBase; Bit16u id; if (save_dir && (strcmp(path,save_path)==0)) { strcpy(expandedPath,save_expanded); return save_dir; }; // LOG_DEBUG("DIR: Find %s",path); // Remove base dir path start += strlen(basePath); strcpy(expandedPath,basePath); // hehe, baseDir should be cached in... if (!IsCachedIn(curDir)) { strcpy(work,basePath); if (OpenDir(curDir,work,id)) { char buffer[CROSS_LEN]; char* result = 0; strcpy(buffer,dirPath); ReadDir(id,result); strcpy(dirPath,buffer); if (dirSearch[id]) { dirSearch[id]->id = MAX_OPENDIRS; dirSearch[id] = 0; } }; }; do { // bool errorcheck = false; pos = strchr(start,CROSS_FILESPLIT); if (pos) { safe_strncpy(dir,start,pos-start+1); /*errorcheck = true;*/ } else { strcpy(dir,start); }; // Path found Bits nextDir = GetLongName(curDir,dir); strcat(expandedPath,dir); // Error check /* if ((errorcheck) && (nextDir<0)) { LOG_DEBUG("DIR: Error: %s not found.",expandedPath); }; */ // Follow Directory if ((nextDir>=0) && curDir->fileList[nextDir]->isDir) { curDir = curDir->fileList[nextDir]; strcpy (curDir->orgname,dir); if (!IsCachedIn(curDir)) { if (OpenDir(curDir,expandedPath,id)) { char buffer[CROSS_LEN]; char* result = 0; strcpy(buffer,dirPath); ReadDir(id,result); strcpy(dirPath,buffer); if (dirSearch[id]) { dirSearch[id]->id = MAX_OPENDIRS; dirSearch[id] = 0; } }; } }; if (pos) { strcat(expandedPath,split); start = pos+1; } } while (pos); // Save last result for faster access next time strcpy(save_path,path); strcpy(save_expanded,expandedPath); save_dir = curDir; return curDir; }
void DOS_Drive_Cache::CreateShortName(CFileInfo* curDir, CFileInfo* info) { Bits len = 0; bool createShort = false; char tmpNameBuffer[CROSS_LEN]; char* tmpName = tmpNameBuffer; // Remove Spaces strcpy(tmpName,info->orgname); upcase(tmpName); createShort = RemoveSpaces(tmpName); // Get Length of filename char* pos = strchr(tmpName,'.'); if (pos) { // ignore preceding '.' if extension is longer than "3" if (strlen(pos)>4) { while (*tmpName=='.') tmpName++; createShort = true; } pos = strchr(tmpName,'.'); if (pos) len = (Bits)(pos - tmpName); else len = (Bits)strlen(tmpName); } else { len = (Bits)strlen(tmpName); } // Should shortname version be created ? createShort = createShort || (len>8); if (!createShort) { char buffer[CROSS_LEN]; strcpy(buffer,tmpName); createShort = (GetLongName(curDir,buffer)>=0); } if (createShort) { // Create number char buffer[8]; info->shortNr = CreateShortNameID(curDir,tmpName); sprintf(buffer,"%d",info->shortNr); // Copy first letters Bits tocopy = 0; size_t buflen = strlen(buffer); if (len+buflen+1>8) tocopy = (Bits)(8 - buflen - 1); else tocopy = len; safe_strncpy(info->shortname,tmpName,tocopy+1); // Copy number strcat(info->shortname,"~"); strcat(info->shortname,buffer); // Add (and cut) Extension, if available if (pos) { // Step to last extension... pos = strrchr(tmpName, '.'); // add extension strncat(info->shortname,pos,4); info->shortname[DOS_NAMELENGTH] = 0; } // keep list sorted for CreateShortNameID to work correctly if (curDir->longNameList.size()>0) { if (!(strcmp(info->shortname,curDir->longNameList.back()->shortname)<0)) { // append at end of list curDir->longNameList.push_back(info); } else { // look for position where to insert this element bool found=false; std::vector<CFileInfo*>::iterator it; for (it=curDir->longNameList.begin(); it!=curDir->longNameList.end(); ++it) { if (strcmp(info->shortname,(*it)->shortname)<0) { found = true; break; } } // Put it in longname list... if (found) curDir->longNameList.insert(it,info); else curDir->longNameList.push_back(info); } } else { // empty file list, append curDir->longNameList.push_back(info); } } else { strcpy(info->shortname,tmpName); } RemoveTrailingDot(info->shortname); }
char* DOS_Drive_Cache::GetExpandName(const char* path) { static char work [CROSS_LEN] = { 0 }; char dir [CROSS_LEN]; work[0] = 0; strcpy (dir,path); const char* pos = strrchr(path,CROSS_FILESPLIT); if (pos) dir[pos-path+1] = 0; CFileInfo* dirInfo = FindDirInfo(dir, work); if (pos) { // Last Entry = File strcpy(dir,pos+1); GetLongName(dirInfo, dir); strcat(work,dir); } if (*work) { size_t len = strlen(work); #if defined (WIN32) if((work[len-1] == CROSS_FILESPLIT ) && (len >= 2) && (work[len-2] != ':')) { #else if((len > 1) && (work[len-1] == CROSS_FILESPLIT )) { #endif work[len-1] = 0; // Remove trailing slashes except when in root } } return work; } void DOS_Drive_Cache::AddEntry(const char* path, bool checkExists) { // Get Last part... char file [CROSS_LEN]; char expand [CROSS_LEN]; CFileInfo* dir = FindDirInfo(path,expand); const char* pos = strrchr(path,CROSS_FILESPLIT); if (pos) { strcpy(file,pos+1); // Check if file already exists, then don't add new entry... if (checkExists) { if (GetLongName(dir,file)>=0) return; } CreateEntry(dir,file,false); Bits index = GetLongName(dir,file); if (index>=0) { Bit32u i; // Check if there are any open search dir that are affected by this... if (dir) for (i=0; i<MAX_OPENDIRS; i++) { if ((dirSearch[i]==dir) && ((Bit32u)index<=dirSearch[i]->nextEntry)) dirSearch[i]->nextEntry++; } } // LOG_DEBUG("DIR: Added Entry %s",path); } else { // LOG_DEBUG("DIR: Error: Failed to add %s",path); } }