本文整理汇总了C++中boost::format::str方法的典型用法代码示例。如果您正苦于以下问题:C++ format::str方法的具体用法?C++ format::str怎么用?C++ format::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::format
的用法示例。
在下文中一共展示了format::str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
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: 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;
}
示例3: scanMaskFile
void ExtractNeighborsWorkflow::scanMaskFile(
const reference::SortedReferenceMetadata::MaskFile &maskFile,
const std::vector<uint64_t> &contigOffsets,
const std::vector<unsigned> &karyotypes,
std::vector<bool> &neighbors,
std::vector<bool> &highRepeats)
{
if (!exists(maskFile.path))
{
const boost::format message = boost::format("Mask file %s does not exist: %s") % maskFile.path;
BOOST_THROW_EXCEPTION(common::IoException(ENOENT, message.str()));
}
std::ifstream maskInput(maskFile.path.c_str());
if (!maskInput)
{
const boost::format message = boost::format("Failed to open mask file %s for reading: %s") % maskFile.path % strerror(errno);
BOOST_THROW_EXCEPTION(common::IoException(errno, message.str()));
}
std::size_t scannedKmers = 0, maskNeighbors = 0, maskNonHighRepeats = 0;
while(maskInput)
{
reference::ReferenceKmer<KmerT> referenceKmer;
if (maskInput.read(reinterpret_cast<char *>(&referenceKmer), sizeof(referenceKmer)))
{
++scannedKmers;
const reference::ReferencePosition pos = referenceKmer.getReferencePosition();
if (!pos.isTooManyMatch())
{
const reference::ReferencePosition translatedPos = pos.translateContig(karyotypes);
if (translatedPos.hasNeighbors())
{
neighbors.at(contigOffsets.at(translatedPos.getContigId()) + translatedPos.getPosition()) = true;
++maskNeighbors;
}
if (!highRepeats.empty())
{
highRepeats.at(contigOffsets.at(translatedPos.getContigId()) + translatedPos.getPosition()) = false;
}
++maskNonHighRepeats;
}
}
}
if (!maskInput.eof())
{
const boost::format message = boost::format("Failed to scan %s to the end") % maskFile.path % strerror(errno);
BOOST_THROW_EXCEPTION(common::IoException(errno, message.str()));
}
else
{
ISAAC_THREAD_CERR << "Scanning " << maskFile.path << " found " << scannedKmers << " kmers of which " <<
maskNeighbors << " neighbors and " << (scannedKmers - maskNonHighRepeats) << " high repeats" << std::endl;
}
}
示例4: 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);
}
示例5: postProcess
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'
}
示例6:
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;
}
示例7:
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 ) {}
示例8: log
void Logger::log(
const Level& level,
const boost::format& message,
const std::string& filename,
const int& lineNumber
)
{
log( level, message.str(), filename, lineNumber );
}
示例9:
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
}
示例10: 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());
}
}
示例11: 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);
}
示例12: 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());
}
}
}
示例13: 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());
}
}
示例14: Error
void Log::Error( boost::format &fmt )
{
int ConsoleLogLevel = sConfig.GetIntDefault("Log.ConsoleLogLevel",LOGLEVEL_INFO);
int FileLogLevel = sConfig.GetIntDefault("Log.FileLogLevel",LOGLEVEL_WARNING);
if (ConsoleLogLevel >= LOGLEVEL_ERROR || FileLogLevel >= LOGLEVEL_ERROR)
{
Error(fmt.str());
}
}
示例15: strerror
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()));
}
}