void mozTXTToHTMLConv::CompleteAbbreviatedURL(const PRUnichar * aInString, PRInt32 aInLength, const PRUint32 pos, nsString& aOutString) { NS_ASSERTION(PRInt32(pos) < aInLength, "bad args to CompleteAbbreviatedURL, see bug #190851"); if (PRInt32(pos) >= aInLength) return; if (aInString[pos] == '@') { // only pre-pend a mailto url if the string contains a .domain in it.. //i.e. we want to linkify [email protected] but not "let's meet @8pm" nsDependentString inString(aInString, aInLength); if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign.... { aOutString.AssignLiteral("mailto:"); aOutString += aInString; } } else if (aInString[pos] == '.') { if (ItMatchesDelimited(aInString, aInLength, NS_LITERAL_STRING("www.").get(), 4, LT_IGNORE, LT_IGNORE)) { aOutString.AssignLiteral("http://"); aOutString += aInString; } else if (ItMatchesDelimited(aInString,aInLength, NS_LITERAL_STRING("ftp.").get(), 4, LT_IGNORE, LT_IGNORE)) { aOutString.AssignLiteral("ftp://"); aOutString += aInString; } } }
NS_IMETHODIMP mozSqlConnectionODBC::Init(const nsAString &aHost, PRInt32 aPort, const nsAString &aDatabase, const nsAString &aUsername, const nsAString &aPassword) { if (mConnection) return NS_OK; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &mEnv); SQLSetEnvAttr(mEnv, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, mEnv, &mConnection); NS_LossyConvertUTF16toASCII inString(NS_LITERAL_STRING("DSN=") + aDatabase + NS_LITERAL_STRING(";UID=") + aUsername + NS_LITERAL_STRING(";PWD=") + aPassword); char outString[1024]; SQLSMALLINT outStringLength; if (!SQL_SUCCEEDED(SQLDriverConnect(mConnection, NULL, (SQLCHAR*)inString.get(), inString.Length(), (SQLCHAR*)outString, sizeof(outString), &outStringLength, SQL_DRIVER_COMPLETE))) { SetError(mConnection, SQL_HANDLE_DBC); return NS_ERROR_FAILURE; } return NS_OK; }
std::string Game::ReadInput() { char str[64]; getstr(str); std::string inString(str); return inString; }
int main(int argc, char *args[]){ int i; if(argc <= 1) return 0; for(i = 1; i < argc - 1; i++){ if(0 == strcmp(args[i],"-v")){ printf("Error.\n"); return 0; } } if(!access(args[argc - 1], R_OK)&&inString(args, argc, "-r")) printf("Reading is ok. "); if(!access(args[argc - 1], W_OK)&&inString(args, argc, "-w")) printf("Writing is ok. "); if(!access(args[argc - 1], X_OK)&&inString(args, argc, "-x")) printf("Executing is ok. "); printf("\n"); }
NS_IMETHODIMP mozTXTToHTMLConv::ScanHTML(const PRUnichar *text, PRUint32 whattodo, PRUnichar **_retval) { NS_ENSURE_ARG(text); // FIX ME!!! nsString outString; nsString inString (text); // look at this nasty extra copy of the entire input buffer! outString.SetCapacity(PRUint32(inString.Length() * growthRate)); ScanHTML(inString, whattodo, outString); *_retval = ToNewUnicode(outString); return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY; }
/** * read the file. */ Goods::Goods(std::ifstream& is):count(1), discount(1){ std::string strin, str; while(is >> strin){ str += " " + strin; } /** * [inString store all the input data.] * @str [store the input data temporarily] */ std::istringstream inString(str); int commodity; std::string name; std::string origin; int benchmark; while(inString){ inString >> commodity >> name >> origin >> benchmark; allGoods.push_back(Goods(commodity, name, origin, benchmark)); } allGoods.pop_back(); }
void QueryProcessor::parseQuery(std::string search) { searchQuery = search; istringstream inString(searchQuery); searchWords.clear(); //reading in the query by word save into vector while (inString) { string temp; //breaks if there aren't any words left if (!getline(inString, temp, ' ')) break; //otherwise adds to the search words vector searchWords.push_back(temp); } currentQ->clearQuery(); //finds if there are any not keywords in the file for(int i = searchWords.size() - 1; i >= 0 ; i--) { //adds to not vector if the keyword is found if(searchWords[i].compare("NOT")==0) { notArgFinder(i); break; } } if(searchWords[0].compare("AND")==0) otherArgFinder(0); else if(searchWords[0].compare("OR")==0) otherArgFinder(1); else otherArgFinder(2); stemQuery(); }
std::string WideToUTF8(const wchar_t* in) { std::wstring inString(in); return WideToUTF8(inString); }
std::wstring UTF8ToWide(const char* in) { std::string inString(in); return UTF8ToWide(inString); }
void read_FLO_file( std::string filePATH, cv::Mat &flow, float &maxxV ) { std::cout << "read_FLO_file - " << filePATH << std::endl; std::ifstream myfile; myfile.open (filePATH.data(), std::ios::binary); std::string inString(4,'\0'); int inInt; float inFloat; float www = 0; float hhh = 0; std::cout << "fileSize = " << sizeof(myfile) << std::endl; std::cout << "sizeof(int) = " << sizeof(int ) << std::endl; std::cout << "sizeof(float) = " << sizeof(float) << std::endl; if(myfile.is_open()) { myfile.read( &inString[0], 4 ); myfile.read( (char*)&inInt, sizeof(int) ); www = inInt; myfile.read( (char*)&inInt, sizeof(int) ); hhh = inInt; } ////////////////////////////////////////// flow = cv::Mat::zeros(hhh,www,CV_32FC2); ////////////////////////////////////////// maxxV = -999999; for (int iii=0; iii<hhh; iii++) { for (int jjj=0; jjj<www; jjj++) { myfile.read( (char*)&inFloat, sizeof(float) ); flow.at<cv::Point2f>(iii,jjj).x = inFloat; myfile.read( (char*)&inFloat, sizeof(float) ); flow.at<cv::Point2f>(iii,jjj).y = inFloat; if ( flow.at<cv::Point2f>(iii,jjj).x<1e9 && flow.at<cv::Point2f>(iii,jjj).y<1e9 ) { float magn = sqrt( pow(flow.at<cv::Point2f>(iii,jjj).x,2) + pow(flow.at<cv::Point2f>(iii,jjj).y,2) ); if (magn>maxxV) maxxV=magn; } } } std::cout << "\n\n~EOF~ " << maxxV << "\n\n" << std::endl; if(myfile.is_open()) { myfile.read( (char*)&inFloat, sizeof(float) ); // just to reach EOF while(!myfile.eof()) { std::cout << "not EOF!" << std::endl; } } myfile.close(); }