本文整理汇总了C++中WriteStream类的典型用法代码示例。如果您正苦于以下问题:C++ WriteStream类的具体用法?C++ WriteStream怎么用?C++ WriteStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WriteStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fp
void ArrayObject::save(const chowstring & filename)
{
FSFile fp(convert_path(filename).c_str(), "w");
if (!fp.is_open())
return;
WriteStream stream;
stream.write(CT_ARRAY_MAGIC, sizeof(CT_ARRAY_MAGIC));
stream.write_int16(ARRAY_MAJOR_VERSION);
stream.write_int16(ARRAY_MINOR_VERSION);
stream.write_int32(data.x_size);
stream.write_int32(data.y_size);
stream.write_int32(data.z_size);
int flags = 0;
if (data.is_numeric)
flags |= NUMERIC_FLAG;
if (data.offset != 0)
flags |= BASE1_FLAG;
stream.write_int32(flags);
for (int i = 0; i < data.x_size * data.y_size * data.z_size; i++) {
if (data.is_numeric) {
stream.write_int32(int(data.array[i]));
} else {
stream.write_int32(data.strings[i].size());
stream.write_string(data.strings[i]);
}
}
stream.save(fp);
fp.close();
}
示例2: writeStringFixed
void writeStringFixed(WriteStream &stream, const Common::UString &str, Encoding encoding, size_t length) {
if (length == 0)
return;
ScopedPtr<MemoryReadStream> data(convertString(str, encoding, false));
size_t n = stream.writeStream(*data, length);
while (n++ < length)
stream.writeByte(0);
}
示例3: write
void InsetMathAMSArray::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
os << "\\begin{" << name_ << '}';
bool open = os.startOuterRow();
InsetMathGrid::write(os);
os << "\\end{" << name_ << '}';
if (open)
os.startOuterRow();
}
示例4: write
void InsetMathCases::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
if (os.fragile())
os << "\\protect";
os << "\\begin{cases}\n";
InsetMathGrid::write(os);
if (os.fragile())
os << "\\protect";
os << "\\end{cases}";
}
示例5: fp
void AssociateArray::save(const std::string & path, int method)
{
FSFile fp(path.c_str(), "w");
if (!fp.is_open()) {
std::cout << "Could not save associate array: " << path << std::endl;
return;
}
WriteStream stream;
save_assarray(*this, stream, method);
stream.save(fp);
fp.close();
}
示例6: saveMemos
void FoxPro::saveMemos(WriteStream &fpt) const {
fpt.writeUint32BE(_memos.size() + 1); // Next free block
fpt.writeUint16BE(0x0000); // Reserved
fpt.writeUint16BE(_memoBlockSize);
// Reserved
for (int i = 0; i < 126; i++)
fpt.writeUint32BE(0x00000000);
for (size_t i = 0; i < _memos.size(); i++)
fpt.write(_memos[i], _memoBlockSize);
}
示例7: saveRecords
void FoxPro::saveRecords(WriteStream &dbf) const {
// Write the records
for (size_t i = 0; i < _records.size(); i++) {
const Record &record = _records[i];
dbf.writeByte(record.deleted ? '*' : ' ');
for (size_t j = 0; j < _fields.size(); j++)
dbf.write(record.fields[j], _fields[j].size);
}
dbf.writeByte(0x1A); // Records end marker
}
示例8: writeStringFixed
void writeStringFixed(WriteStream &stream, const Common::UString &str, Encoding encoding, size_t length) {
MemoryReadStream *data = 0;
try {
data = convertString(str, encoding, false);
size_t n = stream.writeStream(*data, length);
while (n++ < length)
stream.writeByte(0);
} catch (...) {
delete data;
throw;
}
delete data;
}
示例9: writeString
size_t writeString(WriteStream &stream, const Common::UString &str, Encoding encoding, bool terminate) {
ScopedPtr<MemoryReadStream> data(convertString(str, encoding, terminate));
const size_t n = stream.writeStream(*data);
return n;
}
示例10: write
void InsetMathBig::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
os << '\\' << name_ << delim_;
if (delim_[0] == '\\')
os.pendingSpace(true);
}
示例11: write
void InsetMathSplit::write(WriteStream & ws) const
{
MathEnsurer ensurer(ws);
if (ws.fragile())
ws << "\\protect";
docstring suffix;
if (!numbered_ && name_ == "align")
suffix = from_ascii("*");
ws << "\\begin{" << name_ << suffix << '}';
if (name_ != "split" && name_ != "align" && verticalAlignment() != 'c')
ws << '[' << verticalAlignment() << ']';
if (name_ == "alignedat")
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
InsetMathGrid::write(ws);
if (ws.fragile())
ws << "\\protect";
ws << "\\end{" << name_ << suffix << "}\n";
}
示例12: write
void InsetMathDecoration::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
if (os.fragile() && protect())
os << "\\protect";
os << '\\' << key_->name << '{';
ModeSpecifier specifier(os, currentMode());
os << cell(0) << '}';
}
示例13: write
void InsetMathSymbol::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
os << '\\' << name();
// $,#, etc. In theory the restriction based on catcodes, but then
// we do not handle catcodes very well, let alone cat code changes,
// so being outside the alpha range is good enough.
if (name().size() == 1 && !isAlphaASCII(name()[0]))
return;
os.pendingSpace(true);
}
示例14: write
void InsetMathTabular::write(WriteStream & os) const
{
ModeSpecifier specifier(os, TEXT_MODE);
if (os.fragile())
os << "\\protect";
os << "\\begin{" << name_ << '}';
bool open = os.startOuterRow();
char const v = verticalAlignment();
if (v == 't' || v == 'b')
os << '[' << v << ']';
os << '{' << horizontalAlignments() << "}\n";
InsetMathGrid::write(os);
if (os.fragile())
os << "\\protect";
os << "\\end{" << name_ << '}';
if (open)
os.startOuterRow();
// adding a \n here is bad if the tabular is the last item
// in an \eqnarray...
}
示例15: writeString
size_t writeString(WriteStream &stream, const Common::UString &str, Encoding encoding, bool terminate) {
size_t n = 0;
MemoryReadStream *data = 0;
try {
data = convertString(str, encoding, terminate);
n = stream.writeStream(*data);
} catch (...) {
delete data;
throw;
}
delete data;
return n;
}