void convertHitsToASQG(const std::string& indexPrefix, const StringVector& hitsFilenames, std::ostream* pASQGWriter) { // Load the suffix array index and the reverse suffix array index // Note these are not the full suffix arrays SuffixArray* pFwdSAI = new SuffixArray(indexPrefix + SAI_EXT); SuffixArray* pRevSAI = new SuffixArray(indexPrefix + RSAI_EXT); // Load the ReadInfoTable for the queries to look up the ID and lengths of the hits ReadInfoTable* pQueryRIT = new ReadInfoTable(opt::readsFile); // If the target file is not the query file, load its ReadInfoTable ReadInfoTable* pTargetRIT; if(!opt::targetFile.empty() && opt::targetFile != opt::readsFile) pTargetRIT = new ReadInfoTable(opt::targetFile); else pTargetRIT = pQueryRIT; bool bIsSelfCompare = pTargetRIT == pQueryRIT; // Convert the hits to overlaps and write them to the asqg file as initial edges for(StringVector::const_iterator iter = hitsFilenames.begin(); iter != hitsFilenames.end(); ++iter) { printf("[%s] parsing file %s\n", PROGRAM_IDENT, iter->c_str()); std::istream* pReader = createReader(*iter); // Read each hit sequentially, converting it to an overlap std::string line; while(getline(*pReader, line)) { size_t readIdx; size_t totalEntries; bool isSubstring; OverlapVector ov; OverlapCommon::parseHitsString(line, pQueryRIT, pTargetRIT, pFwdSAI, pRevSAI, bIsSelfCompare, readIdx, totalEntries, ov, isSubstring); for(OverlapVector::iterator iter = ov.begin(); iter != ov.end(); ++iter) { ASQG::EdgeRecord edgeRecord(*iter); edgeRecord.write(*pASQGWriter); } } delete pReader; // delete the hits file unlink(iter->c_str()); } // Deallocate data if(pTargetRIT != pQueryRIT) delete pTargetRIT; delete pFwdSAI; delete pRevSAI; delete pQueryRIT; }
void RegistryComponent::SetComponentInfo(const ComponentInfo &info) { std::string KeyComponentClassId = Key_ComponentClassIDs; KeyComponentClassId += "/"; StringVector ClassIDs = info.GetClassIDs(); for (StringVector::const_iterator i = ClassIDs.begin() ; i != ClassIDs.end() ; ++i) { std::string ClassId = KeyComponentClassId; ClassId += *i; Reg.CreateKey(ClassId); Reg.SetValue(ClassId, info.GetModuleGuid().c_str()); } std::string KeyComponentInformation = Key_ComponentInformation; KeyComponentInformation += "/"; KeyComponentInformation += info.GetModuleGuid(); KeyComponentInformation += "/"; std::string Key = KeyComponentInformation; Key += Key_Type; Reg.CreateKey(Key); Reg.SetValue(Key, info.GetTypeAsStr().c_str()); Key = KeyComponentInformation; Key += Key_ModuleName; Reg.CreateKey(Key); Reg.SetValue(Key, info.GetModuleName().c_str()); Key = KeyComponentInformation; Key += Key_Location; Reg.CreateKey(Key); Reg.SetValue(Key, info.GetLocation().c_str()); Key = KeyComponentInformation; Key += Key_Description; Reg.CreateKey(Key); Reg.SetValue(Key, info.GetDescription().c_str()); Key = KeyComponentInformation; Key += Key_ClassIDs; Reg.CreateKey(Key); unsigned Index = 0; for (StringVector::const_iterator i = ClassIDs.begin() ; i != ClassIDs.end() ; ++i) { std::stringstream Io; Io << Key_ClassId << Index++; std::string ClassIdKey = Key + "/" + Io.str(); Reg.CreateKey(ClassIdKey); Reg.SetValue(ClassIdKey, static_cast<const char*>(i->c_str())); } }
//----------------------------------------------------------------------- void CgProgram::buildArgs(void) { StringVector args; if (!mCompileArgs.empty()) args = StringUtil::split(mCompileArgs); StringVector::const_iterator i; if (mSelectedCgProfile == CG_PROFILE_VS_1_1) { // Need the 'dcls' argument whenever we use this profile // otherwise compilation of the assembler will fail bool dclsFound = false; for (i = args.begin(); i != args.end(); ++i) { if (*i == "dcls") { dclsFound = true; break; } } if (!dclsFound) { args.push_back("-profileopts"); args.push_back("dcls"); } } // Now split args into that god-awful char** that Cg insists on freeCgArgs(); mCgArguments = new char*[args.size() + 1]; int index = 0; for (i = args.begin(); i != args.end(); ++i, ++index) { mCgArguments[index] = new char[i->length() + 1]; strcpy(mCgArguments[index], i->c_str()); } // Null terminate list mCgArguments[index] = 0; }
void CLocation::SetMember(size_t i, const string& str) { _ASSERTE(i < NB_MEMBER); switch (i) { case ID: m_ID = str; break; case NAME: m_name = str; break; case LAT: m_lat = ToDouble(str); break; case LON: m_lon = ToDouble(str); break; case ELEV: m_elev = ToDouble(str); break; case SSI: { StringVector SSIs(str.c_str(), "{}"); for (StringVector::const_iterator it = SSIs.begin(); it != SSIs.end(); it++) { string::size_type pos = it->find(':', 0); if (pos < string::npos) SetSSI(it->substr(0, pos), it->substr(pos + 1)); } break; } default: _ASSERTE(false); } }
int main(int argc, char * argv[]) { try { Options options; options.descriptions.add_options() ("show-urls", "Show all the capability URLs") ; if (!options.ParseCommandLine(argc, argv)) { return 0; } RetsSessionPtr session = options.RetsLogin(); if (!session) { cout << "Login failed\n"; return -1; } cout << "Logged in\n"; LoginResponse * login = session->GetLoginResponse(); CapabilityUrls * urls = session->GetCapabilityUrls(); cout << "Member name: " << login->GetMemberName() << endl; cout << "Search URL: " << urls->GetSearchUrl() << endl; cout << "Action:\n" << session->GetAction() << endl; if (session->GetDetectedRetsVersion() >= RETS_1_8) { try { cout << "User ID:" << login->GetUserID() << endl; cout << "User Class: " << login->GetUserClass() << endl; cout << "User Level: " << login->GetUserLevel() << endl; cout << "Agent Code: " << login->GetAgentCode() << endl; if (options.count("verbose")) { cout << "Broker Code: " << login->GetBrokerCode() << endl; cout << "Broker Branch: " << login->GetBrokerBranch() << endl; cout << "Metadata ID: " << login->GetMetadataID() << endl; cout << "Metadata Version: " << login->GetMetadataVersion() << endl; cout << "Metadata Timestamp: " << login->GetMetadataTimestamp() << endl; cout << "Min Metadata Timestamp: " << login->GetMinMetadataTimestamp() << endl; cout << "Balance: " << login->GetBalance() << endl; cout << "Timeout Seconds: " << login->GetTimeout() << endl; cout << "Password Expiration: " << login->GetPasswordExpire() << endl; cout << "Password Expiration Warn: " << login->GetWarnPasswordExpirationDays() << endl; cout << "OfficeList: " << login->GetOfficeList() << endl; cout << "Standard Names Version: " << login->GetStandardNamesVersion() << endl; cout << "Vendor Name: " << login->GetVendorName() << endl; cout << "Server Product Name: " << login->GetServerProductName() << endl; cout << "Operator Name: " << login->GetOperatorName() << endl; cout << "Role Name: " << login->GetRoleName() << endl; cout << "Support Contact Information: " << login->GetSupportContactInformation() << endl; } } catch (RetsException & e) { /* * The ServerInformation Transaction is not supported. * Continue silently. */ } } if (options.count("show-urls")) { /* * Action and Search URLs unconditionally shown above. */ cout << "Change Password URL: " << urls->GetChangePasswordUrl() << endl; cout << "GetObject URL: " << urls->GetGetObjectUrl() << endl; cout << "Login Complete URL: " << urls->GetLoginCompleteUrl() << endl; cout << "Logout URL: " << urls->GetLogoutUrl() << endl; cout << "GetMetadata URL: " << urls->GetGetMetadataUrl() << endl; cout << "ServerInformation URL: " << urls->GetServerInformationUrl() << endl; cout << "Update URL: " << urls->GetUpdateUrl() << endl; if (session->GetDetectedRetsVersion() >= RETS_1_8) { cout << "Payload List URL: " << urls->GetPayloadListUrl() << endl; } cout << endl; } if (session->GetDetectedRetsVersion() == RETS_1_7) { try { ServerInformationResponseAPtr serverInfo = session->GetServerInformation(); if (serverInfo.get()) { StringVector parameters = serverInfo->GetParameters(); StringVector::const_iterator i; for (i = parameters.begin(); i != parameters.end(); i++) { if (i->empty()) { continue; } cout << *i << ": " << serverInfo->GetValue(*i) << endl; } } } catch (RetsException & e) { /* * The ServerInformation Transaction is not supported. * Continue silently. */ } } if (session->GetDetectedRetsVersion() >= RETS_1_8) { try { PayloadListResultSetAPtr payloadList = session->GetPayloadList(""); if (options.count("verbose")) { cout << setw(15) << "Class" << ": " << setw(0) << payloadList->GetPayloadClass() << endl; cout << setw(15) << "Resource" << ": " << setw(0) << payloadList->GetPayloadResource() << endl; cout << setw(15) << "Date" << ": " << setw(0) << payloadList->GetPayloadDate() << endl; cout << setw(15) << "Version" << ": " << setw(0) << payloadList->GetPayloadVersion() << endl << endl; } while (payloadList->HasNext()) { StringVector columns = payloadList->GetColumns(); StringVector::const_iterator i; for (i = columns.begin(); i != columns.end(); i++) { string column = *i; cout << setw(15) << column << ": " << setw(0) << payloadList->GetString(column) << endl; } cout << endl; } } catch (RetsException & e) { /* * The GetPayloadList Transaction is not supported. */ cout << e.what() << endl; } } LogoutResponseAPtr logout = session->Logout(); cout << "Logged out\n"; if (logout.get()) { cout << "Billing information: " << logout->GetBillingInfo() << endl; cout << "Connect time: " << logout->GetConnectTime() << endl; cout << "Message: " << logout->GetLogoutMessage() << endl; } } catch (RetsException & e) { e.PrintFullReport(cerr); return 1; } catch (exception & e) { cerr << e.what() << endl; return 2; } return 0; }
int main(int argc, char * argv[]) { try { Options options; if (!options.ParseCommandLine(argc, argv)) { return 0; } RetsSessionPtr session = options.RetsLogin(); if (!session) { cout << "Login failed\n"; return -1; } if (session->GetDetectedRetsVersion() != session->GetRetsVersion()) { cout << "** Warning, requested RETS version \"" << session->RetsVersionToString(session->GetRetsVersion()) << "\", got version \"" << session->RetsVersionToString(session->GetDetectedRetsVersion()) << "\" ** " << endl; } if (session->GetDetectedRetsVersion() == RETS_1_7) { try { ServerInformationResponseAPtr serverInfo = session->GetServerInformation(); if (serverInfo.get()) { StringVector parameters = serverInfo->GetParameters(); StringVector::const_iterator i; for (i = parameters.begin(); i != parameters.end(); i++) { if (i->empty()) { continue; } cout << *i << ": " << serverInfo->GetValue(*i) << endl; } } } catch (RetsException & e) { /* * The ServerInformation Transaction is not supported. * Continue silently. */ } } RetsMetadata * metadata = session->GetMetadata(); dumpSystem(metadata); dumpAllForeignKeys(metadata); dumpAllResources(metadata); session->Logout(); } catch (RetsException & e) { e.PrintFullReport(cout); return 1; } catch (exception & e) { cout << e.what() << endl; return 2; } return 0; }