本文整理汇总了C++中fmt类的典型用法代码示例。如果您正苦于以下问题:C++ fmt类的具体用法?C++ fmt怎么用?C++ fmt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fmt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Print
void FGaussShell::Print( std::ostream &out ) const
{
using fmt::ff;
using fmt::fi;
using fmt::fe;
out << "vCenter: (" << ff(vCenter[0],6,4) << " " << ff(vCenter[1],7,4) << " " << ff(vCenter[2],6,4) << ") "
<< "iCenter: " << fi(iCenter,3) << "\n"
<< *pFn;
}
示例2: fi
void FGaussShell::PrintAligned( std::ostream &xout, uint Indent ) const
{
using namespace fmt;
std::streampos
p0 = xout.tellp(),
p1;
// xout << fi(iCenter, 3) << " "
xout << fi(pFn->Contractions.size(), 3) << ":"
<< "spdfghiklm"[AngularMomentum()]
<< " "
<< ff(vCenter[0],8,4) << " " << ff(vCenter[1],8,4) << " " << ff(vCenter[2],8,4)
<< " ";
p1 = xout.tellp();
for ( uint iExp = 0; iExp < pFn->Exponents.size(); ++ iExp ){
if ( iExp != 0 ){
xout << "\n";
for ( uint i = 0; i < Indent + p1 - p0; ++ i )
xout << " ";
}
xout << fmt::ff(pFn->Exponents[iExp],16,7) << " ";
double
fRenorm = 1.0/GaussNormalizationSpher( pFn->Exponents[iExp], pFn->AngularMomentum );
// fRenorm = 1.;
std::stringstream
str;
for ( uint iCo = 0; iCo < pFn->Contractions.size(); ++ iCo ){
aic::FGaussBfn::FContraction const
&Co = pFn->Contractions[iCo];
uint
w = 9, p = 5;
if ( Co.nBegin <= iExp && iExp < Co.nEnd ) {
str << " " << fmt::ff(Co.Coeffs[iExp - Co.nBegin]*fRenorm, w, p);
} else {
str << " " << fmt::fc(" - - - -", w);
}
}
std::string
s = str.str();
while( !s.empty() && (s[s.size()-1] == ' ' || s[s.size()-1] == '-' ) )
s.resize(s.size() - 1);
xout << s;
}
}
示例3: forEachSimulator
void SimulationBar::forEachSimulator(std::function<void(SimulatorItem* simulator)> callback, bool doSelect)
{
MessageView* mv = MessageView::instance();
/*
ItemList<SimulatorItem> simulators =
ItemTreeView::mainInstance()->selectedItems<SimulatorItem>();
*/
ItemList<SimulatorItem> simulators =
ItemTreeView::mainInstance()->selectedItems<SimulatorItem>();
if(simulators.empty()){
simulators.extractChildItems(RootItem::instance());
if(simulators.empty()){
mv->notify(_("There is no simulator item."));
} else if(simulators.size() > 1){
simulators.clear();
mv->notify(_("Please select a simulator item to simulate."));
} else {
if(doSelect){
ItemTreeView::instance()->selectItem(simulators.front());
}
}
}
typedef map<WorldItem*, SimulatorItem*> WorldToSimulatorMap;
WorldToSimulatorMap worldToSimulator;
for(size_t i=0; i < simulators.size(); ++i){
SimulatorItem* simulator = simulators.get(i);
WorldItem* world = simulator->findOwnerItem<WorldItem>();
if(world){
WorldToSimulatorMap::iterator p = worldToSimulator.find(world);
if(p == worldToSimulator.end()){
worldToSimulator[world] = simulator;
} else {
p->second = 0; // skip if multiple simulators are selected
}
}
}
for(size_t i=0; i < simulators.size(); ++i){
SimulatorItem* simulator = simulators.get(i);
WorldItem* world = simulator->findOwnerItem<WorldItem>();
if(!world){
mv->notify(format(_("{} cannot be processed because it is not related with a world."),
simulator->name()));
} else {
WorldToSimulatorMap::iterator p = worldToSimulator.find(world);
if(p != worldToSimulator.end()){
if(!p->second){
mv->notify(format(_("{} cannot be processed because another simulator"
"in the same world is also selected."),
simulator->name()));
} else {
callback(simulator);
}
}
}
}
}
示例4: putJointPositionFault
void KinematicFaultCheckerImpl::putJointPositionFault(int frame, Link* joint, std::ostream& os)
{
if(frame > lastPosFaultFrames[joint->jointId()] + 1){
double q, l, u, m;
if(joint->isRotationalJoint()){
q = degree(joint->q());
l = degree(joint->q_lower());
u = degree(joint->q_upper());
m = degree(angleMargin);
} else {
q = joint->q();
l = joint->q_lower();
u = joint->q_upper();
m = translationMargin;
}
if(m != 0.0){
os << format(_("{0:7.3f} [s]: Position limit over of {1} ({2} is beyond the range ({3} , {4}) with margin {5}.)"),
(frame / frameRate), joint->name(), q, l, u, m) << endl;
} else {
os << format(_("{0:7.3f} [s]: Position limit over of {1} ({2} is beyond the range ({3} , {4}).)"),
(frame / frameRate), joint->name(), q, l, u) << endl;
}
numFaults++;
}
lastPosFaultFrames[joint->jointId()] = frame;
}
示例5: checkOrUpdateNamingContext
bool NamingContextHelper::checkOrUpdateNamingContext()
{
if(failedInLastAccessToNamingContext){
return false;
}
if (!CORBA::is_nil(namingContext)) {
return true;
}
try {
omniORB::setClientCallTimeout(500);
CORBA::Object_var obj = getORB()->string_to_object(namingContextLocation.c_str());
namingContext = CosNaming::NamingContext::_narrow(obj);
omniORB::setClientCallTimeout(namingContext, 150);
if (CORBA::is_nil(namingContext)) {
errorMessage_ = format("The object at {} is not a NamingContext object.", namingContextLocation);
failedInLastAccessToNamingContext = true;
}
} catch (CORBA::SystemException& ex) {
errorMessage_ = format("A NameService doesn't exist at \"{}\".", namingContextLocation);
namingContext = CosNaming::NamingContext::_nil();
failedInLastAccessToNamingContext = true;
}
omniORB::setClientCallTimeout(0); // reset the global timeout setting?
return (!CORBA::is_nil(namingContext));
}
示例6: load
SgNode* YAMLSceneLoaderImpl::load(const std::string& filename)
{
SgNodePtr scene;
MappingPtr topNode;
try {
YAMLReader reader;
topNode = reader.loadDocument(filename)->toMapping();
if(topNode){
boost::filesystem::path filepath(filename);
sceneReader.setBaseDirectory(filepath.parent_path().string());
sceneReader.readHeader(*topNode);
ValueNodePtr sceneElements = topNode->findMapping("scene");
if(!sceneElements->isValid()){
os() << format(_("Scene file \"{}\" does not have the \"scene\" node."), filename) << endl;
} else {
scene = sceneReader.readNodeList(*sceneElements);
if(!scene){
os() << format(_("Scene file \"{}\" is an empty scene."), filename) << endl;
scene = new SgNode;
}
}
}
} catch(const ValueNode::Exception& ex){
os() << ex.message();
}
os().flush();
sceneReader.clear();
return scene.retn();
}
示例7: apply
void KinematicFaultCheckerImpl::apply()
{
ItemList<BodyMotionItem> items = ItemTreeView::mainInstance()->selectedItems<BodyMotionItem>();
if(items.empty()){
mes.notify(_("No BodyMotionItems are selected."));
} else {
for(size_t i=0; i < items.size(); ++i){
BodyMotionItem* motionItem = items.get(i);
BodyItem* bodyItem = motionItem->findOwnerItem<BodyItem>();
if(!bodyItem){
mes.notify(format(_("{} is not owned by any BodyItem. Check skiped."), motionItem->name()));
} else {
mes.putln();
mes.notify(format(_("Applying the Kinematic Fault Checker to {} ..."),
motionItem->headItem()->name()));
dynamic_bitset<> linkSelection;
if(selectedJointsRadio.isChecked()){
linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem);
} else if(nonSelectedJointsRadio.isChecked()){
linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem);
linkSelection.flip();
} else {
linkSelection.resize(bodyItem->body()->numLinks(), true);
}
double beginningTime = 0.0;
double endingTime = motionItem->motion()->getTimeLength();
std::numeric_limits<double>::max();
if(onlyTimeBarRangeCheck.isChecked()){
TimeBar* timeBar = TimeBar::instance();
beginningTime = timeBar->minTime();
endingTime = timeBar->maxTime();
}
int n = checkFaults(bodyItem, motionItem, mes.cout(),
positionCheck.isChecked(),
velocityCheck.isChecked(),
collisionCheck.isChecked(),
linkSelection,
beginningTime, endingTime);
if(n > 0){
if(n == 1){
mes.notify(_("A fault has been detected."));
} else {
mes.notify(format(_("{} faults have been detected."), n));
}
} else {
mes.notify(_("No faults have been detected."));
}
}
}
}
}
示例8: findObjectSub
CORBA::Object_ptr NamingContextHelper::findObjectSub(std::vector<ObjectPath>& pathList)
{
CORBA::Object_ptr obj = CORBA::Object::_nil();
if(checkOrUpdateNamingContext()){
string fullName;
CosNaming::Name ncName;
ncName.length(pathList.size());
for(int index = 0; index < pathList.size(); index++){
ncName[index].id = CORBA::string_dup(pathList[index].id.c_str());
ncName[index].kind = CORBA::string_dup(pathList[index].kind.c_str());
if(0 < fullName.length()){
fullName = fullName + "/";
}
fullName = fullName + pathList[index].id;
}
try {
obj = namingContext->resolve(ncName);
} catch (const CosNaming::NamingContext::NotFound &ex) {
errorMessage_ = format("\"{}\" is not found: ", fullName);
switch (ex.why) {
case CosNaming::NamingContext::missing_node:
errorMessage_ += "Missing Node";
break;
case CosNaming::NamingContext::not_context:
errorMessage_ += "Not Context";
break;
case CosNaming::NamingContext::not_object:
errorMessage_ += "Not Object";
break;
default:
errorMessage_ += "Unknown Error";
break;
}
} catch (CosNaming::NamingContext::CannotProceed &exc) {
errorMessage_ = format("Resolving \"{}\" cannot be proceeded.", fullName);
} catch (CosNaming::NamingContext::AlreadyBound &exc) {
errorMessage_ = format("\"{}\" has already been bound.", fullName);
} catch (const CORBA::TRANSIENT &) {
errorMessage_ = format("Resolving \"{}\" failed with the TRANSIENT exception.", fullName);
}
}
return obj;
}
示例9: load
bool YAMLReaderImpl::load(const std::string& filename)
{
yaml_parser_initialize(&parser);
clearDocuments();
if(isRegularMultiListingExpected){
expectedListingSizes.clear();
}
currentDocumentIndex = 0;
bool result = false;
FILE* file = fopen(filename.c_str(), "rb");
if(file==NULL){
errorMessage = strerror(errno);
} else {
yaml_parser_set_input_file(&parser, file);
try {
result = parse();
}
catch(const ValueNode::Exception& ex){
errorMessage = format(_("{0} at line {1}, column {2}"),
ex.message(), ex.line(), ex.column());
}
fclose(file);
}
return result;
}
示例10: parameterize
/**
\todo Use integated nested map whose node is a single path element to be more efficient.
*/
std::string ParametricPathProcessor::parameterize(const std::string& orgPathString)
{
filesystem::path orgPath(orgPathString);
// In the case where the path is originally relative one
if(!orgPath.is_complete()){
return getGenericPathString(orgPath);
} else {
filesystem::path relativePath;
if(!impl->baseDirPath.empty() && findSubDirectory(impl->baseDirPath, orgPath, relativePath)){
return getGenericPathString(relativePath);
} else {
string varName;
if(impl->findSubDirectoryOfDirectoryVariable(orgPath, varName, relativePath)){
return format("${{{0}}}/{1}", varName, getGenericPathString(relativePath));
} else if(findSubDirectory(impl->shareDirPath, orgPath, relativePath)){
return string("${SHARE}/") + getGenericPathString(relativePath);
} else if(findSubDirectory(impl->topDirPath, orgPath, relativePath)){
return string("${PROGRAM_TOP}/") + getGenericPathString(relativePath);
} else if(!impl->isBaseDirInHome && findSubDirectory(impl->homeDirPath, orgPath, relativePath)){
return string("${HOME}/") + getGenericPathString(relativePath);
} else if(!impl->baseDirPath.empty() && findRelativePath(impl->baseDirPath, orgPath, relativePath)){
return getGenericPathString(relativePath);
}
}
}
return getGenericPathString(orgPath);
}
示例11: initializeCorbaUtil
void cnoid::initializeCorbaUtil(bool activatePOAManager, int listeningPort)
{
if (orb) {
return; // already initialized
}
int numArgs = (listeningPort >= 0) ? 5 : 1;
char** argv = new char*[numArgs];
int argc = 0;
argv[argc++] = (char*)"choreonoid";
string endpoint;
if (listeningPort >= 0) {
endpoint = format("giop:tcp::{}", listeningPort);
argv[argc++] = (char*)"-ORBendPoint";
argv[argc++] = (char*)endpoint.c_str();
argv[argc++] = (char*)"-ORBpoaUniquePersistentSystemIds";
argv[argc++] = (char*)"1";
}
// Initialize ORB
orb = CORBA::ORB_init(argc, argv);
delete[] argv;
initializeCorbaUtil(orb, activatePOAManager);
}
示例12: initializePlayback
void Source::initializePlayback(double time)
{
pa_threaded_mainloop_lock(manager->mainloop);
waitForOperation();
if(!isActive_ && connectStream()){
seek(time);
initialWritingDone = false;
size_t writableSize = pa_stream_writable_size(stream);
if(writableSize <= 0){
manager->os <<
format(_("PulseAudio stream for {} cannot be written."), audioItem->name()) << endl;
disconnectStream();
} else {
timeToFinish = std::numeric_limits<double>::max();
write(writableSize, true);
isActive_ = true;
pa_stream_set_write_callback(stream, pa_stream_write_callback, (void*)this);
pa_stream_set_overflow_callback(stream, pa_stream_overflow_notify_callback, (void*)this);
pa_stream_set_underflow_callback(stream, pa_stream_underflow_notify_callback, (void*)this);
}
}
pa_threaded_mainloop_unlock(manager->mainloop);
}
示例13: initialize
bool AizuWheelController::initialize(SimpleControllerIO* io)
{
body = io->body();
dt = io->timeStep();
actuationMode = Link::JOINT_TORQUE;
string option = io->optionString();
if(!option.empty()){
if(option == "velocity" || option == "position"){
actuationMode = Link::JOINT_VELOCITY;
} else if(option == "torque"){
actuationMode = Link::JOINT_TORQUE;
} else {
io->os() << format("Warning: Unknown option \"{}\".", option) << endl;
}
}
vector<string> wheelNames = { "L_WHEEL", "R_WHEEL" };
if(!initializeWheels(io, wheelNames)){
return false;
}
joystick = io->getOrCreateSharedObject<SharedJoystick>("joystick");
targetMode = joystick->addMode();
return true;
}
示例14: initialize
void LightingProgram::initialize()
{
numLightsLocation = getUniformLocation("numLights");
lightInfos.resize(maxNumLights());
string lightFormat("lights[{}].");
for(int i=0; i < maxNumLights(); ++i){
LightInfo& light = lightInfos[i];
string prefix = format(lightFormat, i);
light.positionLocation = getUniformLocation(prefix + "position");
light.intensityLocation = getUniformLocation(prefix + "intensity");
light.ambientIntensityLocation = getUniformLocation(prefix + "ambientIntensity");
light.constantAttenuationLocation = getUniformLocation(prefix + "constantAttenuation");
light.linearAttenuationLocation = getUniformLocation(prefix + "linearAttenuation");
light.quadraticAttenuationLocation = getUniformLocation(prefix + "quadraticAttenuation");
light.cutoffAngleLocation = getUniformLocation(prefix + "cutoffAngle");
light.beamWidthLocation = getUniformLocation(prefix + "beamWidth");
light.cutoffExponentLocation = getUniformLocation(prefix + "cutoffExponent");
light.directionLocation = getUniformLocation(prefix + "direction");
}
maxFogDistLocation = getUniformLocation("maxFogDist");
minFogDistLocation = getUniformLocation("minFogDist");
fogColorLocation = getUniformLocation("fogColor");
isFogEnabledLocation = getUniformLocation("isFogEnabled");
}
示例15: load
SgNode* VRMLSceneLoaderImpl::load(const std::string& filename)
{
converter.clearConvertedNodeMap();
SgGroupPtr top = new SgGroup;
try {
parser.load(filename);
while(VRMLNodePtr vrml = parser.readNode()){
SgNodePtr node = converter.convert(vrml);
if(node){
top->addChild(node);
}
}
parser.checkEOF();
} catch(EasyScanner::Exception& ex){
os() << ex.getFullMessage() << endl;
return 0;
}
if(top->empty()){
os() << format(_("VRML file \"{}\" does not have any valid entity."), filename) << endl;
return 0;
}
if(top->numChildren() == 1){
return top->child(0);
}
return top.retn();
}