本文整理汇总了C++中ostream::put方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::put方法的具体用法?C++ ostream::put怎么用?C++ ostream::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ostream
的用法示例。
在下文中一共展示了ostream::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
uint32_t AsmFunc::write(ostream &out) const
{
out.write((const char *) name.index, 2);
out.write((const char *) doc.index, 2);
out.write((const char *) (&line_no), 2);
if (ctx) {
out.write((const char *) ctx->index, 2);
} else {
uint16_t zero(0);
out.write((const char *) &zero, 2);
}
out.write((const char *) param_types.index, 2);
out.write((const char *) result_type.index, 2);
out.put(this->fcontext);
out.put(argc);
out.put(regc);
out.put('\0');
uint32_t func_size(FunctionHeader::SIZE);
AsmParamList::const_iterator pit(params.begin());
for (; pit!=params.end(); ++pit) {
out.write((const char *) (*pit)->name.index, 2);
out.write((const char *) (*pit)->type.index, 2);
func_size += 4;
}
codeblock::const_iterator ci(code.begin());
for (; ci!=code.end(); ++ci) {
uint8_t isize(write_instruction(out, **ci));
func_size += isize;
}
return func_size;
}
示例2: save
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::save(ostream& out) const
{
// Write out each of the key and value pairs
bool changed = false;
for(int i = 0; i < LastPropType; ++i)
{
// Try to save some space by only saving the items that differ from default
if(myProperties[i] != ourDefaultProperties[i])
{
writeQuotedString(out, ourPropertyNames[i]);
out.put(' ');
writeQuotedString(out, myProperties[i]);
out.put('\n');
changed = true;
}
}
if(changed)
{
// Put a trailing null string so we know when to stop reading
writeQuotedString(out, "");
out.put('\n');
out.put('\n');
}
}
示例3: boxLine
//---------------------------------------------------------------------------------
// Function: boxLine()
// Title: Box Line
// Description:
// draws a a line of text aligned in the middle of the box
// Programmer: Paul Bladek
//
// Date: 10/3/2006
//
// Version: 1.01
//
// Environment: Hardware: i3
// Software: OS: Windows 7;
// Compiles under Microsoft Visual C++ 2012
//
// Output: Formatted text to sout
//
// Called By: header()
// endbox()
//
// Parameters: sout: ostream&; stream to print to
// text: const string&; text to print
// length: unsigned short; length of the box
// alignment: unsigned char; 'L' (left), 'C'(center),'R'(right)
// fillc: char; fill character
//
// Returns: void
//
// History Log:
// 10/3/2006 PB completed v 1.01
//
//---------------------------------------------------------------------------------
void boxLine(ostream& sout, const string& text, unsigned short length,
unsigned char alignment, char fillc)
{
long originalformat = sout.flags(); // saves original format
alignment = toupper(alignment);
if(alignment != LEFT && alignment != RIGHT && alignment != CENTER)
throw exception();
if(length > MAX_LINE_LENGTH)
length = MAX_LINE_LENGTH;
sout << setfill(fillc); // change fill character
sout.put(VERT);
if(alignment == CENTER)
{
sout <<
setw((length + static_cast<streamsize>(text.length())) / 2 - 1)
<< text
<< setw((length - static_cast<streamsize>(text.length())) / 2 - 1)
<< fillc;
if(text.length() % 2 == 0)
sout << fillc;
}
else
{
if(alignment == LEFT)
sout << left;
sout << setw(length - OFFSET) << text;
}
sout.flags(originalformat); // reset flags
sout.put(VERT);
sout << endl;
}
示例4: write_update
void Alg_smf_write::write_update(Alg_update_ptr update)
{
char *name = update->parameter.attr_name();
/****Non-Meta Events****/
if (!strcmp(name, "pressurer")) {
write_delta(update->time);
if (update->get_identifier() < 0) { // channel pressure message
out_file->put(0xD0 + to_midi_channel(update->chan));
write_data((int)(update->parameter.r * 127));
} else { // just 1 key -- poly pressure
out_file->put(0xA0 + to_midi_channel(update->chan));
write_data(update->get_identifier());
write_data((int)(update->parameter.r * 127));
}
} else if (!strcmp(name, "programi")) {
write_delta(update->time);
out_file->put(0xC0 + to_midi_channel(update->chan));
write_data(update->parameter.i);
} else if (!strcmp(name, "bendr")) {
int temp = ROUND(0x2000 * (update->parameter.r + 1));
if (temp > 0x3fff) temp = 0x3fff; // 14 bits maximum
if (temp < 0) temp = 0;
int c1 = temp & 0x7F; // low 7 bits
int c2 = temp >> 7; // high 7 bits
write_delta(update->time);
out_file->put(0xE0 + to_midi_channel(update->chan));
write_data(c1);
write_data(c2);
} else if (!strncmp(name, "control", 7) &&
示例5: writePPM
void Image::writePPM(ostream& o)
{
o << "P6\n";
o << mWidth << ' ' << mHeight << '\n';
o << "255\n";
int i, j;
unsigned int ired, igreen, iblue;
unsigned char red, green, blue;
for (i = mHeight - 1; i >= 0; i--)
{
for (j = 0; j < mWidth;++j)
{
ired = (unsigned int)(256 * mRaster[j][i].r());
igreen = (unsigned int)(256 * mRaster[j][i].g());
iblue = (unsigned int)(256 * mRaster[j][i].b());
if (ired > 255) ired = 255;
if (igreen > 255) igreen = 255;
if (iblue > 255) iblue = 255;
red = (unsigned char)ired;
green = (unsigned char)igreen;
blue = (unsigned char)iblue;
o.put(red);
o.put(green);
o.put(blue);
}
}
}
示例6: Write
FIT_UINT8 FieldDefinition::Write(ostream &file)
{
file.put(num);
file.put(size);
file.put(type);
return 3;
}
示例7: write_smpteoffset
void Alg_smf_write::write_smpteoffset(Alg_update_ptr update, char *s)
{
write_midi_channel_prefix(update);
write_delta(update->time);
out_file->put(0xFF); // meta event
out_file->put(0x54); // smpte offset type code
out_file->put(5); // length
for (int i = 0; i < 5; i++) *out_file << s[i];
}
示例8: write_text
void Alg_smf_write::write_text(Alg_update_ptr update, char type)
{
write_midi_channel_prefix(update);
write_delta(update->time);
out_file->put(0xFF);
out_file->put(type);
out_file->put((char) strlen(update->parameter.s));
*out_file << update->parameter.s;
}
示例9: boxBottom
//---------------------------------------------------------------------------------
// Function: boxBottom()
// Title: Box Bottom
// Description:
// draws a a line for the bottom of the box
// Programmer: Paul Bladek
//
// Date: 10/3/2006
//
// Version: 1.01
//
// Environment: Hardware: i3
// Software: OS: Windows 7;
// Compiles under Microsoft Visual C++ 2012
//
// Output: Formatted line to sout
//
// Called By: header()
// endbox()
//
// Parameters: sout: ostream&; stream to print to
// ength: unsigned short; length of the box
//
// Returns: void
//
// History Log:
// 10/3/2006 PB completed v 1.01
//
//---------------------------------------------------------------------------------
void boxBottom(ostream& sout, unsigned short length)
{
if(length > MAX_LINE_LENGTH)
length = MAX_LINE_LENGTH;
sout.put(LL);
for(int i = 0; i < length - OFFSET; i++)
sout.put(HORIZ);
sout.put(LR);
sout << endl;
}
示例10: write_binary
void Alg_smf_write::write_binary(int type_byte, char *msg)
{
int len = strlen(msg) / 2;
out_file->put(type_byte);
write_varinum(len);
for (int i = 0; i < len; i++) {
out_file->put(hex_to_char(msg));
msg += 2;
}
}
示例11: write_delimited
void write_delimited(ostream& os, const string& s)
/* PURPOSE: write a "" delimited string (including spaces)
to a stream. Embedded " and \ are quoted by \
*/
{ os.put('"');
for (unsigned i = 0; i < s.length(); i++)
{ char ch = s[i];
if (ch == '"' || ch == '\\') os.put('\\');
os.put(ch);
}
os.put('"');
}
开发者ID:schulzmarc,项目名称:Loyola-University-Chicago---Computer-Science-272--Student-,代码行数:12,代码来源:shapes.cpp
示例12: write_midi_channel_prefix
void Alg_smf_write::write_midi_channel_prefix(Alg_update_ptr update)
{
if (update->chan >= 0) { // write MIDI Channel Prefix
write_delta(update->time);
out_file->put(0xFF); // Meta Event
out_file->put(0x20); // Type code for MIDI Channel Prefix
out_file->put(1); // length
out_file->put(to_midi_channel(update->chan));
// one thing odd about the Std MIDI File spec is that once
// you turn on MIDI Channel Prefix, there seems to be no
// way to cancel it unless a non-Meta event shows up. We
// don't do any analysis to avoid assigning channels to
// meta events.
}
}
示例13: Crypt
void Engine::Crypt(istream& I, ostream& O, bool unwrapFlag)
{
vector<thread> threads;
vector<ostream&> Os;
if (phase != fresh)
throw Exception("The phase must be fresh to call Engine::Crypt().");
for(unsigned int i=0; i<Pi; i++)
{
// Pistons[i].Crypt(I, O, Et[i], unwrapFlag);
stringstream stream;
Os.push_back(stream);
threads.push_back(thread(&Piston::Crypt, &Pistons[i], I, Os.at[i], Et[i], unwrapFlag));
}
for(unsigned int i=0; i<Pi; i++)
{
threads.at(i).join();
O.put(Os.at(i).str());
}
if (hasMore(I))
phase = crypted;
else
phase = endOfCrypt;
}
示例14: GetTags
void Engine::GetTags(ostream& T, const vector<unsigned int>& l)
{
vector<thread> threads;
vector<stringstream> Ts;
if (phase != endOfMessage)
throw Exception("The phase must be endOfMessage to call Engine::GetTags().");
Spark(true, l);
for(unsigned int i=0; i<Pi; i++)
{
// Pistons[i].GetTag(T, l[i]);
stringstream stream;
Ts.push_back(stream);
threads.push_back(thread(&Piston::GetTag, &Pistons[i], Ts.at(i), l[i]));
}
for(unsigned int i=0; i<Pi; i++)
{
threads.at(i).join();
T.put(Ts.at(i).str());
}
phase = fresh;
}
示例15: WriteObject
void OutputStreamHelper::WriteObject(ostream& stream, T value)
{
for (uint32_t size = sizeof(T); size > 0; --size, value >>= 8)
{
stream.put(static_cast<char>(value & 0xFF));
}
}