void Options::parsePluginStringData(const std::string &str, char separator1, char separator2) { StringList valueList; split(str, valueList, separator1); if (valueList.size() > 0) { StringList keyAndValue; for (StringList::iterator itr = valueList.begin(); itr != valueList.end(); ++itr) { split(*itr, keyAndValue, separator2); if (keyAndValue.size() > 1) { setPluginStringData(keyAndValue.front(), keyAndValue.back()); } else if (keyAndValue.size() > 0) { setPluginStringData(keyAndValue.front(), "true"); } keyAndValue.clear(); } } }
void LabelStatement::compile(const StringList& code_line_parts) { if (code_line_parts.size() != NUMBER_OF_CODE_LINE_PARTS) { throw InvalidNumberOfCodeLineParts(); } std::string label = code_line_parts.front(); if (!ExpressionCompiler::isIdentifier(label)) { throw InvalidIdentifierFormat(label); } getCompiler()->getAssemblerModule()->createLabel(label); }
SS DFStatement::buildSS( const StringList &inVarNameList, const DoubleList &inCoefList, const StringList &outVarNameList, const DoubleList &outCoefList ) { // // FIRST, BUILD THE FILTER EQUATION // StringList::const_iterator inVarNameItr = inVarNameList.begin(); DoubleList::const_iterator inCoefItr = inCoefList.begin(); StringList::const_iterator outVarNameItr = outVarNameList.begin(); DoubleList::const_iterator outCoefItr = outCoefList.begin(); BE be( 0, "+", BE( *inCoefItr, "*", *inVarNameItr ) ); while( ++inVarNameItr != inVarNameList.end() ) { (void)++inCoefItr; be = BE( be, "+", BE( *inCoefItr, "*", *inVarNameItr ) ); } while( ++outVarNameItr != outVarNameList.end() ) { (void)++outCoefItr; be = BE( be, "-", BE( *outCoefItr, "*", *outVarNameItr ) ); } be = BE( be, "/", outCoefList.front() ); be = BE( outVarNameList.front(), "=", be ); // // SHIFT THE VARIABLES // SS ss( IE( 1 ), be ); (void)--inVarNameItr; while( inVarNameItr != inVarNameList.begin() ) { StringList::const_iterator nxtInVarNameItr = inVarNameItr; (void)--nxtInVarNameItr; ss = SS( ss, BE( *inVarNameItr, "=", *nxtInVarNameItr ) ); inVarNameItr = nxtInVarNameItr; } (void)--outVarNameItr; while( outVarNameItr != outVarNameList.begin() ) { StringList::const_iterator nxtOutVarNameItr = outVarNameItr; (void)--nxtOutVarNameItr; ss = SS( ss, BE( *outVarNameItr, "=", *nxtOutVarNameItr ) ); outVarNameItr = nxtOutVarNameItr; } return ss; }
/** * Note: intended to be used with fsck only */ bool StorageTkEx::getNextContDirID(unsigned hashDirNum, int64_t lastOffset, std::string* outID, int64_t* outNewOffset) { *outID = ""; StringList outIDs; FhgfsOpsErr retVal = getContDirIDsIncremental(hashDirNum, lastOffset, 1, &outIDs, outNewOffset); if ( ( outIDs.empty() ) || ( retVal != FhgfsOpsErr_SUCCESS ) ) return false; else { *outID = outIDs.front(); return true; } }
void QuantitativeExperimentalDesign::applyDesign2Quantifier(PeptideAndProteinQuant & quantifier, TextFile & file, StringList & file_paths) { // vector< pair<PeptideAndProteinQuant::PeptideData,PeptideAndProteinQuant::ProteinQuant> >& result) //create mapping from experimental setting to all respective file names map<String, StringList> design2FileBaseName; mapFiles2Design_(design2FileBaseName, file); //filter out all non-existing files map<String, StringList> design2FilePath; findRelevantFilePaths_(design2FileBaseName, design2FilePath, file_paths); //determine wether we deal with idXML or featureXML FileTypes::Type in_type = FileHandler::getType(file_paths.front()); if (in_type == FileTypes::FEATUREXML) { FeatureMap<> features; for (map<String, StringList>::iterator iter = design2FilePath.begin(); iter != design2FilePath.end(); ++iter) { mergeFeatureMaps_(features, iter->first, iter->second); } LOG_INFO << "Number of proteinIdentifications: " << features.getProteinIdentifications().size() << endl; ProteinIdentification & proteins = features.getProteinIdentifications()[0]; quantifier.quantifyPeptides(features); quantifier.quantifyProteins(proteins); } else { ConsensusMap consensus; for (map<String, StringList>::iterator iter = design2FilePath.begin(); iter != design2FilePath.end(); ++iter) { mergeConsensusMaps_(consensus, iter->first, iter->second); } LOG_INFO << "Number of proteinIdentifications: " << consensus.getProteinIdentifications().size() << endl; ProteinIdentification & proteins = consensus.getProteinIdentifications()[0]; quantifier.quantifyPeptides(consensus); quantifier.quantifyProteins(proteins); } }
void QuantitativeExperimentalDesign::applyDesign2Resolver(ProteinResolver & resolver, TextFile & file, StringList & file_paths) { //create mapping from experimental setting to all respective file names map<String, StringList> design2FileBaseName; mapFiles2Design_(design2FileBaseName, file); //filter out all non-existing files map<String, StringList> design2FilePath; findRelevantFilePaths_(design2FileBaseName, design2FilePath, file_paths); //determine wether we deal with idXML or featureXML FileTypes::Type in_type = FileHandler::getType(file_paths.front()); if (in_type == FileTypes::IDXML) { vector<ProteinIdentification> proteins; vector<PeptideIdentification> peptides; for (map<String, StringList>::iterator iter = design2FilePath.begin(); iter != design2FilePath.end(); ++iter) { // merge the respective files mergeIDFiles_(proteins, peptides, iter->first, iter->second); } resolver.resolveID(peptides); } else { ConsensusMap consensus; for (map<String, StringList>::iterator iter = design2FilePath.begin(); iter != design2FilePath.end(); ++iter) { mergeConsensusMaps_(consensus, iter->first, iter->second); } resolver.resolveConsensus(consensus); } }
bool CTagLoaderTagLib::ParseTag(ID3v2::Tag *id3v2, MUSIC_INFO::EmbeddedArt *art, MUSIC_INFO::CMusicInfoTag& tag) { if (!id3v2) return false; ReplayGain replayGainInfo; ID3v2::AttachedPictureFrame *pictures[3] = {}; const ID3v2::FrameListMap& frameListMap = id3v2->frameListMap(); for (ID3v2::FrameListMap::ConstIterator it = frameListMap.begin(); it != frameListMap.end(); ++it) { // It is possible that the taglist is empty. In that case no useable values can be extracted. // and we should skip the tag. if (it->second.isEmpty()) continue; if (it->first == "TPE1") SetArtist(tag, GetID3v2StringList(it->second)); else if (it->first == "TALB") tag.SetAlbum(it->second.front()->toString().to8Bit(true)); else if (it->first == "TPE2") SetAlbumArtist(tag, GetID3v2StringList(it->second)); else if (it->first == "TIT2") tag.SetTitle(it->second.front()->toString().to8Bit(true)); else if (it->first == "TCON") SetGenre(tag, GetID3v2StringList(it->second)); else if (it->first == "TRCK") tag.SetTrackNumber(strtol(it->second.front()->toString().toCString(true), NULL, 10)); else if (it->first == "TPOS") tag.SetDiscNumber(strtol(it->second.front()->toString().toCString(true), NULL, 10)); else if (it->first == "TYER") tag.SetYear(strtol(it->second.front()->toString().toCString(true), NULL, 10)); else if (it->first == "TCMP") tag.SetCompilation((strtol(it->second.front()->toString().toCString(true), NULL, 10) == 0) ? false : true); else if (it->first == "TENC") {} // EncodedBy else if (it->first == "TCOP") {} // Copyright message else if (it->first == "TDRC") tag.SetYear(strtol(it->second.front()->toString().toCString(true), NULL, 10)); else if (it->first == "TDRL") tag.SetYear(strtol(it->second.front()->toString().toCString(true), NULL, 10)); else if (it->first == "TDTG") {} // Tagging time else if (it->first == "TLAN") {} // Languages else if (it->first == "TMOO") tag.SetMood(it->second.front()->toString().to8Bit(true)); else if (it->first == "USLT") // Loop through any lyrics frames. Could there be multiple frames, how to choose? for (ID3v2::FrameList::ConstIterator lt = it->second.begin(); lt != it->second.end(); ++lt) { ID3v2::UnsynchronizedLyricsFrame *lyricsFrame = dynamic_cast<ID3v2::UnsynchronizedLyricsFrame *> (*lt); if (lyricsFrame) tag.SetLyrics(lyricsFrame->text().to8Bit(true)); } else if (it->first == "COMM") // Loop through and look for the main (no description) comment for (ID3v2::FrameList::ConstIterator ct = it->second.begin(); ct != it->second.end(); ++ct) { ID3v2::CommentsFrame *commentsFrame = dynamic_cast<ID3v2::CommentsFrame *> (*ct); if (commentsFrame && commentsFrame->description().isEmpty()) tag.SetComment(commentsFrame->text().to8Bit(true)); } else if (it->first == "TXXX") // Loop through and process the UserTextIdentificationFrames for (ID3v2::FrameList::ConstIterator ut = it->second.begin(); ut != it->second.end(); ++ut) { ID3v2::UserTextIdentificationFrame *frame = dynamic_cast<ID3v2::UserTextIdentificationFrame *> (*ut); if (!frame) continue; // First field is the same as the description StringList stringList = frame->fieldList(); if (stringList.size() == 1) continue; stringList.erase(stringList.begin()); String desc = frame->description().upper(); if (desc == "MUSICBRAINZ ARTIST ID") tag.SetMusicBrainzArtistID(SplitMBID(StringListToVectorString(stringList))); else if (desc == "MUSICBRAINZ ALBUM ID") tag.SetMusicBrainzAlbumID(stringList.front().to8Bit(true)); else if (desc == "MUSICBRAINZ ALBUM ARTIST ID") tag.SetMusicBrainzAlbumArtistID(SplitMBID(StringListToVectorString(stringList))); else if (desc == "MUSICBRAINZ ALBUM ARTIST") SetAlbumArtist(tag, StringListToVectorString(stringList)); else if (desc == "REPLAYGAIN_TRACK_GAIN") replayGainInfo.ParseGain(ReplayGain::TRACK, stringList.front().toCString(true)); else if (desc == "REPLAYGAIN_ALBUM_GAIN") replayGainInfo.ParseGain(ReplayGain::ALBUM, stringList.front().toCString(true)); else if (desc == "REPLAYGAIN_TRACK_PEAK") replayGainInfo.ParsePeak(ReplayGain::TRACK, stringList.front().toCString(true)); else if (desc == "REPLAYGAIN_ALBUM_PEAK") replayGainInfo.ParsePeak(ReplayGain::ALBUM, stringList.front().toCString(true)); else if (desc == "ALBUMARTIST" || desc == "ALBUM ARTIST") SetAlbumArtist(tag, StringListToVectorString(stringList)); else if (desc == "ARTISTS") { if (id3v2->header()->majorVersion() < 4) tag.SetMusicBrainzArtistHints(StringListToVectorString(TagLib::StringList::split(stringList.front(), TagLib::String("/")))); else tag.SetMusicBrainzArtistHints(StringListToVectorString(stringList)); } else if (desc == "ALBUMARTISTS" || desc == "ALBUM ARTISTS") { if (id3v2->header()->majorVersion() < 4) tag.SetMusicBrainzAlbumArtistHints(StringListToVectorString(TagLib::StringList::split(stringList.front(), TagLib::String("/")))); else tag.SetMusicBrainzAlbumArtistHints(StringListToVectorString(stringList)); } else if (desc == "MOOD") tag.SetMood(stringList.front().to8Bit(true)); else if (g_advancedSettings.m_logLevel == LOG_LEVEL_MAX) CLog::Log(LOGDEBUG, "unrecognized user text tag detected: TXXX:%s", frame->description().toCString(true)); } else if (it->first == "UFID") // Loop through any UFID frames and set them for (ID3v2::FrameList::ConstIterator ut = it->second.begin(); ut != it->second.end(); ++ut) { ID3v2::UniqueFileIdentifierFrame *ufid = reinterpret_cast<ID3v2::UniqueFileIdentifierFrame*> (*ut); if (ufid->owner() == "http://musicbrainz.org") { // MusicBrainz pads with a \0, but the spec requires binary, be cautious char cUfid[64]; int max_size = std::min((int)ufid->identifier().size(), 63); strncpy(cUfid, ufid->identifier().data(), max_size); cUfid[max_size] = '\0'; tag.SetMusicBrainzTrackID(cUfid); } } else if (it->first == "APIC") // Loop through all pictures and store the frame pointers for the picture types we want for (ID3v2::FrameList::ConstIterator pi = it->second.begin(); pi != it->second.end(); ++pi) { ID3v2::AttachedPictureFrame *pictureFrame = dynamic_cast<ID3v2::AttachedPictureFrame *> (*pi); if (!pictureFrame) continue; if (pictureFrame->type() == ID3v2::AttachedPictureFrame::FrontCover) pictures[0] = pictureFrame; else if (pictureFrame->type() == ID3v2::AttachedPictureFrame::Other) pictures[1] = pictureFrame; else if (pi == it->second.begin()) pictures[2] = pictureFrame; } else if (it->first == "POPM") // Loop through and process ratings for (ID3v2::FrameList::ConstIterator ct = it->second.begin(); ct != it->second.end(); ++ct) { ID3v2::PopularimeterFrame *popFrame = dynamic_cast<ID3v2::PopularimeterFrame *> (*ct); if (!popFrame) continue; // @xbmc.org ratings trump others (of course) if (popFrame->email() == "*****@*****.**") tag.SetUserrating(popFrame->rating() / 51 + '0'); else if (tag.GetUserrating() == '0') { if (popFrame->email() != "Windows Media Player 9 Series" && popFrame->email() != "Banshee" && popFrame->email() != "no@email" && popFrame->email() != "*****@*****.**" && popFrame->email() != "*****@*****.**") CLog::Log(LOGDEBUG, "unrecognized ratings schema detected: %s", popFrame->email().toCString(true)); tag.SetUserrating(POPMtoXBMC(popFrame->rating())); } } else if (g_advancedSettings.m_logLevel == LOG_LEVEL_MAX) CLog::Log(LOGDEBUG, "unrecognized ID3 frame detected: %c%c%c%c", it->first[0], it->first[1], it->first[2], it->first[3]); } // for // Process the extracted picture frames; 0 = CoverArt, 1 = Other, 2 = First Found picture for (int i = 0; i < 3; ++i) if (pictures[i]) { std::string mime = pictures[i]->mimeType().to8Bit(true); TagLib::uint size = pictures[i]->picture().size(); tag.SetCoverArtInfo(size, mime); if (art) art->set((const uint8_t*)pictures[i]->picture().data(), size, mime); // Stop after we find the first picture for now. break; } tag.SetReplayGain(replayGainInfo); return true; }
int main(int argc, char* argv[]) { StringSet targets, configurations, schemes; String sdkRoot, projectPath, xcconfigPath, workspacePath; String logVerbosity("warning"); int projectSet = 0; int workspaceSet = 0; int interactiveFlag = 0; int relativeSdkFlag = 0; int genProjectionsFlag = 0; int allTargets = 0; int allSchemes = 0; int mode = GenerateMode; static struct option long_options[] = { {"version", no_argument, 0, 0}, {"usage", no_argument, 0, 0}, {"help", no_argument, 0, 0}, {"interactive", no_argument, &interactiveFlag, 1}, {"loglevel", required_argument, 0, 0}, {"sdk", required_argument, 0, 0}, {"list", no_argument, &mode, ListMode}, {"project", required_argument, &projectSet, 1}, {"target", required_argument, 0, 0}, {"alltargets", no_argument, &allTargets, 1}, {"configuration", required_argument, 0, 0}, {"xcconfig", required_argument, 0, 0}, {"workspace", required_argument, &workspaceSet, 1}, {"scheme", required_argument, 0, 0}, {"allschemes", required_argument, &allSchemes, 1}, {"relativepath", no_argument, &relativeSdkFlag, 1}, { "genprojections", no_argument, &genProjectionsFlag, 1 }, {0, 0, 0, 0} }; int numOptions = sizeof(long_options) / sizeof(struct option) - 1; while (1) { int option_index = 0; int c = getopt_long_only(argc, argv, "", long_options, &option_index); if (c == -1) { break; } else if (c || option_index < 0 || option_index >= numOptions) { printUsage(argv[0], false); exit(EXIT_FAILURE); } // Process options switch (option_index) { case 0: printVersion(argv[0]); exit(EXIT_SUCCESS); break; case 1: printUsage(argv[0], false); exit(EXIT_SUCCESS); break; case 2: printUsage(argv[0], true); exit(EXIT_SUCCESS); break; case 4: logVerbosity = strToLower(optarg); break; case 5: sdkRoot = optarg; break; case 7: projectPath = optarg; break; case 8: targets.insert(optarg); break; case 10: configurations.insert(optarg); break; case 11: xcconfigPath = optarg; break; case 12: workspacePath = optarg; break; case 13: schemes.insert(optarg); break; default: // Do nothing break; } } // Set AI Telemetry_Init TELEMETRY_INIT(L"AIF-23c336e0-1e7e-43ba-a5ce-eb9dc8a06d34"); if (checkTelemetryOptIn()) { TELEMETRY_ENABLE(); } else { TELEMETRY_DISABLE(); } TELEMETRY_SET_INTERNAL(isMSFTInternalMachine()); String machineID = getMachineID(); if (!machineID.empty()) { TELEMETRY_SET_MACHINEID(machineID.c_str()); } TELEMETRY_EVENT_DATA(L"VSImporterStart", getProductVersion().c_str()); // Process non-option ARGV-elements VariableCollectionManager& settingsManager = VariableCollectionManager::get(); while (optind < argc) { String arg = argv[optind]; if (arg == "/?") { // Due to issue 6715724, flush before exiting TELEMETRY_EVENT_DATA(L"VSImporterIncomplete", "printUsage"); TELEMETRY_FLUSH(); printUsage(argv[0], true); exit(EXIT_SUCCESS); } else if (arg.find_first_of('=') != String::npos) { settingsManager.processGlobalAssignment(arg); } else { sbValidateWithTelemetry(0, "Unsupported argument: " + arg); } optind++; } // Set output format settingsManager.setGlobalVar("VSIMPORTER_OUTPUT_FORMAT", "WinStore10"); // Set logging level SBLogLevel logLevel; if (logVerbosity == "debug") logLevel = SB_DEBUG; else if (logVerbosity == "info") logLevel = SB_INFO; else if (logVerbosity == "warning") logLevel = SB_WARN; else if (logVerbosity == "error") logLevel = SB_ERROR; else if (!logVerbosity.empty()) { sbValidateWithTelemetry(0, "Unrecognized logging verbosity: " + logVerbosity); } SBLog::setVerbosity(logLevel); // Look for a project file in current directory, if one hasn't been explicitly specified if (!projectSet && !workspaceSet) { StringList projects; findFiles(".", "*.xcodeproj", DT_DIR, false, projects); StringList workspaces; findFiles(".", "*.xcworkspace", DT_DIR, false, workspaces); if (!workspaces.empty()) { sbValidateWithTelemetry(workspaces.size() == 1, "Multiple workspaces found. Select the workspace to use with the -workspace option."); workspacePath = workspaces.front(); workspaceSet = 1; } else if (!projects.empty()) { sbValidateWithTelemetry(projects.size() == 1, "Multiple projects found. Select the project to use with the -project option."); projectPath = projects.front(); projectSet = 1; } else { sbValidateWithTelemetry(0, "The current directory does not contain a project or workspace."); } } // Set the architecture String arch = "msvc"; settingsManager.setGlobalVar("ARCHS", arch); settingsManager.setGlobalVar("CURRENT_ARCH", arch); // Make sure workspace arguments are valid if (workspaceSet) { sbValidateWithTelemetry(!projectSet, "Cannot specify both a project and a workspace."); } // Disallow specifying schemes and targets together sbValidateWithTelemetry((schemes.empty() && !allSchemes) || (targets.empty() && !allTargets), "Cannot specify schemes and targets together."); // Process allTargets and allSchemes flags if (allSchemes) schemes.clear(); if (allTargets) targets.clear(); // Initialize global settings String binaryDir = sb_dirname(getBinaryLocation()); sbValidateWithTelemetry(!binaryDir.empty(), "Failed to resolve binary directory."); settingsManager.setGlobalVar("VSIMPORTER_BINARY_DIR", binaryDir); settingsManager.setGlobalVar("VSIMPORTER_INTERACTIVE", interactiveFlag ? "YES" : "NO"); settingsManager.setGlobalVar("VSIMPORTER_RELATIVE_SDK_PATH", relativeSdkFlag ? "YES" : "NO"); if (!sdkRoot.empty()) { sdkRoot = joinPaths(getcwd(), sdkRoot); } else { sdkRoot = joinPaths(binaryDir, ".."); } settingsManager.setGlobalVar("WINOBJC_SDK_ROOT", sdkRoot); // Add useful environment variables to global settings String username; sbValidateWithTelemetry(sb_getenv("USERNAME", username), "Failed to get current username."); settingsManager.setGlobalVar("USER", username); // Read xcconfig file specified from the command line if (!xcconfigPath.empty()) settingsManager.processGlobalConfigFile(xcconfigPath); // Read xcconfig file specified by the XCODE_XCCONFIG_FILE environment variable String xcconfigFile; if (sb_getenv("XCODE_XCCONFIG_FILE", xcconfigFile)) settingsManager.processGlobalConfigFile(xcconfigFile); // Validate WinObjC SDK directory checkWinObjCSDK(); // Create a workspace SBWorkspace *mainWorkspace; if (workspaceSet) { mainWorkspace = SBWorkspace::createFromWorkspace(workspacePath); } else if (projectSet) { mainWorkspace = SBWorkspace::createFromProject(projectPath); } else { sbAssertWithTelemetry(0); // non-reachable } if (mode == ListMode) { mainWorkspace->printSummary(); } else if (mode == GenerateMode) { if (!schemes.empty() || allSchemes) { mainWorkspace->queueSchemes(schemes, configurations); } else { mainWorkspace->queueTargets(targets, configurations); } mainWorkspace->generateFiles(genProjectionsFlag); } else { sbAssertWithTelemetry(0); // non-reachable } TELEMETRY_EVENT_DATA(L"VSImporterComplete", getProductVersion().c_str()); TELEMETRY_FLUSH(); return EXIT_SUCCESS; }
/** Function to parse the command line options. Responsible to 1. Parse the input values. 2. Print the usage note. 3. Identify the valdations to be carried out. 4. Type of report needs to be generated. @internalComponent @released @param aArgc - argument count @param aArgv[] - argument values */ ReturnType CmdLineHandler::ProcessCommandLine(unsigned int aArgc, char* aArgv[]) { if(aArgc < 2) { std::cout << PrintVersion().c_str() << std::endl; std::cout << PrintUsage().c_str() << std::endl; return EQuit; } ArgumentList argumentList(&aArgv[0], aArgv + aArgc); int argCount = argumentList.size(); iInputCommand = KToolName; for( int i = 1; i < argCount; i++ ) //Skip tool name { String name = argumentList.at(i); iInputCommand += " "; iInputCommand += name; int longOptionFlag = 0; if(IsOption(name, longOptionFlag)) { String optionName; bool optionValue = false; StringList optionValueList; ParseOption(name, optionName, optionValueList, optionValue); char shortOption = KNull; if(Validate(ReaderUtil::ToLower(optionName), optionValue, optionValueList.size())) { if(longOptionFlag) { shortOption = optionName.at(2); } else { shortOption = optionName.at(1); } } switch(shortOption) { case 'q': iCommmandFlag |= QuietMode; break; case 'a': iCommmandFlag |= KAll; break; case 'x': iCommmandFlag |= KXmlReport; break; case 'o': iXmlFileName.assign(optionValueList.front()); NormaliseName(); break; case 's': if((optionName == KShortSuppressOption) || (optionName == KLongSuppressOption)) { String value; while(optionValueList.size() > 0) { value = optionValueList.front(); if(iSuppressVal[value]) { if(iValidations > 0) //Is any check enabled? { if(iValidations & iSuppressVal[value]) { iValidations ^= iSuppressVal[value]; //Consider only 3 LSB's } } else //Is this valid value? { iSuppressions |= iSuppressVal[value]; } } else { throw ExceptionReporter(UNKNOWNSUPPRESSVAL,(char*)(optionValueList.front().c_str())); } optionValueList.pop_front(); } } else if(optionName == KLongEnableSidCheck) { iValidations |= KMarkEnable; iValidations |= ESid; } else if(optionName == KLongSidAllOption) { iCommmandFlag |= KSidAll; } break; case 'd': if(optionName == KLongEnableDbgFlagCheck) { iValidations |= KMarkEnable; iValidations |= EDbg; if(optionValueList.size() > 0) { if(optionValueList.front() == String("true")) { iDebuggableFlagVal = true; } else if (optionValueList.front() == String("false")) { iDebuggableFlagVal = false; } else { throw ExceptionReporter(UNKNOWNDBGVALUE); } } } else if (optionName == KLongEnableDepCheck) { iValidations |= KMarkEnable; iValidations |= EDep; } break; case 'e': if (optionName == KLongE32InputOption) { iCommmandFlag |= KE32Input; } break; case 'v': if(optionName == KLongVidValOption) { StringListToUnIntList(optionValueList, iVidValList); } else if(optionName == KLongEnableVidCheck) { iValidations |= KMarkEnable; iValidations |= EVid; } else { iCommmandFlag |= KVerbose; /**Initialize ExceptionImplementation class with verbose mode flag to print all status information to standard output*/ ExceptionImplementation::Instance(iCommmandFlag); } break; case 'n': iCommmandFlag |= KNoCheck; break; case 'h': std::cout << PrintVersion().c_str() << std::endl; std::cout << PrintUsage().c_str() << std::endl; return EQuit; //Don't proceed further } } else { if(!AlreadyReceived(name)) { iImageNameList.push_back(name); } else { ExceptionReporter(IMAGENAMEALREADYRECEIVED, (char*)name.c_str()).Report(); } iNoImage = false; } } //While loop ends here if((iCommmandFlag || iValidations || iSuppressions) && iNoImage) { PrintVersion(); PrintUsage(); } //Always log the version information into log file ExceptionImplementation::Instance(iCommmandFlag)->Log(iVersion); ValidateArguments(); ValidateE32NoCheckArguments(); if(iCommmandFlag & KE32Input) { ValidateImageNameList(); } return ESuccess; }
/** Function to convert strings to integers. 1. If any validation is enabled, then only enabled validations are carried. 2. If any validation is suppressed, then all validations are carried execept the suppressed ones. 3. Throws an error if the value is not a decimal or hexadecimal one. @internalComponent @released @param aStrList - List VID values received at command line @param aUnIntList - Received values are validated and put into this container. */ void CmdLineHandler::StringListToUnIntList(StringList& aStrList, UnIntList& aUnIntList) { String tempString; Long64 intValue = 0; while(aStrList.size() > 0) { tempString = aStrList.front(); if(tempString.length() >= 2) //Hex number should start with '0x' { //is this an Hexadecimal number? if((tempString.at(0) == '0') && (tempString.at(1) == 'x')) { tempString = tempString.substr(2); unsigned int location = 0; if(!tempString.empty()) { while(location < tempString.length()) //Ignore proceeding zeros. { if(tempString.at(location) == '0') { location++; continue; } break; } } else { throw ExceptionReporter(INVALIDVIDVALUE,(char*)aStrList.front().c_str()); } tempString = tempString.substr(location); if(tempString.empty() && location != 0) { tempString = '0'; } unsigned int strLength = tempString.length(); if(strLength <= KHexEightByte && strLength > 0) { if(tempString.find_first_not_of(KHexNumber) == String::npos) { aUnIntList.push_back(ReaderUtil::HexStrToInt(tempString)); aStrList.pop_front(); continue; } } else { throw ExceptionReporter(DATAOVERFLOW,(char*)tempString.c_str()); } } } //is this an Decimal number? if(tempString.find_first_not_of(KDecNumber) == String::npos) { intValue = ReaderUtil::DecStrToInt(tempString); if(intValue <= KDecHighValue) { aUnIntList.push_back(intValue); } else { throw ExceptionReporter(DATAOVERFLOW,(char*)tempString.c_str()); } } else { throw ExceptionReporter(INVALIDVIDVALUE,(char*)tempString.c_str()); } aStrList.pop_front(); } }
void InitialServerStreamProtocol::readOptionMap(const StringStringListMap& clientOptionMap) { #if defined OPENRTI_ENCODING_DEVELOPMENT_WARNING Log(MessageCoding, Warning) << OPENRTI_ENCODING_DEVELOPMENT_WARNING << std::endl; #endif // Given the clients values in value map, choose something sensible. // Here we might want to have something configurable to prefer something over the other?? StringStringListMap::const_iterator i; i = clientOptionMap.find("version"); if (i == clientOptionMap.end()) { errorResponse("No version field in the connect header given."); return; } // Currently only version OPENRTI_ENCODING_VERSION is supported on both sides, currently just something to be // extensible so that we can change something in the future without crashing clients or servers // by a wrong protocol or behavior. if (!contains(i->second, OPENRTI_ENCODING_VERSION)) { errorResponse("Client does not support version " OPENRTI_ENCODING_VERSION " of the protocol."); return; } // Check the encodings i = clientOptionMap.find("encoding"); if (i == clientOptionMap.end() || i->second.empty()) { errorResponse("Client advertises no encoding!"); return; } // collect some possible encodings StringList encodingList = MessageEncodingRegistry::instance().getCommonEncodings(i->second); if (encodingList.empty()) { errorResponse("Client and server have no common encoding!"); return; } // FIXME Here, we could negotiate with a server configuration which one to take... // Preload this with the server nodes configuration StringStringListMap responseValueMap; responseValueMap = _networkServer.getServerNode().getServerOptions()._optionMap; // Since we already asked for the common encodings, this must be successful now. SharedPtr<AbstractMessageEncoding> messageProtocol; messageProtocol = MessageEncodingRegistry::instance().getEncoding(encodingList.front()); // FIXME May be get this from the Server? // This way we could get a connect that matches the network servers idea of threading? SharedPtr<NetworkServerConnect> connect = new NetworkServerConnect; connect->connect(_networkServer, clientOptionMap); messageProtocol->setConnect(connect); // This is the part of the protocol stack that replaces this initial stuff. SharedPtr<AbstractProtocolLayer> protocolStack = messageProtocol; // Survived, respond with a valid response packet responseValueMap["version"].clear(); responseValueMap["version"].push_back(OPENRTI_ENCODING_VERSION); responseValueMap["encoding"].clear(); responseValueMap["encoding"].push_back(encodingList.front()); responseValueMap["compression"].clear(); i = clientOptionMap.find("compression"); if (i != clientOptionMap.end()) { for (StringList::const_iterator j = i->second.begin(); j != i->second.end(); ++j) { // #if defined(OPENRTI_HAVE_XZ) // if (*j == "lzma") { // SharedPtr<LZMACompressionProtocolLayer> layer = new LZMACompressionProtocolLayer; // layer->setProtocolLayer(protocolStack); // protocolStack = layer; // responseValueMap["compression"].push_back("lzma"); // break; // } // #endif #if defined(OPENRTI_HAVE_ZLIB) if (*j == "zlib") { SharedPtr<ZLibProtocolLayer> layer = new ZLibProtocolLayer; layer->setProtocolLayer(protocolStack); protocolStack = layer; responseValueMap["compression"].push_back("zlib"); break; } #endif } } if (responseValueMap["compression"].empty()) responseValueMap["compression"].push_back("no"); writeOptionMap(responseValueMap); setFollowupProtocol(protocolStack); }