本文整理汇总了C++中boost::format类的典型用法代码示例。如果您正苦于以下问题:C++ format类的具体用法?C++ format怎么用?C++ format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strerror
void BitsetSaver::save(
const std::vector<bool> &bits)
{
char byte = 0;
for (size_t i = 0; i < bits.size(); ++ i)
{
const unsigned shift = i % 8;
const char positionHasNeighbors = bits[i];
byte |= positionHasNeighbors << shift;
if (7 == shift)
{
if (!os_.write(&byte, sizeof(byte)))
{
const boost::format message = boost::format("Failed to write bits into %s: %s") % filePath_.string() % strerror(errno);
BOOST_THROW_EXCEPTION(common::IoException(errno, message.str()));
}
byte = 0;
}
}
if (!os_.write(&byte, sizeof(byte)))
{
const boost::format message = boost::format("Failed to write final bits byte into %s: %s") % filePath_.string() % strerror(errno);
BOOST_THROW_EXCEPTION(common::IoException(errno, message.str()));
}
}
示例2: check
void FastaDumperOptions::postProcess(bpo::variables_map &vm)
{
eagle::common::OptionsHelper check(vm);
if (fastaFiles.empty())
{
throw bpo::validation_error(bpo::validation_error::at_least_one_value_required, "", "positional");
}
check.addPathOptions(fastaFiles,"positional");
check.inputPathsExist();
if ( 1 == fastaFiles.size() && bfs::is_directory(fastaFiles[0]) )
{
mode = WHOLE_DIR;
} else {
for (unsigned int i = 0; i < fastaFiles.size(); i++)
{
if (bfs::is_directory(fastaFiles[i]))
{
const boost::format message = boost::format("\n *** FASTA file #%d has an invalid value: ***"
"\n *** It should point to a file, but a directory already exists with name %s ***\n")
% i % fastaFiles[i];
BOOST_THROW_EXCEPTION(eagle::common::InvalidOptionException(message.str()));
}
}
mode = SAFE_MODE;
}
check.inRange<unsigned long>(std::make_pair(size,"size"),1); // 1 <= size < inf
// (size == 0) not allowed, so internally used to represent 'until the end'
}
示例3: expandUseBasesMask
static std::vector<std::string > expandUseBasesMask (
const std::vector<unsigned int> &readLengths,
const std::string &useBasesMask,
const boost::filesystem::path &baseCallsDirectory)
{
std::vector<std::string > result;
std::string::const_iterator parseIt(useBasesMask.begin());
const std::string::const_iterator parseEnd(useBasesMask.end());
UseBasesMaskGrammar<std::string::const_iterator> parser(readLengths);
if (!boost::spirit::qi::parse(parseIt, parseEnd, parser, result) ||
parseEnd != parseIt)
{
const boost::format message = boost::format("\n *** Could not parse the use-bases-mask '%s' for '%s' at: %s ***\n") %
useBasesMask % baseCallsDirectory.string() % useBasesMask.substr(parseIt - useBasesMask.begin());
BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str()));
}
ISAAC_THREAD_CERR << "use bases mask: " << boost::algorithm::join(result, ",") << "\n";
ISAAC_THREAD_CERR << "reads parsed: " << parser.currentRead_ << "\n";
if (result.size() != readLengths.size())
{
const boost::format message = boost::format("\n *** use-bases-mask '%s' is incompatible with number of reads (%d) in %s ***\n") %
useBasesMask % readLengths.size() % baseCallsDirectory.string();
BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str()));
}
return result;
}
示例4: filePath_
BitsetSaver::BitsetSaver(const boost::filesystem::path filePath) :
filePath_(filePath),
os_(filePath.c_str())
{
if (!os_)
{
const boost::format message = boost::format("Failed to open file %s for writing: %s") % filePath_ % strerror(errno);
BOOST_THROW_EXCEPTION(common::IoException(errno, message.str()));
}
}
示例5: AppendStatusMessage
void vfeSession::AppendStatusMessage (const boost::format& fmt, int RecommendedPause)
{
boost::mutex::scoped_lock lock(m_MessageMutex);
m_StatusQueue.push (StatusMessage (*this, fmt.str(), RecommendedPause));
m_StatusLineMessage = fmt.str();
if (m_MaxStatusMessages != -1)
while (m_StatusQueue.size() > m_MaxStatusMessages)
m_StatusQueue.pop();
NotifyEvent(stStatusMessage);
}
示例6: CustomFormat
boost::format CustomFormat(const char* s)
{
using namespace boost::io;
boost::format format(s);
format.exceptions(all_error_bits ^ (too_many_args_bit | too_few_args_bit));
return format;
}
示例7: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
//std::string topic = nh.resolveName("image");
// std::string topic = "/ardrone/image_raw";
std::string topic = "/ardrone/kinect/image_raw";
std::string topic_depth = "/ardrone/kinect/depth/image_raw";
Callbacks callbacks;
//callbacks.control ="10000000";
//callbacks.path = "/home/jay/data/";
//obtain saving location
std::string saving_location = nh.resolveName("generated_set");
//if(saving_location.compare("generated_set")) saving_location = "remote_images/set_online";
callbacks.path = "/home/jay/data/"+saving_location;
boost::filesystem::path dir(callbacks.path);
boost::filesystem::remove_all(dir);
if(boost::filesystem::create_directory(dir)) {
callbacks.path_depth = callbacks.path+"/depth";
boost::filesystem::path dir_depth(callbacks.path_depth);
if(boost::filesystem::create_directory(dir_depth)) {
std::cout << "Success in creating: "<<callbacks.path_depth << "\n";
}
callbacks.path = callbacks.path+"/RGB";
boost::filesystem::path dir_rgb(callbacks.path);
if(boost::filesystem::create_directory(dir_rgb)) {
std::cout << "Success in creating: "<<callbacks.path << "\n";
}
}else{
std::cout <<"Failed to make saving direction "<<callbacks.path <<"\n";
}
// Useful when CameraInfo is being published
/*image_transport::CameraSubscriber sub_image_and_camera = it.subscribeCamera(topic, 1,
&Callbacks::callbackWithCameraInfo,
&callbacks);*/
// Useful when CameraInfo is not being published
image_transport::Subscriber sub_image = it.subscribe(
topic, 1, boost::bind(&Callbacks::callbackWithoutCameraInfo, &callbacks, _1));
//depth
image_transport::Subscriber sub_image_depth = it.subscribe(
topic_depth, 1, boost::bind(&Callbacks::callbackWithoutCameraInfoWithDepth, &callbacks, _1));
// Make subscriber to cmd_vel in order to set the name.
ros::Subscriber takeOff = nh.subscribe("/ardrone/takeoff",1,&Callbacks::callbackTakeoff, &callbacks);
ros::Subscriber subControl = nh.subscribe("/dagger_vel",1,&Callbacks::callbackCmd, &callbacks);
// [hover, back, forward, turn right, turn left, down, up, clockwise, ccw]
// Adapt name instead of left0000.jpg it should be 00000-gt1.jpg when receiving control 1 ~ straight
ros::NodeHandle local_nh("~");
std::string format_string;
local_nh.param("filename_format", format_string, std::string("%s/%010i-gt%s.%s"));
local_nh.param("encoding", encoding, std::string("bgr8"));
local_nh.param("save_all_image", save_all_image, true);
g_format.parse(format_string);
ros::ServiceServer save = local_nh.advertiseService ("save", service);
ros::spin();
}
示例8:
hpgl_exception::hpgl_exception(
const std::string & a_where,
const boost::format & what)
:m_where(a_where), m_what(what.str())
{
m_message = m_where + ": " + m_what;
//std::cerr << m_message << std::endl;
}
示例9:
error::error(
bool _status,
long long _code,
boost::format _msg,
std::string _file,
int _line,
std::string _fcn ) :
error::error( _status, _code, _msg.str(), _file, _line, _fcn ) {}
示例10: log
void Logger::log(
const Level& level,
const boost::format& message,
const std::string& filename,
const int& lineNumber
)
{
log( level, message.str(), filename, lineNumber );
}
示例11:
bs_exception::bs_exception (const std::string &who, const boost::format &message)
: who_ (who),
what_ (who_ + ": " + message.str ()),
m_err_ (user_defined)
{
#ifdef BS_EXCEPTION_COLLECT_BACKTRACE
what_ += detail::collect_backtrace ();
#endif
}
示例12: send
void Trace::send(const boost::format& str, TraceLevelOptions level)
{
if (not Trace::Pimpl::mTrace) {
Trace::init();
}
boost::mutex::scoped_lock lock(Trace::Pimpl::mTrace->getMutex());
Pimpl::mTrace->send(str.str(), level);
}
示例13: event_dumb
void chronometer_t::event_dumb(boost::format const& params) {
if (is_dumb) {
if (!log_ptr) {
log_ptr = logger::instance();
}
if (log_ptr) {
log_ptr->debug("raw/begin/" + name, params.str());
}
}
}
示例14: Critical
void Log::Critical( boost::format &fmt )
{
int ConsoleLogLevel = sConfig.GetIntDefault("Log.ConsoleLogLevel",LOGLEVEL_INFO);
int FileLogLevel = sConfig.GetIntDefault("Log.FileLogLevel",LOGLEVEL_WARNING);
if (ConsoleLogLevel >= LOGLEVEL_CRITICAL || FileLogLevel >= LOGLEVEL_CRITICAL)
{
Critical(fmt.str());
}
}
示例15: Debug
void Log::Debug( boost::format &fmt )
{
int ConsoleLogLevel = sConfig.GetIntDefault("Log.ConsoleLogLevel",LOGLEVEL_INFO);
int FileLogLevel = sConfig.GetIntDefault("Log.FileLogLevel",LOGLEVEL_WARNING);
if (ConsoleLogLevel >= LOGLEVEL_DEBUG || FileLogLevel >= LOGLEVEL_DEBUG)
{
Debug(fmt.str());
}
}