本文整理汇总了C++中OStream::write方法的典型用法代码示例。如果您正苦于以下问题:C++ OStream::write方法的具体用法?C++ OStream::write怎么用?C++ OStream::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OStream
的用法示例。
在下文中一共展示了OStream::write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pos_to_str
void pos_to_str(Pos p, OStream & buf) {
if (p.name.empty())
buf.write("<anon>");
else
buf.write(p.name);
if (p.line == NPOS)
;//buf.write(":");
else if (p.col == NPOS)
buf.printf(":%u", p.line);
else
buf.printf(":%u:%u", p.line, p.col);
}
示例2: quantize
inline
void quantize(ngram_type& ngram, OStream& os, LogProbs& logprobs, Hashed& hashed, Counts& counts, Codemap& codemap, Codebook& codebook, int order, int shard)
{
hashed.clear();
counts.clear();
codemap.clear();
const size_type pos_first = ngram.index[shard].offsets[order - 1];
const size_type pos_last = ngram.index[shard].offsets[order];
for (size_type pos = pos_first; pos < pos_last; ++ pos)
++ hashed[logprobs(pos, order)];
counts.insert(hashed.begin(), hashed.end());
hashed.clear();
expgram::Quantizer::quantize(ngram, counts, codebook, codemap);
for (size_type pos = pos_first; pos < pos_last; ++ pos) {
typename Codemap::const_iterator citer = codemap.find(logprobs(pos, order));
if (citer == codemap.end())
throw std::runtime_error("no codemap?");
os.write((char*) &(citer->second), sizeof(quantized_type));
}
}
示例3: makeTiled
Int64
Header::writeTo (OStream &os, bool isTiled) const
{
//
// Write a "magic number" to identify the file as an image file.
// Write the current file format version number.
//
Xdr::write <StreamIO> (os, MAGIC);
int version = isTiled ? makeTiled (EXR_VERSION) : EXR_VERSION;
Xdr::write <StreamIO> (os, version);
//
// Write all attributes. If we have a preview image attribute,
// keep track of its position in the file.
//
Int64 previewPosition = 0;
const Attribute *preview =
findTypedAttribute <PreviewImageAttribute> ("preview");
for (ConstIterator i = begin(); i != end(); ++i)
{
//
// Write the attribute's name and type.
//
Xdr::write <StreamIO> (os, i.name());
Xdr::write <StreamIO> (os, i.attribute().typeName());
//
// Write the size of the attribute value,
// and the value itself.
//
StdOSStream oss;
i.attribute().writeValueTo (oss, version);
std::string s = oss.str();
Xdr::write <StreamIO> (os, (int) s.length());
if (&i.attribute() == preview)
previewPosition = os.tellp();
os.write (s.data(), s.length());
}
//
// Write zero-length attribute name to mark the end of the header.
//
Xdr::write <StreamIO> (os, "");
return previewPosition;
}
示例4: png_pov_write_data
void png_pov_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
OStream *file = reinterpret_cast<OStream *>(png_get_io_ptr(png_ptr));
if (!file->write (data, length))
{
Messages *m = reinterpret_cast<Messages *>(png_get_error_ptr(png_ptr));
if (m)
m->error = string("Cannot write PNG data");
throw POV_EXCEPTION(kFileDataErr, "Cannot write PNG data");
}
}
示例5: png_pov_write_data
void png_pov_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
OStream *file = (OStream *)png_get_io_ptr(png_ptr);
if (!file->write ((char *)data, length))
{
Messages *m = (Messages *)png_get_error_ptr(png_ptr);
if (m)
m->error = string("Cannot write PNG data");
throw POV_EXCEPTION(kFileDataErr, "Cannot write PNG data");
}
}
示例6: write_impl
static void write_impl(OStream & ost, array<typename OStream::char_type, N> const & s) {
ost.write(s.data(), N);
}