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

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

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

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

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

示例1: debug

/** * /brief Display Calibration data. */std::ostream&	operator<<(std::ostream& out,			const Astro::Calibration& calibration) {	debug(LOG_DEBUG, DEBUG_LOG, 0, "display calibration object");	out << "calibration:     ";	out << calibration.id << std::endl;	out << "when:            ";	out << calibration.timeago << std::endl;	out << "coefficients:    ";	out << stringprintf("[ %10.6f, %10.6f, %10.6f;",		calibration.coefficients[0],		calibration.coefficients[1],		calibration.coefficients[2]);	out << std::endl;	out << "           :     ";	out << stringprintf("  %10.6f, %10.6f, %10.6f   ]",		calibration.coefficients[3],		calibration.coefficients[4],		calibration.coefficients[5]);	out << std::endl;	out << "points:          ";	out << calibration.points.length() << std::endl;	for (unsigned int i = 0; i < calibration.points.length(); i++) {		out << "                 ";		out << calibration.points[i] << std::endl;	}	return out;}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:30,


示例2: qhyname

/** * /brief Construct a camera from a camera description * * /param name		Name of the camera * /return 		Camera with that name */CameraPtr	QhyCameraLocator::getCamera0(const DeviceName& name) {	QhyName	qhyname(name);	if (!qhyname.isCamera(name)) {		std::string	msg = stringprintf("%s is not a Camera name",			name.toString().c_str());		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}	// scan the devices and get 	std::vector<usb::DevicePtr>	d = context.devices();	std::vector<usb::DevicePtr>::const_iterator	i;	for (i = d.begin(); i != d.end(); i++) {		usb::DevicePtr	dptr = *i;		int	busnumber = dptr->getBusNumber();		int	deviceaddress = dptr->getDeviceAddress();		if ((busnumber == qhyname.busnumber()) &&			(deviceaddress == qhyname.deviceaddress())) {			dptr->open();			return CameraPtr(new QhyCamera(dptr));		}	}	// failure to construct the camera	std::string	msg = stringprintf("cannot create camera from '%s'",		name.toString().c_str());	throw std::runtime_error(msg);}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:34,


示例3: debug

void	InstrumentTest::testInstrumentComponentTable() {	debug(LOG_DEBUG, DEBUG_LOG, 0, "testInstrumentComponentTable() begin");	Database	database = DatabaseFactory::get(dbfilename);	discover::InstrumentComponentTable	table(database);	std::string	query("delete from instrumentcomponents;");	database->query(query);	std::string	names[2] = { "INSTRUMENT", "TELESCOPE" };	for (int j = 0; j < 2; j++) {		for (int i = 0; i < 5; i++) {			discover::InstrumentComponentKey	key(names[j],				discover::InstrumentComponentKey::CCD, i);			discover::InstrumentComponent	component(key, "blubber",				stringprintf("ccd:sx/1-2-3/%d", i));			discover::InstrumentComponentRecord	record(component);			table.add(record);		}		for (int i = 0; i < 5; i++) {			discover::InstrumentComponentKey	key(names[j],				discover::InstrumentComponentKey::Cooler, i);			discover::InstrumentComponent	component(key, "blubber",				stringprintf("cooler:sx/1-2-3/%d", i));			discover::InstrumentComponentRecord	record(component);			table.add(record);		}	}	debug(LOG_DEBUG, DEBUG_LOG, 0, "testInstrumentComponentTable() end");}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:32,


示例4: log

/// move die over boardvoid Game::makeMove(Move move, bool storeMove) {  //TODO: check correctness! (Game::makeMove)  KBX::Logger log("DieState");  //// perform move  DieState& dieState = this->_dice[move.dieIndex];  log.info(stringprintf("initial state: %d", dieState.getCurrentState()));  // delete die from current position on board  this->_fields[dieState.x()][dieState.y()] = CLEAR;  // get directions for horizontal movement (aka x coordinate)  int directionX, directionY;  if (move.rel.dx < 0) {    directionX = WEST;  } else {    directionX = EAST;  }  // get directions for vertical movement (aka y coordinate)  if (move.rel.dy < 0) {    directionY = SOUTH;  } else {    directionY = NORTH;  }  // assume move to go first in y direction  int stepsFirst = abs(move.rel.dy);  int directionFirst = directionY;  int stepsSec = abs(move.rel.dx);  int directionSec = directionX;  // swap values if move goes in x direction first  if (move.rel.firstX) {    swap(stepsFirst, stepsSec);    swap(directionFirst, directionSec);  }  // traverse through dice states  for (size_t i = stepsFirst; i > 0; i--) {    // rotate in first direction    dieState.moveOneStep(directionFirst);    log.info(stringprintf("new state: %d", dieState.getCurrentState()));  }  for (size_t i = stepsSec; i > 0; i--) {    // rotate in second direction    dieState.moveOneStep(directionSec);    log.info(stringprintf("new state: %d", dieState.getCurrentState()));  }  // delete old die on this position before moving new die to it  int keyOldDie = this->_fields[dieState.x()][dieState.y()];  if (keyOldDie != CLEAR) {    this->_dice[keyOldDie].kill();  }  // if the move should be stored, do so  if(storeMove){    this->_moveStackPending.clear();    this->_deathStackPending.clear();    this->_moveStack.push_front(move);    this->_deathStack.push_front(keyOldDie);  }  // move die to new position  this->_fields[dieState.x()][dieState.y()] = move.dieIndex;  this->_nextPlayer = inverse(this->_nextPlayer);}
开发者ID:lettis,项目名称:Kubix,代码行数:59,


示例5: stringprintf

void	CelestronMount::Goto(const RaDec& radec) {	std::string	cmd;	if (version > 106) {		cmd = stringprintf("r%08X,%08X",			angle32(radec.ra()), angle32(radec.dec()));	} else {		cmd = stringprintf("R%04X,%04X",			angle16(radec.ra()), angle16(radec.dec()));	}	debug(LOG_DEBUG, DEBUG_LOG, 0, "command sent: %s", cmd.c_str());	write(cmd);	getprompt();}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:13,


示例6: debug

//////////////////////////////////////////////////////////////////////// ProjectTable implementation//////////////////////////////////////////////////////////////////////ProjectRecord	ProjectTable::get(const std::string& name) {	debug(LOG_DEBUG, DEBUG_LOG, 0, "retrieve project '%s'", name.c_str());	std::string	condition = stringprintf("name = '%s'",		database()->escape(name).c_str());	std::list<ProjectRecord>	l = select(condition);	if (0 == l.size()) {		std::string	msg = stringprintf("no project '%s'",			name.c_str());		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}	return *(l.begin());}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:16,


示例7: stringprintf

/** * /brief Get the filter name */std::string	FilterWheel::filterName(size_t index) {	if (index >= nFilters()) {		std::string	msg = stringprintf("%u is too large", index);		throw std::runtime_error(msg);	}	// get the properties	Properties	properties(name().toString());	try {		return properties.getProperty(stringprintf("filter%u", index));	} catch (...) {		return stringprintf("%u", index);	}}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:16,


示例8: debug

/** * /brief Retrieve a list of image types  * * /param index		index of the camera  */std::vector<std::string>	AsiCameraLocator::imgtypes(int index) {	debug(LOG_DEBUG, DEBUG_LOG, 0, "retrieving image types for %d", index);	// make sure the index is valid	if (index >= ASIGetNumOfConnectedCameras()) {		std::string	msg = stringprintf("");		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}	std::vector<std::string>	result;	int	rc;	if (!isopen(index)) {		int	rc = ASIOpenCamera(index);		debug(LOG_DEBUG, DEBUG_LOG, 0, "open camera %d: %d", index, rc);		if (ASI_SUCCESS != rc) {			std::string	msg = stringprintf("%d cannot open: %s",				index, AsiCamera::error(rc).c_str());			debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());			throw std::runtime_error(msg);		}	}	ASI_CAMERA_INFO	camerainfo;	if (ASI_SUCCESS != (rc = ASIGetCameraProperty(&camerainfo, index))) {		std::string	msg = stringprintf("%d cannot get props: %s",			index, AsiCamera::error(rc).c_str());		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}	debug(LOG_DEBUG, DEBUG_LOG, 0, "got camera info for %d", index);        int     imgtypeidx = 0;        while (camerainfo.SupportedVideoFormat[imgtypeidx] != -1) {                std::string     it = AsiCcd::imgtype2string(                        camerainfo.SupportedVideoFormat[imgtypeidx]);		result.push_back(it);		imgtypeidx++;	}	if (!isopen(index)) {		rc = ASICloseCamera(index);		debug(LOG_DEBUG, DEBUG_LOG, 0, "close camera %d: %d",			index, rc);		if (ASI_SUCCESS != rc) {			std::string	msg = stringprintf("%d cannot close: %s",				index, AsiCamera::error(rc).c_str());			debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());			throw std::runtime_error(msg);		}	}	return result;}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:53,


示例9: _filename

/** * /brief Construct a Mapped file */MappedFile::MappedFile(const std::string& filename, size_t recordlength)	: _filename(filename), _recordlength(recordlength) {	debug(LOG_DEBUG, DEBUG_LOG, 0, "mapping file '%s'", filename.c_str());	// stat the file	struct stat	sb;	if (stat(filename.c_str(), &sb) < 0) {		std::string	msg = stringprintf("cannot stat '%s': %s",			filename.c_str(), strerror(errno));		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}	data_len = sb.st_size;	if (0 != (data_len % _recordlength)) {		debug(LOG_DEBUG, DEBUG_LOG, 0, "record length %u does not "			"divide file size %u", recordlength, data_len);		throw std::runtime_error("record length does not devide "			"file size");	}	_nrecords = data_len / _recordlength;	debug(LOG_DEBUG, DEBUG_LOG, 0, "file contains %u records", _nrecords);	// open the file	debug(LOG_DEBUG, DEBUG_LOG, 0, "open file '%s'", filename.c_str());	int	fd = open(filename.c_str(), O_RDONLY);	if (fd < 0) {		std::string	msg = stringprintf("cannot open '%s': %s",			filename.c_str(), strerror(errno));		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}        // map the file into the address space	debug(LOG_DEBUG, DEBUG_LOG, 0, "mapping '%s', length %u",		filename.c_str(), data_len);	data_ptr = (char *)mmap(NULL, sb.st_size, PROT_READ,		MAP_FILE | MAP_PRIVATE, fd, 0);	if ((void *)(-1) == data_ptr) {		close(fd);		std::string     msg = stringprintf("cannot map '%s': %s",			filename.c_str(), strerror(errno));		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}        // we can now close the file descriptor        close(fd);	debug(LOG_DEBUG, DEBUG_LOG, 0, "file '%s' mapped", filename.c_str());}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:51,


示例10: writeimage

void	writeimage(ImagePtr image) {	std::string	filename = stringprintf("sim%03d.fits", counter);	unlink(filename.c_str());	FITSout	out(filename);	out.write(image);	counter++;}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:7,


示例11: setMosaicType

/** * /brief Set mosaic type from name * * This method ensures that only valid mosaic type names are used and * that the mosaic_type member variable is consistently set. * /param mosaic_name	string representation of color mosaic */void	ImageBase::setMosaicType(const std::string& mosaic_name) {	if (mosaic_name == "NONE") {		setMosaicType(MosaicType::NONE);		return;	}	if (mosaic_name == "RGGB") {		setMosaicType(MosaicType::BAYER_RGGB);		return;	}	if (mosaic_name == "GRBG") {		setMosaicType(MosaicType::BAYER_GRBG);		return;	}	if (mosaic_name == "GBRG") {		setMosaicType(MosaicType::BAYER_GBRG);		return;	}	if (mosaic_name == "BGGR") {		setMosaicType(MosaicType::BAYER_BGGR);		return;	}	std::string	msg = stringprintf("unknown mosaic name: %s",		mosaic_name.c_str());	debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());	throw std::runtime_error(msg);}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:33,


示例12: addname

/** * /brief Get a list of Starlight Express cameras. * * /param device	the type of devices we want to have listed * /return 		a vector of strings that uniquely descript devices */std::vector<std::string>	QhyCameraLocator::getDevicelist(DeviceName::device_type device) {	std::vector<std::string>	names;	// list all devices from the context	std::vector<usb::DevicePtr>	d = context.devices();	std::vector<usb::DevicePtr>::const_iterator	i;	for (i = d.begin(); i != d.end(); i++) {		usb::DevicePtr	devptr = *i;		// try to open all devices, and check whether they have		// the right vendor id		try {			devptr->open();			try {				addname(names, devptr, device);			} catch (std::runtime_error& x) {				debug(LOG_DEBUG, DEBUG_LOG, 0, "found a non "					"QHY device: %s", x.what());			}		} catch (std::exception& x) {			std::string	msg = stringprintf("cannot work with "				"device at bus=%d and addr=%d",				devptr->getBusNumber(),				devptr->getDeviceAddress());			debug(LOG_ERR, DEBUG_LOG, 0, msg.c_str());		}	}	// return the list of devices	return names;}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:36,


示例13: baseimage

Analyzer::Analyzer(const ConstImageAdapter<double>& _baseimage,	int _spacing, int _patchsize)	: baseimage(_baseimage), spacing(_spacing), patchsize(_patchsize)  {	if (_spacing < 0) {		std::string	msg = stringprintf("invalid spacing %d",			_spacing);		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::range_error(msg);	}	if (_patchsize < 0) {		std::string	msg = stringprintf("invalid patchsize %d",			_patchsize);		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::range_error(msg);	}}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:16,


示例14: debug

/** * /brief Save an image in the directory, return the short name */std::string	ImageDirectory::save(astro::image::ImagePtr image) {	debug(LOG_DEBUG, DEBUG_LOG, 0, "saving an image");	// create a temporary file name in the base directory	char	buffer[1024];	snprintf(buffer, sizeof(buffer), "%s/XXXXXXXX.fits", basedir().c_str());	int	fd = mkstemps(buffer, 5);	if (fd < 0) {		std::string	cause = stringprintf("cannot create a tmp "			"image file: %s", strerror(errno));		debug(LOG_ERR, DEBUG_LOG, 0, "%s", cause.c_str());		throw std::runtime_error(cause);	}	unlink(buffer);	close(fd);	std::string	fullname(buffer);	// construct the filename	std::string	filename = basename(fullname);	debug(LOG_DEBUG, DEBUG_LOG, 0, "image full name: %s, filename: %s",		fullname.c_str(), filename.c_str());	// write the file	ImageDirectory::write(image, filename);	// return the filename	debug(LOG_DEBUG, DEBUG_LOG, 0, "image short name: %s",		filename.c_str());	return filename;}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:32,


示例15: flat_correct

void	flat_correct(Image<ImagePixelType>& image,		const Image<FlatPixelType>& flat) {	ImagePixelType	max = std::numeric_limits<ImagePixelType>::max();	// first check that image sizes match	if (image.size() != flat.size()) {		std::string	msg = stringprintf("size: image %s != flat %s",			image.size().toString().c_str(),			flat.size().toString().c_str());		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());		throw std::runtime_error(msg);	}	// correct all pixels	for (size_t offset = 0; offset < image.size().getPixels(); offset++) {		ImagePixelType	ip = image.pixels[offset];		// skip NaN pixels		if (ip != ip) {			continue;		}		FlatPixelType	dp = flat.pixels[offset];		// turn off (make nan) pixels that are marked nan in the flat		if (dp != dp) {			ip = 0;		} else {			FlatPixelType	v = ip / dp;			if (v > max) {				ip = max;			} else {				ip = v;			}		}		image.pixels[offset] = ip;	}}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:35,


示例16: stringprintf

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