您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stof函数代码示例

51自学网 2021-06-03 08:24:00
  C++
这篇教程C++ stof函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中stof函数的典型用法代码示例。如果您正苦于以下问题:C++ stof函数的具体用法?C++ stof怎么用?C++ stof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了stof函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: int

std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {  for (size_t idx = 0; idx < om.size(); ++idx)      for (const auto& it : om)          if (it.second.idx == idx)          {              const Option& o = it.second;              os << "/noption name " << it.first << " type " << o.type;              if (o.type == "string" || o.type == "check" || o.type == "combo")                  os << " default " << o.defaultValue;              if (o.type == "spin")                  os << " default " << int(stof(o.defaultValue))                     << " min "     << o.min                     << " max "     << o.max;              break;          }  return os;}
开发者ID:DU-jdto,项目名称:Stockfish,代码行数:22,


示例2: getline

void Codebook::readIn(string filePath){    ifstream file;    file.open (filePath, ios::in);    string line;    getline (file,line);    int numOfEntries = stoi(line);//    assert(numOfEntries==CODEBOOK_SIZE);    getline (file,line);    int numOfFeatures = stoi(line);    for (int n=0; n < numOfEntries; n++)    {        vector<double> exemplar;        for (int f=0; f < numOfFeatures; f++)        {            getline (file,line);            double val = stof(line);            exemplar.push_back(val);        }        push_back(exemplar);    }    file.close();}
开发者ID:herobd,项目名称:ComputerVision,代码行数:23,


示例3: stof

Plane* SDLReader::read_plane(string filename){  Plane *plane;	Util::read_file(filename, [&plane](string line, int i) {	if(line.size() == 0) 		return;    if(i > 1)       return;        vector<string> parm = Util::split_on_separators(line," ");    float a = stof(parm[0]);      float b = stof(parm[1]);      float c = stof(parm[2]);     float d = stof(parm[3]);    float x0 = stof(parm[4]);     float y0 = stof(parm[5]);    float z0 = stof(parm[6]);    plane = new Plane(a, b, c, d, x0, y0, z0);  });    return plane;}
开发者ID:luiz-reis,项目名称:pg-corte-plano,代码行数:23,


示例4: split

Component *Vector::spawn(std::string sig, std::string args){	std::vector<std::string> arguments = split(args, ' ');	arguments.erase(arguments.begin());	if(sig.compare("ff") == 0){		return new Vector(stof(arguments[0]), stof(arguments[1]));	}else if(sig.compare("ffi") == 0){		return new Vector(stof(arguments[0]), stof(arguments[1]), stoi(arguments[2]));	}else if(sig.compare("ffs") == 0){		int type = 0;		if(arguments[2].compare("velocity") == 0){			type = COMPONENT_VELOCITY;		}		if(arguments[2].compare("acceleration") == 0){			type = COMPONENT_ACCELERATION;		}		if(arguments[2].compare("angularVelocity") == 0){			type = COMPONENT_ANGULARVELOCITY;		}		return new Vector(stof(arguments[0]), stof(arguments[1]), type);	}	return new Vector();}
开发者ID:askillin,项目名称:LD33,代码行数:23,


示例5: readShip

void Save::readShip(Ship* mShip, string& property, string& value){	if (!readObject(mShip, property, value))	{		if (!property.compare("health"))		{			mShip->setHealth(stoi(value));		}		if (!property.compare("numFiredBullets"))		{			mShip->setNumFiredBullets(stoi(value));		}		if (!property.compare("score"))		{			mShip->setScore(stoi(value));		}		if (!property.compare("lastHitPlanet"))		{			mShip->setLastHitPlanet(stoi(value));		}		if (!property.compare("speed"))		{			mShip->setSpeed(stof(value));		}		if (!property.compare("acceleration"))		{			mShip->setAcceleration(stof(value));		}		if (!property.compare("jolt"))		{			mShip->setJolt(stof(value));		}		if (!property.compare("maxSpeed"))		{			mShip->setMaxSpeed(stof(value));		}		if (!property.compare("timer"))		{			mShip->setTimer(stof(value));		}		if (!property.compare("mAnimationStill"))		{			//Manage the animation			getMI()->_animationManager->addToSurface(mShip->getAnimationStill(), value.c_str(), IND_ALPHA, IND_32);			getMI()->_entity2dManager->add(mShip->getAnim2dShip());			mShip->getAnim2dShip()->setAnimation(mShip->getAnimationStill());			mShip->loadPropsAnim2d();			// manage the 2d entity			mShip->getEntity2d()->setPosition(mShip->getPosX(), mShip->getPosY(), 1);			// set bounding areas			mShip->getEntity2d()->setBoundingAreas("../SpaceGame/resources/Spaceship with motor new/spaceship_collisions.xml");		}		if (!property.compare("mAnimationShip"))		{			getMI()->_animationManager->addToSurface(mShip->getAnimationShip(), value.c_str(), IND_ALPHA, IND_32);		}		if (!property.compare("mAnimationLeft"))		{			getMI()->_animationManager->addToSurface(mShip->getAnimationLeft(), value.c_str(), IND_ALPHA, IND_32);		}		if (!property.compare("mAnimationRight"))		{			getMI()->_animationManager->addToSurface(mShip->getAnimationRight(), value.c_str(), IND_ALPHA, IND_32);		}		if (!property.compare("mAnimationExplode"))		{			getMI()->_animationManager->addToSurface(mShip->getAnimationExplode(), value.c_str(), IND_ALPHA, IND_32);		}		if (!property.compare(0, 6, "bullet"))		{			// extract the serial number of the bullet			int id = std::stoi(property.substr(6, property.find_first_of("-") - 6));			if (mShip->getBullets().size() <= id)			{				mShip->getBullets().push_back(new Bullet());				mShip->getBullets().back()->setMI(getMI());			}			// change property so that it contains only the actual property of the bullet			property = property.substr(property.find_first_of("-") + 1, property.find_first_of("]") - property.find_first_of("-") - 1);			readBullet(mShip->getBullets().back(), property, value);		}	}}
开发者ID:uzunov-dimitar,项目名称:TeamRocketGame,代码行数:85,


示例6: song_battle

//.........这里部分代码省略.........	//score	int score = 0; //starting game score				   //text that appears on the screen telling how accurate the hit was	sf::Text hitText;	hitText.setFont(gameFont);	hitText.setCharacterSize(50);	//for text that appears on the side of the song battle	sf::Text sideText;	sideText.setFont(gameFont);	//initialize character texture/sprite	std::deque<sf::Texture> charTextures;	std::deque<Character> * activeTeam = (*(*profile).getTeam()).getActiveTeam();	for (int i = 0; i < (*activeTeam).size(); i++) {		sf::Texture charTexture;		if (!charTexture.loadFromFile("characters/team_" + (*(*profile).getTeam()).getTeamName() + "/" + (*activeTeam)[i].getImagePath())) {			std::cout << "ERROR: Cannot load image for character " << (*activeTeam)[i].getInfoPath() << "/n";		}		charTextures.push_back(charTexture);	}	sf::Sprite charSprite;	//load beats	std::deque<Beat> beatList;	std::ifstream file(filePath + ".txt");	std::string line;	const std::string delimiter = "@";	if (file.is_open()) {		while (std::getline(file, line)) {			std::string key = line.substr(0, line.find(delimiter));			float time = stof(line.substr(line.find(delimiter) + 1, line.length()));			sf::CircleShape shapeGraphics(30);			if (key == "Left") {				//shapeGraphics.setFillColor(sf::Color(102, 1, 46, 128));				//shapeGraphics.setFillColor(sf::Color(205, 54, 128));				shapeGraphics.setFillColor(sf::Color(250, 127, 191));				shapeGraphics.setOutlineThickness(5);				shapeGraphics.setOutlineColor(sf::Color(250, 127, 191));				shapeGraphics.setPosition(20, 0);			}			else if (key == "Up") {				shapeGraphics.setPointCount(3);				//shapeGraphics.setFillColor(sf::Color(25, 80, 70, 128));				shapeGraphics.setFillColor(sf::Color(4, 240, 186));				shapeGraphics.setOutlineThickness(5);				shapeGraphics.setOutlineColor(sf::Color(4, 240, 186));				shapeGraphics.setPosition(270, 0);			}			else if (key == "Right") {				shapeGraphics.setPointCount(4);				//shapeGraphics.setFillColor(sf::Color(18, 40, 76, 128));				shapeGraphics.setFillColor(sf::Color(5, 220, 238));				shapeGraphics.setOutlineThickness(5);				shapeGraphics.setOutlineColor(sf::Color(5, 220, 238));				shapeGraphics.setPosition(520, 0);			}			beatList.push_back(Beat(key, time, shapeGraphics));		}	}	Beat beat = beatList.front();	bool finished = false; //status of empty beatlist
开发者ID:wgwong,项目名称:akb48_ongaku_geimu,代码行数:67,


示例7: cmdHelp

void cmdHelp(std::string* args, CannonBall* ball){    if (args[0].compare("help") == 0)    {        printf("exit                Exits the program/n");        printf("help                Lists available commands./n");        printf("printinfo           Prints velocity and force acting on the cannonball/n");        printf("setlinvel x y z     Sets velocity of cannonball/n");        printf("setangvel x y z     Sets angular velocity of ball/n");        printf("setwind x y z       Sets wind velocity/n");        printf("setmass m           Sets mass of cannonball/n");        printf("setradius r         Sets radius of cannonball/n");        printf("setpos x y z        Sets the position of the cannonball/n");        printf("reset               Sets position, lin. velocity, ang. velocity and wind to 0./n");        printf("launch              Launches the ball/n");    }    else if (args[0].compare("printinfo") == 0)    {        ball->printInfo();    }    else if (args[0].compare("launch") == 0)    {        ball->launch = true;    }    else if (args[0].compare("setpos") == 0)    {        float x, y, z;        set3f(x, y, z, args);        ball->pos.x = x;        ball->pos.y = y;        ball->pos.z = z;    }    else if (args[0].compare("reset") == 0)    {        ball->pos = vec3f(10, 0, ball->radius);        ball->linVel = vec3f(0, 0, 0);        ball->launch = false;        wind = vec3f(0, 0, 0);        ball->angVel = vec3f(0, 0, 0);    }    else if (args[0].compare("setlinvel") == 0)    {        float x, y, z;        set3f(x, y, z, args);        ball->linVel.x = x;        ball->linVel.y = y;        ball->linVel.z = z;        cannon->setDirection(ball->linVel);    }    else if (args[0].compare("setangvel") == 0)    {        float x, y, z;        set3f(x, y, z, args);        ball->angVel.x = x;        ball->angVel.y = y;        ball->angVel.z = z;    }    else if (args[0].compare("setwind") == 0)    {        float x, y, z;        set3f(x, y, z, args);        wind.x = x;        wind.y = y;        wind.z = z;    }    else if (args[0].compare("setmass") == 0)    {        float x = 0;        x = stof(args[1]);        if (x > EPSILON)        {            ball->mass = x;            ball->gravForce = vec3f(0.0f, 0.0f, ball->mass * -1.0f * GRAVACC);        }        else            printf("Mass too low/n");    }    else if (args[0].compare("setradius") == 0)    {        float x = 0;        x = stof(args[1]);        if (x > EPSILON)        {            ball->radius = x;            ball->area = ball->radius * ball->radius * PI;        }        else            printf("Radius too low/n");    }    else if (args[0].compare("clear") == 0)    {        SDL_LockMutex(gRenderLock);        clearBackground();        SDL_UnlockMutex(gRenderLock);    }    else    {        printf("Unrecognized command/n");    }//.........这里部分代码省略.........
开发者ID:JimNilsson,项目名称:SpelfysikJimPer,代码行数:101,


示例8: XYZPointReader

	XYZPointReader(string file, string format, vector<double> colorRange, vector<double> intensityRange)	: stream(file, std::ios::in | std::ios::binary)	{		this->format = format;		pointsRead = 0;		linesSkipped = 0;		pointCount = 0;		colorScale = -1;		if(intensityRange.size() == 2){			intensityOffset = (float)intensityRange[0];			intensityScale = (float)intensityRange[1]-(float)intensityRange[0];		}else if(intensityRange.size() == 1){			intensityOffset = 0.0f;			intensityScale = (float)intensityRange[0];		}else{			intensityOffset = 0.0f;			intensityScale = 1.0f;		}		if(colorRange.size() == 2){			colorOffset = (float)colorRange[0];			colorScale = (float)colorRange[1];		}else if(colorRange.size() == 1){			colorOffset = 0.0f;			colorScale = (float)colorRange[0];		}else if(colorRange.size() == 0){			colorOffset = 0.0f;			// try to find color range by evaluating the first x points.			float max = 0;			int j = 0; 			string line;			while(getline(stream, line) && j < 1000){				trim(line);				vector<string> tokens = split(line, { '/t', ' ', ',' });				if(this->format == "" && tokens.size() >= 3){					string f(tokens.size(), 's');					f.replace(0, 3, "xyz");					if(tokens.size() >= 6){						f.replace(tokens.size() - 3, 3, "rgb");					}					this->format = f;					cout << "using format: '" << this->format << "'" << endl;				}				if(tokens.size() < this->format.size()){					continue;				}				int i = 0;				for(const auto &f : format) {					string token = tokens[i++];					if(f == 'r'){						max = std::max(max, stof(token));					}else if(f == 'g'){						max = std::max(max, stof(token));					}else if(f == 'b'){						max = std::max(max, stof(token));					}				}								j++;			}			if(max <= 1.0f){				colorScale = 1.0f;			} else if(max <= 255){				colorScale = 255.0f;			}else if(max <= pow(2, 16) - 1){				colorScale =(float)pow(2, 16) - 1;			}else{				colorScale = (float)max;			}			stream.clear();			stream.seekg(0, stream.beg);		}		// read through once to calculate aabb and number of points		while(readNextPoint()){			Point p = getPoint();			aabb.update(p.position);			pointCount++;		}		stream.clear();		stream.seekg(0, stream.beg);	}
开发者ID:davijo,项目名称:PotreeConverter,代码行数:94,


示例9: stof

static char *randramp(CSOUND *csound, SRTBLK *bp, char *p,                      int lincnt, int pcnt, CORFIL *sco)  /* NB np's may reference a ramp but ramps must terminate in valid nums */{    char    *q;    char    *psav;    SRTBLK  *prvbp, *nxtbp;    MYFLT   pval, qval, rval;    extern  MYFLT stof(CSOUND *, char *);    int     pnum, n;    psav = ++p;    if (UNLIKELY(*psav != SP && *psav != LF))      goto error1;    pnum = 0;    q = bp->text;    while (q < p)      if (*q++ == SP)        pnum++;    prvbp = bp; backup:    if (LIKELY((prvbp = prvins(prvbp)) != NULL)) {      p = prvbp->text;      n = pnum;      while (n--)        while (*p++ != SP)          ;      if (UNLIKELY(*p == '~'))        goto backup;    }    else goto error2;    nxtbp = bp; forwrd:    if (LIKELY((nxtbp = nxtins(nxtbp)) != NULL)) {      q = nxtbp->text;      n = pnum;      while (n--)        while (*q++ != SP)          ;      if (*q == '~')        goto forwrd;    }    else goto error2;    pval = stof(csound, p);     /* the error msgs generated by stof     */    qval = stof(csound, q);                         /*   are misleading */    rval = (MYFLT) (((double) (csound->Rand31(&(csound->randSeed1)) - 1)                     / 2147483645.0) * ((double) qval - (double) pval)                    + (double) pval);    fltout(csound, rval, sco);    return(psav); error1:    csound->Message(csound,Str("swrite: output, sect%d line%d p%d has illegal"                   " expramp symbol/n"),               csound->sectcnt,lincnt,pcnt);    goto put0; error2:    csound->Message(csound,Str("swrite: output, sect%d line%d p%d expramp has"                               " illegal forward or backward ref/n"),               csound->sectcnt,lincnt,pcnt); put0:    corfile_putc(csound, '0', sco);    return(psav);}
开发者ID:csound,项目名称:csound,代码行数:64,


示例10: printf

void Session::deposit(){	float val;	string num, str_val, name;	/**	 * admin users have extra information they must provide	 */	if(admin){		printf("COMMAND: deposit - enter user:/n");		getline(cin, name);		if(name.compare("") == 0 || !account->validHolder(name)){			printf("ERROR: User /"%s/" does not exist. Try again/n", 				name.c_str());			return;		}		printf("Depositing to /"%s/" - enter account number:/n", name.c_str());	} else {		/**		 * standard users can only deposit into their own accounts		 */		name = user;		printf("COMMAND: deposit - enter account number:/n");	}	/**	 * account number	 */	getline(cin, num);	if(!account->validNumber(num, name)){		printf("ERROR: Account number /"%s/" is not valid. Try again/n", num.c_str());		return;	}	string available = account->available(num);	if(available.compare("") != 0){		printf("%s/n", available.c_str());		return;	}	printf("Depositing to /"%s/" - enter amount:/n", num.c_str());	/**	 * amount of deposit	 */	getline(cin, str_val);	if(str_val.find_first_not_of(".0123456789") == string::npos){		val = stof(str_val);	} else {		printf("Error: /"%s/" is not a valid number/n", str_val.c_str());		return;	}	/**	 * maximum deposit	 */	if(account->checkAmount(val, true, name, num, admin)){		printf("ERROR: Maximum balance exceeded. Try again/n");		return;	}		/**	 * create successful transaction code	 */	this->file->createTransaction("04", name, num, val, "  ");	printf("Deposit of %.2f - complete!/n", val);	return;}
开发者ID:achalparikh,项目名称:Software_Quality,代码行数:63,


示例11: clear

//.........这里部分代码省略.........		if (columns[j].type == "text")			columntype = COLUMN_TYPE_TEXT;		else if (columns[j].type == "image")			columntype = COLUMN_TYPE_IMAGE;		else if (columns[j].type == "color")			columntype = COLUMN_TYPE_COLOR;		else if (columns[j].type == "indent")			columntype = COLUMN_TYPE_INDENT;		else if (columns[j].type == "tree")			columntype = COLUMN_TYPE_TREE;		else			errorstream<<"Invalid table column type: /""				<<columns[j].type<<"/""<<std::endl;		// Process column options		s32 padding = myround(0.5 * em);		s32 tooltip_index = default_tooltip_index;		s32 align = 0;		s32 width = 0;		s32 span = colcount;		if (columntype == COLUMN_TYPE_INDENT) {			padding = 0; // default indent padding		}		if (columntype == COLUMN_TYPE_INDENT ||				columntype == COLUMN_TYPE_TREE) {			width = myround(em * 1.5); // default indent width		}		for (size_t k = 0; k < columns[j].options.size(); ++k) {			const std::string &name = columns[j].options[k].name;			const std::string &value = columns[j].options[k].value;			if (name == "padding")				padding = myround(stof(value) * em);			else if (name == "tooltip")				tooltip_index = allocString(value);			else if (name == "align" && value == "left")				align = 0;			else if (name == "align" && value == "center")				align = 1;			else if (name == "align" && value == "right")				align = 2;			else if (name == "align" && value == "inline")				align = 3;			else if (name == "width")				width = myround(stof(value) * em);			else if (name == "span" && columntype == COLUMN_TYPE_COLOR)				span = stoi(value);			else if (columntype == COLUMN_TYPE_IMAGE &&					!name.empty() &&					string_allowed(name, "0123456789")) {				s32 content_index = allocImage(value);				active_image_indices.insert(std::make_pair(							stoi(name),							content_index));			}			else {				errorstream<<"Invalid table column option: /""<<name<<"/""					<<" (value=/""<<value<<"/")"<<std::endl;			}		}		// If current column type can use information from "color" columns,		// find out which of those is currently active		if (columntype == COLUMN_TYPE_TEXT) {			for (s32 i = 0; i < rowcount; ++i) {
开发者ID:Bremaweb,项目名称:minetest,代码行数:67,


示例12: stou

string CanIdTranslator::translateValidDataToHex(map<string, CanVariable> &data){	string bin = "0000000000000000000000000000000000000000000000000000000000000000";	int highestBit = 0;	for (map<string, CanVariable>::iterator iter = data.begin(); iter != data.end(); iter++)	{		if (iter->second.getType() == "uint")		{			if (iter->second.getStartBit() + iter->second.getBitLength() > highestBit)				highestBit = iter->second.getStartBit() + iter->second.getBitLength();			unsigned int a = stou(iter->second.getValue());			bin.replace(iter->second.getStartBit(), iter->second.getBitLength(), uint2bin(a, iter->second.getBitLength()));		}		else if (iter->second.getType() == "float")		{			if (iter->second.getStartBit() + iter->second.getBitLength() > highestBit)				highestBit = iter->second.getStartBit() + iter->second.getBitLength();			bin.replace(iter->second.getStartBit(), iter->second.getBitLength(), float2bin(stof(iter->second.getValue()), iter->second.getBitLength()));		}		else if (iter->second.getType() == "enum")		{			if (iter->second.getStartBit() + iter->second.getBitLength() > highestBit)				highestBit = iter->second.getStartBit() + iter->second.getBitLength();			string value = iter->second.getEnumIdValue();			if (value == "")			{				throw new CanMessageException("Got enum that could not be converterd to a value. value = /"" + iter->second.getValue() + "/" enumString is /"" + iter->second.getEnumsString() + "/"/n");			}			else			{				bin.replace(iter->second.getStartBit(), iter->second.getBitLength(), uint2bin(stou(value), iter->second.getBitLength()));			}		}		else if (iter->second.getType() == "ascii")		{			for (int n = 0; n < iter->second.getValue().length(); n++)			{				if (iter->second.getStartBit()+n*8 + 8 > highestBit)					highestBit = iter->second.getStartBit()+n*8 + 8;				//bin.replace(iter->second.getStartBit()+n*8, 8, uint2bin((unsigned int)iter->second.getValue()[n], 8));				unsigned int temp = iter->second.getValue()[n];				if (temp > 0xff)				{					temp &= 0xff;				}				bin.replace(iter->second.getStartBit()+n*8, 8, uint2bin(temp, 8));			}		}		else if (iter->second.getType() == "hexstring")		{			for (int n = 0; n < iter->second.getValue().length(); n++)			{				if (iter->second.getStartBit()+n*4 + 4 > highestBit)					highestBit = iter->second.getStartBit()+n*4 + 4;				string character;				character += iter->second.getValue()[n];				bin.replace(iter->second.getStartBit()+n*4, 4, hex2bin(character));			}		}	}	try	{		while (highestBit%8 != 0)		{		    highestBit++;		}		bin = bin.substr(0, highestBit);	}	catch (std::out_of_range& e)	{		cout << "DEBUG: translateValidDataToHex exception: " << e.what() << "/n";		cout << "DEBUG: A bin=" << bin << " :: highestBit=" << highestBit << endl;	}	return bin2hex(bin);}
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:86,


示例13: stof

float Settings::getFloat(const std::string &name) const{	return stof(get(name));}
开发者ID:blockplanet,项目名称:blockplanet,代码行数:4,


示例14: main

int main(){	enum atomType { CarbonAlpha, Carbon, Nitrogen, Oxygen };	/*enum intensityLevel {low =50 , med = 75, high = 100};	struct helixStruct{		int helixNum;		int startPos;		int endPos;	};	struct strand {		int strandID;		int startPos;		int endPos;	};	struct sheetStruct {		std::vector<strand> strands;		std::string sheetID;		int startPos;		int endPos;	};	*/	struct atom {		atomType type = Carbon;		float x = 0.0f;		float y = 0.0f;		float z = 0.0f;	};	struct residue {		int atomCount = 0;		int residueNum = 0;		atom atoms[4];		std::string chainID = "";	};	//std::vector<secondaryStruct> sheet(1);	//std::vector<residue> residues;	//std::vector<sheetStruct> sheet;	//std::vector<helixStruct> helix;	//std::vector<residue> ();	std::ifstream pdbFile;	std::ofstream skelFile;	residue tmpResidue;	pdbFile.open("../PDB Files/5fj6.pdb");	skelFile.open("../PDB Files/5fj6.skel.pdb");	if (pdbFile.is_open() && skelFile.is_open())	{		int currentRes = 0;		std::string line;		bool isHeaderLine = false;		while (std::getline(pdbFile, line))		{			if (IsHeaderLine(line))			{				skelFile << line << std::endl;			}			else // this is an atom, sheet or helix			{				if (IsAtom(line)) {					int atomResNbr = ToInt(line.substr(23, 4));					if (tmpResidue.residueNum == 0)					{						int resNum = atoi(line.substr(23, 4).c_str());						tmpResidue.atomCount = 1;						tmpResidue.residueNum = resNum;						tmpResidue.chainID = line.substr(21, 1);						tmpResidue.atoms[tmpResidue.atomCount - 1].type = Nitrogen;						tmpResidue.atoms[tmpResidue.atomCount - 1].x = stof(line.substr(31, 8));						tmpResidue.atoms[tmpResidue.atomCount - 1].y = stof(line.substr(39, 8));						tmpResidue.atoms[tmpResidue.atomCount - 1].z = stof(line.substr(47, 8));					}					else {						if (tmpResidue.residueNum == atomResNbr) { // still same amino acid							tmpResidue.atomCount++;							switch (tmpResidue.atomCount) {							case 1:								tmpResidue.atoms[tmpResidue.atomCount - 1].type = Nitrogen;								tmpResidue.atoms[tmpResidue.atomCount - 1].x = stof(line.substr(31, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].y = stof(line.substr(39, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].z = stof(line.substr(47, 8));								break;							case 2:								tmpResidue.atoms[tmpResidue.atomCount - 1].type = CarbonAlpha;								tmpResidue.atoms[tmpResidue.atomCount - 1].x = stof(line.substr(31, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].y = stof(line.substr(39, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].z = stof(line.substr(47, 8));								break;							case 3:								tmpResidue.atoms[tmpResidue.atomCount - 1].type = Carbon;								tmpResidue.atoms[tmpResidue.atomCount - 1].x = stof(line.substr(31, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].y = stof(line.substr(39, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].z = stof(line.substr(47, 8));								break;							case 4:								tmpResidue.atoms[tmpResidue.atomCount - 1].type = Oxygen;								tmpResidue.atoms[tmpResidue.atomCount - 1].x = stof(line.substr(31, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].y = stof(line.substr(39, 8));								tmpResidue.atoms[tmpResidue.atomCount - 1].z = stof(line.substr(47, 8));								break;//.........这里部分代码省略.........
开发者ID:CJonesTSU,项目名称:COMP-4500,代码行数:101,


示例15: convert

 inline static float convert(const std::string& str) {     return stof(str); }
开发者ID:LoweDavince,项目名称:RhIO,代码行数:3,


示例16: re_f

void Standard::Transfer() {    string padded_acc_holder_f;    string padded_acc_holder_t;    string padded_acc_num_f;    string padded_acc_num_t;    string padded_amount;    string padded_new_balance_f;    string padded_new_balance_t;    string acc_holder_t;    string temp_acc_num_f;    string temp_acc_num_t;    string temp_amount;    stringstream stream;    float amount;    float new_balance_f = 0.0;    float new_balance_t = 0.0;    int acc_num_f;    int acc_num_t;    cout << "/nTransfer transaction selected./n" << endl;    cout << "Enter you account number: ";    cin >> temp_acc_num_f;    regex re_f("[0-9]{0,5}");    if (regex_match(temp_acc_num_f, re_f) && temp_acc_num_f.compare("99999") != 0) {        acc_num_f = stoi(temp_acc_num_f);    } else {        cerr << "/n>>> ERROR: The account number entered is invalid./n" << endl;        return;    }    if (curr_user.GetNum() != acc_num_f) {        cerr << "/n>>> ERROR: The account number does not match your account./n" << endl;        cout << "Current user: " << curr_user.GetNum() << ", Account Number: " << acc_num_f << endl;        return;    }    if (transactions.is_Disabled(curr_user.GetNum())) {        cerr << "/n>>> ERROR: The account is disabled; you may not send funds./n" << endl;        return;    }    if (transactions.is_New(curr_user.GetNum())) {        cerr << "/n>>> ERROR: Newly created accounts may not send funds. Please try again in 24 hours./n" << endl;        return;    }    cout << "Enter destination account number: ";    cin >> temp_acc_num_t;    regex re_t("[0-9]{0,5}");    if (regex_match(temp_acc_num_t, re_t) && temp_acc_num_t.compare("99999") != 0) {        acc_num_t = stoi(temp_acc_num_t);    } else {        cerr << "/n>>> ERROR: The account number entered is invalid./n" << endl;        return;    }    if (!transactions.NumExists(acc_num_t)) {        cerr << "/n >>> ERROR: The destination account number entered is invalid./n" << endl;        return;    }    if (transactions.is_Disabled(acc_num_t)) {        cerr << "/n>>> ERROR: Disabled accounts may not receive funds./n" << endl;        return;    }    cout << "Enter amount to transfer: ";    cin >> temp_amount;    if (transactions.is_Amount_Valid(temp_amount)) {        amount = stof(temp_amount);    } else {        cerr << "/n>>> ERROR: The amount entered is invalid./n" << endl;        return;    }    for (int i = 0; i < users.size(); i++) {        if (users.at(i).GetNum() == acc_num_t) {            acc_holder_t = users.at(i).GetName();        }    }    padded_acc_holder_f = curr_user.GetName();    while (padded_acc_holder_f.length() < 20) {        padded_acc_holder_f = padded_acc_holder_f + " ";    }    padded_acc_holder_t = acc_holder_t;    while (padded_acc_holder_t.length() < 20) {        padded_acc_holder_t = padded_acc_holder_t + " ";    }    padded_acc_num_f = temp_acc_num_f;    while (padded_acc_num_f.length() < 5) {        padded_acc_num_f = "0" + padded_acc_num_f;    }//.........这里部分代码省略.........
开发者ID:lrojas12,项目名称:CSCI3060Phase1-5,代码行数:101,


示例17: re

void Standard::Paybill() {    string padded_acc_holder;    string padded_acc_num;    string padded_amount;    string padded_new_balance;    string acc_holder;    string temp_acc_num;    string temp_amount;    string company;    stringstream stream;    float amount;    float new_balance;    float company_count;    int acc_num;    cout << "/nPay bill transaction selected./n" << endl;    cout << "Enter your account number: ";    cin >> temp_acc_num;    regex re("[0-9]{0,5}");    if (regex_match(temp_acc_num, re)) {        acc_num = stoi(temp_acc_num);    } else {        cerr << "/n>>> ERROR: The account number entered is invalid./n" << endl;        return;    }    if (curr_user.GetNum() != acc_num) {        cerr << "/n>>> ERROR: The account number does not match your account./n" << endl;        return;    }    if (transactions.is_Disabled(curr_user.GetNum())) {        cerr << "/n>>> ERROR: The account is disabled; you may not send funds./n" << endl;        return;    }    if (transactions.is_New(curr_user.GetNum())) {        cerr << "/n>>> ERROR: Newly created accounts may not send funds. Please try again in 24 hours./n" << endl;        return;    }    cout << "Enter company: ";    cin >> company;    company = transactions.to_Lower(company);    if (company.compare("EC") != 0 || company.compare("CQ") != 0 || company.compare("TV") != 0) {        cerr << "/n>>> ERROR: The company name is invalid. Must be one of the following: EC, CQ or TV./n" << endl;        return;    }    cout << "Enter amount to pay: ";    cin >> temp_amount;    if (transactions.is_Amount_Valid(temp_amount)) {        amount = stof(temp_amount);    } else {        cerr << "/n>>> ERROR: The amount entered is invalid./n" << endl;        return;    }    if ((curr_user.GetBalance() - curr_user.GetDeposited()) < amount) {        cerr << "/n>>> ERROR: You may not pay bills using recently deposited funds./n" << endl;        return;    }    if (company.compare("EC") == 0) {        company_count = curr_user.GetECCount() + amount;        if (company_count > 2000.00) {            cerr << "/n>>> ERROR: The limit to pay per company per day is $2000.00./n" << endl;            return;        }        curr_user.SetECCount(company_count);    } else if (company.compare("TV") == 0) {        company_count = curr_user.GetTVCount() + amount;        if (company_count > 2000.00) {            cerr << "/n>>> ERROR: The limit to pay per company per day is $2000.00./n" << endl;            return;        }        curr_user.SetTVCount(company_count);    } else {        company_count = curr_user.GetCQCount() + amount;        if (company_count > 2000.00) {            cerr << "/n>>> ERROR: The limit to pay per company per day is $2000.00./n" << endl;            return;        }        curr_user.SetCQCount(company_count);    }    if (amount <= curr_user.GetBalance() && amount > 0.0) {        /*         * Done in the Back End         *         if (curr_user.GetPlan() == 'S')           new_balance = curr_user.GetBalance() - amount - 0.05;         else if (curr_user.GetPlan() == 'N')           new_balance = curr_user.GetBalance() - amount - 0.10;//.........这里部分代码省略.........
开发者ID:lrojas12,项目名称:CSCI3060Phase1-5,代码行数:101,


示例18: readNextPoint

	bool readNextPoint(){		double x = 0;		double y = 0;		double z = 0;		float nx = 0;		float ny = 0;		float nz = 0;		unsigned char r = 255;		unsigned char g = 255;		unsigned char b = 255;		// unsigned char a = 255;  // unused variable		unsigned short intensity = 0;		string line;		while(getline(stream, line)){			trim(line);			vector<string> tokens = split(line, {'/t', ' ', ','});			if(tokens.size() != format.size()){				//throw PotreeException("Not enough tokens for the given format");				if(linesSkipped == 0){					cout << "some lines may be skipped because they do not match the given format: '" << format << "'" << endl;				}				linesSkipped++;				continue;			}			int i = 0;			for(const auto &f : format) {				string token = tokens[i++];				if(f == 'x'){					x = stod(token);				}else if(f == 'y'){					y = stod(token);				}else if(f == 'z'){					z = stod(token);				}else if(f == 'r'){					r = (unsigned char)(255.0f * (stof(token) - colorOffset) / colorScale); 				}else if(f == 'g'){					g = (unsigned char)(255.0f * (stof(token) - colorOffset) / colorScale); 				}else if(f == 'b'){					b = (unsigned char)(255.0f * (stof(token) - colorOffset) / colorScale); 				}else if(f == 'i'){					intensity = (unsigned short)( 65535 * (stof(token) - intensityOffset) / intensityScale);				}else if(f == 's'){					// skip				}else if(f == 'X'){					nx = stof(token);				}else if(f == 'Y'){					ny = stof(token);				}else if(f == 'Z'){					nz = stof(token);				}			}			point = Point(x,y,z,r,g,b);			point.normal.x = nx;			point.normal.y = ny;			point.normal.z = nz;			point.intensity = intensity;			pointsRead++;			return true;		}		return false;	}
开发者ID:davijo,项目名称:PotreeConverter,代码行数:67,


示例19: x

void MPSReader::readBOUNDS(){  /*				type            meaning                  ---------------------------------------------------                  LO    lower bound        b <= x (< +inf)                  UP    upper bound        (0 <=) x <= b                  FX    fixed variable     x = b                  FR    free variable      -inf < x < +inf                  MI    lower bound -inf   -inf < x (<= 0)                  PL    upper bound +inf   (0 <=) x < +inf                  BV    binary variable    x = 0 or 1                  LI    integer variable   b <= x (< +inf)                  UI    integer variable   (0 <=) x <= b                  SC    semi-cont variable x = 0 or l <= x <= b                  l is the lower bound on the variable                  If none set then defaults to 1*/  //Como se trata de um bloco opcional dos problemas,  //Apenas tratarei os tipos LO e UP.  StringTokenizer *lineTokens = new StringTokenizer(line);  string boundType;  string boundName;  string nomeVariavel;  string boundValue;  string auxRestName; //sera criada uma nova restricao se a fronteira for valida  Desigualdade tipoDesigualdade;  if (lineTokens->nextToken().compare("BOUNDS") == 0){    line = fileReader->readLine();    while (line.compare("ENDATA") != 0){      lineTokens->setLine(line);      //Ler no minimo 3 tokens      //Nome variavel / Nome Funcao|Restricao / Valor variavel      boundType = lineTokens->nextToken();      boundName = lineTokens->nextToken();      nomeVariavel = lineTokens->nextToken();      boundValue = lineTokens->nextToken();      if (boundType.compare("LO") == 0){        tipoDesigualdade = MaiorOuIgual;      }      else if (boundType.compare("UP") == 0){        tipoDesigualdade = MenorOuIgual;      }      auxRestName = funcao->addRestricao();      //Configurar nova restricao      funcao->addVariavelRestricao(auxRestName, nomeVariavel, 1.0);      funcao->setDesigualdadeRestricao(auxRestName, tipoDesigualdade);      funcao->setTermoLivreRestricao(auxRestName, stof(boundValue.c_str()));      line = fileReader->readLine(); //ler nova linha ao final    }  }}
开发者ID:vinishiru,项目名称:cuda-simplex,代码行数:62,


示例20: hts_open

void cis_data::readPhenotypes(string fbed) {	int n_includedS = 0;	int n_includedP = 0;	int n_excludedP = 0;	int n_negativeStrd = 0;	vector < int > mappingS;	//Open BED file	vrb.title("Reading phenotype data in [" + fbed + "]");	htsFile *fp = hts_open(fbed.c_str(),"r");	if (!fp) vrb.error("Cannot open file");	tbx_t *tbx = tbx_index_load(fbed.c_str());	if (!tbx) vrb.error("Cannot open index file");	kstring_t str = {0,0,0};	if (hts_getline(fp, KS_SEP_LINE, &str) <= 0 || !str.l || str.s[0] != tbx->conf.meta_char ) vrb.error("Cannot read header line!");	//Process sample names	vector < string > tokens;	stb.split(string(str.s), tokens);	if (tokens.size() < 7) vrb.error("Incorrect number of columns!");	for (int t = 6 ; t < tokens.size() ; t ++) {		mappingS.push_back(findSample(tokens[t]));		if (mappingS.back() >= 0) n_includedS++;	}	//Read phenotypes    unsigned int linecount =0;        //Read phenotypes    if (regionPhenotype.chr != "NA"){        hts_itr_t *itr = tbx_itr_querys(tbx, regionPhenotype.get().c_str());        vrb.bullet("target region [" + regionPhenotype.get() + "]");        if (!itr) vrb.error("Cannot jump to region!");        //Read data        while (tbx_itr_next(fp, tbx, itr, &str) >= 0) {            linecount ++;            if (linecount % 100000 == 0) vrb.bullet("Read " + stb.str(linecount) + " lines");            stb.split(string(str.s), tokens);            if (tokens.size() < 7) vrb.error("Incorrect number of columns!");            if ((grp_mode == GRP_NONE && filter_phenotype.check(tokens[3])) || (grp_mode != GRP_NONE && filter_phenotype.check(tokens[4]))) {                phenotype_id.push_back(tokens[3]);                phenotype_chr.push_back(tokens[0]);                phenotype_start.push_back(atoi(tokens[1].c_str()) + 1);                phenotype_end.push_back(atoi(tokens[2].c_str()));				if (grp_mode > 0 && full_test) phenotype_grp.push_back("ALL_GENES");				if (grp_mode > 0 && !full_test) phenotype_grp.push_back(tokens[4]);                phenotype_neg.push_back(tokens[5] == "-");                if (phenotype_neg.back()) n_negativeStrd ++;                phenotype_val.push_back(vector < float > (sample_count, 0.0));                for (int t = 6 ; t < tokens.size() ; t ++) {                    if (mappingS[t-6] >= 0) {                        if (tokens[t] == "NA") phenotype_val.back()[mappingS[t-6]] = bcf_float_missing;                        else phenotype_val.back()[mappingS[t-6]] = stof(tokens[t]);                    }                }                n_includedP++;            } else n_excludedP ++;        }        tbx_itr_destroy(itr);    }else{        while (hts_getline(fp, KS_SEP_LINE, &str) >= 0) {            linecount ++;            if (linecount % 100000 == 0) vrb.bullet("Read " + stb.str(linecount) + " lines");            stb.split(string(str.s), tokens);            if (str.l && str.s[0] != tbx->conf.meta_char) {                if (tokens.size() < 7) vrb.error("Incorrect number of columns!");                if ((grp_mode == GRP_NONE && filter_phenotype.check(tokens[3])) || (grp_mode != GRP_NONE && filter_phenotype.check(tokens[4]))) {                    phenotype_id.push_back(tokens[3]);                    phenotype_chr.push_back(tokens[0]);                    phenotype_start.push_back(atoi(tokens[1].c_str()) + 1);                    phenotype_end.push_back(atoi(tokens[2].c_str()));    				if (grp_mode > 0 && full_test) phenotype_grp.push_back("ALL_GENES");    				if (grp_mode > 0 && !full_test) phenotype_grp.push_back(tokens[4]);                    phenotype_neg.push_back(tokens[5] == "-");                    if (phenotype_neg.back()) n_negativeStrd ++;                    phenotype_val.push_back(vector < float > (sample_count, 0.0));                    for (int t = 6 ; t < tokens.size() ; t ++) {                        if (mappingS[t-6] >= 0) {                            if (tokens[t] == "NA") phenotype_val.back()[mappingS[t-6]] = bcf_float_missing;                            else phenotype_val.back()[mappingS[t-6]] = stof(tokens[t]);                        }                    }                    n_includedP++;                } else n_excludedP ++;            }        }    }	//Finalize & verbose	tbx_destroy(tbx);	if (hts_close(fp)) vrb.error("Cannot properly close file");	phenotype_count = phenotype_id.size();	vrb.bullet(stb.str(n_includedP) + " phenotypes included");	if (n_excludedP > 0) vrb.bullet(stb.str(n_excludedP) + " phenotypes excluded by user");	if (n_negativeStrd > 0 ) vrb.bullet(stb.str(n_negativeStrd) + " phenotypes are on the negative strand");    if (phenotype_count == 0) vrb.leave("Cannot find phenotypes in target region!");}
开发者ID:qtltools,项目名称:qtltools,代码行数:97,


示例21: faceCascade

InputProcessing::InputProcessing(int inputType, bool DEBUG_MODE) :    faceCascade(CascadeClassifier()),    inputType(inputType),    DEBUG_MODE(DEBUG_MODE),    eyeCascadeGlasses(CascadeClassifier()),    eyeCascade(CascadeClassifier()){    printf("loading /n");    if (!faceCascade.load("cascades//haarcascade_frontalface_alt.xml")) {        printf("--(!)File not found faceCascade/n");        exit(-11);    }    if (!eyeCascadeGlasses.load("cascades//haarcascade_eye_tree_eyeglasses.xml")) {        printf("--(!)File not found eyeCascadeGlasses/n");        exit(-12);    }    if (!eyeCascade.load("cascades//haarcascade_eye.xml")) {        printf("--(!)File not found eyeCascade/n");        exit(-13);    }    if (inputType < 1 || inputType > 4) {        printf("--(!)Input type %i not specified/n", inputType);        exit(-15);    }    else if (inputType == INPUT_TYPE_CAMERA_INPUT) {        // set default camera        cap = VideoCapture(0);        if (!cap.isOpened()) {            printf("--(!)Camera 0 not available/n");        }    }    else if (inputType == INPUT_TYPE_GI4E_DB) {        /*        load ground truth        Format for GI4E image_labels.txt:        xxx_yy.png	x1 y1 x2 y2 x3 y3 x4 y4 x5 y5 x6 y6        The first point (x1,y1) is the external corner of the left user's eye. The second point is the centre of the left iris.        The third one is the internal corner of the left eye. The other three points are internal corner, iris centre and        external corner of the right eye.        */        ifstream file("../GI4E/labels/image_labels.txt");        string line;        if (file.is_open()) {            while (getline(file, line)) {                try {                    istringstream iss(line);                    string filename, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;                    getline(iss, filename, '/t');                    getline(iss, x1, '/t');                    getline(iss, y1, '/t');                    getline(iss, x2, '/t');                    getline(iss, y2, '/t');                    getline(iss, x3, '/t');                    getline(iss, y3, '/t');                    getline(iss, x4, '/t');                    getline(iss, y4, '/t');                    getline(iss, x5, '/t');                    getline(iss, y5, '/t');                    getline(iss, x6, '/t');                    getline(iss, y6, '/t');                    vector<Point2f> v;                    v.push_back(Point2f(stof(x1), stof(y1)));                    v.push_back(Point2f(stof(x2), stof(y2)));                    v.push_back(Point2f(stof(x3), stof(y3)));                    v.push_back(Point2f(stof(x4), stof(y4)));                    v.push_back(Point2f(stof(x5), stof(y5)));                    v.push_back(Point2f(stof(x6), stof(y6)));                    v.shrink_to_fit();                    labels.push_back(v);                }                catch (Exception e) {                    printf("--(!)Error while parsing /GI4E/labels/image_labels.txt/n");                }            }            labels.shrink_to_fit();            file.close();        }    }}
开发者ID:zteffi,项目名称:Webcamera-Eye-Tracker,代码行数:86,


示例22: readObject

bool Save::readObject(Object* mObject, string& property, string& value){	if (!property.compare("posX"))	{		mObject->setPosX(stof(value));		return true;	}	if (!property.compare("posY"))	{		mObject->setPosY(stof(value));		return true;	}	if (!property.compare("scaleX"))	{		mObject->setScaleX(stof(value));		return true;	}	if (!property.compare("scaleY"))	{		mObject->setScaleY(stof(value));		return true;	}	if (!property.compare("speedX"))	{		mObject->setSpeedX(stof(value));		return true;	}	if (!property.compare("speedY"))	{		mObject->setSpeedY(stof(value));		return true;	}	if (!property.compare("angularSpeed"))	{		mObject->setAngularSpeed(stof(value));		return true;	}	if (!property.compare("angularAcceleration"))	{		mObject->setAngularAcceleration(stof(value));		return true;	}	if (!property.compare("maxAngularSpeed"))	{		mObject->setMaxAngularSpeed(stof(value));		return true;	}	if (!property.compare("angleZ"))	{		mObject->setAngleZ(stof(value));		return true;	}	if (!property.compare("pathSurface"))	{		mObject->setPathSurface(value.c_str());		getMI()->_entity2dManager->add(mObject->getEntity2d());		mObject->getEntity2d()->setHotSpot(0.5f, 0.5f);		return true;	}	// if none of the IFs executes, the property is not one of an object therefore return false	return false;}
开发者ID:uzunov-dimitar,项目名称:TeamRocketGame,代码行数:62,


示例23: hts_open

void union_data::readGenotypesBED(string fbed,string region) {	string buffer;	int n_includedG = 0;	int n_excludedG_user = 0;	int n_includedS = 0;	int n_excludedS = 0;	int n_missingS = 0;	vector < int > mappingS;	genotype_id.clear();	genotype_chr.clear();	genotype_start.clear();	genotype_end.clear();	genotype_val.clear();	genotype_count=0;	genotype_id_to_idx.clear();	//Opening files	htsFile *fp = hts_open(fbed.c_str(),"r");	if (!fp) vrb.error("Cannot open file!");	tbx_t * tbx = tbx_index_load(fbed.c_str());	if (!tbx) vrb.error("Cannot load index file!");	kstring_t str = {0,0,0};	if (hts_getline(fp, KS_SEP_LINE, &str) <= 0 || !str.l || str.s[0] != tbx->conf.meta_char ) vrb.error("Cannot read header line!");	//Process sample names	vector < string > tokens;	stb.split(string(str.s), tokens);	if (tokens.size() < 7) vrb.error("Incorrect number of columns!");	for (int i0 = 6 ; i0 < tokens.size() ; i0 ++) {		string sid = tokens[i0];		if (filter_sample.check(sid)) {			mappingS.push_back(findSample(sid));			if (mappingS.back() >= 0) n_includedS ++;			else n_missingS ++;		} else {			mappingS.push_back(-1);			n_excludedS ++;		}	}	//vrb.bullet(stb.str(n_includedS) + " samples included");	//if (n_excludedS > 0) vrb.bullet(stb.str(n_excludedS) + " samples excluded by user");	//if (n_missingS > 0) vrb.bullet(stb.str(n_missingS) + " samples without phenotype data");	//if (n_includedS != sample_count) vrb.error("Cannot find genotype for " + stb.str(sample_count - n_includedS) + " samples!");    unsigned int linecount = 0;	//Jump to interesting region	hts_itr_t *itr = tbx_itr_querys(tbx, region.c_str());	//vrb.bullet("target region [" + regionGenotype.get() + "]");	//if (!itr) vrb.error("Cannot jump to region!");	while (tbx_itr_next(fp, tbx, itr, &str) >= 0) {		linecount ++;		if (linecount % 100000 == 0) vrb.bullet("Read " + stb.str(linecount) + " lines");		stb.split(string(str.s), tokens);		if (tokens.size() < 7) vrb.error("Incorrect number of columns!");		if (filter_genotype.check(tokens[3])) {			genotype_id.push_back(tokens[3]);			genotype_chr.push_back(tokens[0]);			genotype_start.push_back(atoi(tokens[1].c_str()) + 1);			genotype_end.push_back(atoi(tokens[2].c_str()));			genotype_val.push_back(vector < float > (sample_count, 0.0));			for (int t = 6 ; t < tokens.size() ; t ++) {				if (mappingS[t-6] >= 0) {					if (tokens[t] == "NA") genotype_val.back()[mappingS[t-6]] = bcf_float_missing;					else genotype_val.back()[mappingS[t-6]] = stof(tokens[t]);				}			}			pair < string, int > temp (tokens[3],n_includedG);			genotype_id_to_idx.insert(temp);			n_includedG++;		} else n_excludedG_user ++;	}	tbx_itr_destroy(itr);	//Finalize & verbose	tbx_destroy(tbx);	if (hts_close(fp)) vrb.error("Cannot properly close file!");	genotype_count = n_includedG;	//vrb.bullet(stb.str(n_includedG) + " variants included");	//if (n_excludedG_user > 0) vrb.bullet(stb.str(n_excludedG_user) + " variants excluded by user");    //if (genotype_count == 0) vrb.leave("Cannot find variants in target region!");}
开发者ID:qtltools,项目名称:qtltools,代码行数:83,


示例24: g_maplistCacheQueryNexuizMapList

float g_maplistCacheQueryNexuizMapList(entity me, float i){	return stof(substring(me.g_maplistCache, i, 1));}
开发者ID:heartofdalek,项目名称:RocketMinsta,代码行数:4,


示例25: veh

void TrafficSimulation::import_vehicles(std::string vehicles_file){	// load input file	std::ifstream infile;	infile.exceptions(std::ifstream::badbit);	try {		infile.open(vehicles_file);		// read and match lines		std::string line;		for (uint_fast32_t line_num = 1; std::getline(infile, line);			 ++line_num) {			// split by fields			std::vector<std::string> fields = nonstd::split(line, ':');			// 4 fields are required (time, name, from, to)			if (fields.size() < 4) {				std::cerr << "E: Line " << line_num << " of input file /""						  << vehicles_file						  << "/" is not valid. See documentation "							 "for correct syntax. Skipping..." << std::endl;				continue;			}#ifndef NDEBUG			std::cout << "Fields:" << std::endl;			for (auto &f : fields) {				std::cout << f << std::endl;			}			std::cout << "Matched vehicle on line " << line_num << std::endl					  << "name: " << fields[1] << std::endl					  << "from: " << fields[2] << std::endl					  << "to: " << fields[3] << std::endl					  << "starttime: " << fields[0] << std::endl;#endif			// create vehicle; parse starttime, name, from and to			try {				Vehicle veh(*this, fields[2], fields[3], stoull(fields[0]),							fields[1]);				// parse optional properties				for (int i = 4; i < fields.size(); ++i) {					// split property field by =					std::vector<std::string> property =						nonstd::split(fields[i], '=');					// assign property					switch (nonstd::hash(property[0].c_str())) {					case nonstd::hash("traffic_increase_caused"):						veh.traffic_increase_caused = stof(property[1]);						break;					case nonstd::hash("max_speed"):						veh.max_speed = stoul(property[1]);						break;					}				}				// add vehicle to simulation				vehicles.push_back(veh);				std::cout << "I: Vehicle " << veh.name						  << " loaded for simulation" << std::endl;			}			// vehicle construction errors			catch (const std::runtime_error &e) {				std::cerr << "E: " << vehicles_file << ":" << line_num						  << " Vehicle on line " << line_num						  << "could'n be loaded for simulation. " << e.what()						  << std::endl;			}		}	}	// input file errors	catch (const std::ifstream::failure &e) {		std::cerr << "E: Couldn't read file '" << vehicles_file << " "				  << e.what() << std::endl;	}}
开发者ID:hrnr,项目名称:TrafficSim,代码行数:80,



注:本文中的stof函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ stok函数代码示例
C++ stod函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。