本文整理汇总了C++中ofstream::put方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::put方法的具体用法?C++ ofstream::put怎么用?C++ ofstream::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofstream
的用法示例。
在下文中一共展示了ofstream::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_array
void write_array(ofstream &out_file, const unsigned char *array,
size_t array_size, uint_least64_t half_key_length, bool decryption)
{
if (!decryption) {
for (size_t i = array_size; i < half_key_length; ++i) {
out_file.put('\0');
}
}
for (size_t i = decryption ? 1 : 0; i < array_size; ++i) {
out_file.put(static_cast<char>(array[i]));
}
}
示例2: writeChar
bool Serializer::writeChar(ofstream &outfile, char write) {
outfile.put(write);
if (!outfile.good())
return false;
return true;
}
示例3: writePDCHeader
//-----------------------------------------------------------------------------
void PDCFileWriter::writePDCHeader(ofstream &outfile)
{
//create temporary versions of the variables to byte-swap
int temp_formatVersion = getFormatVersion();
int temp_byteOrder = getByteOrder();
int temp_extra1 = getExtra1();
int temp_extra2 = getExtra2();
int temp_numParticles = getParticleCount();
int temp_numAttributes = getAttributeCount();
//do swap of byte order
swapInt((char*) &temp_formatVersion);
swapInt((char*) &temp_byteOrder);
swapInt((char*) &temp_extra1);
swapInt((char*) &temp_extra2);
swapInt((char*) &temp_numParticles);
swapInt((char*) &temp_numAttributes);
//write out to file
for(int i=0;i<4;i++)
{
outfile.put( m_format[i]);
}
outfile.write((char*) &temp_formatVersion, sizeof(int));
outfile.write((char*) &temp_byteOrder, sizeof(int));
outfile.write((char*) &temp_extra1, sizeof(int));
outfile.write((char*) &temp_extra2, sizeof(int));
outfile.write((char*) &temp_numParticles, sizeof(int));
outfile.write((char*) &temp_numAttributes, sizeof(int));
}
示例4: put16
void put16(ofstream &ofs, unsigned i)
{
char a, b;
a = i>>8;
// printf("store (%4X) %4X\n", i, a);
ofs.put((char)a);
ofs.put((char)i);
}
示例5:
//24bits per pixel bitmap
static bool write_bitmap24(unsigned char *bitmap)
{
char padding_byte=0;
int k=0;
for (int i=0; i<h;i++){
for (int j=0; j<original_w*3; j++){
fout.put(bitmap[k]);
k++;
}
for (int p=0; p<padbyte_count;p++)
fout.put(padding_byte);
}
return 1;
}
示例6: write_bitmap
//black and white bitmap
static bool write_bitmap(char *bitmap)
{
int i=0;
for (i=0; i<sz;i++)
fout.put(bitmap[i]);
return 1;
}
示例7: decode
/** This function handles the decoding of the
* input file. It will convert the encoded file
* to it's original condition.
*
* @params: reference to input & output streams
*/
void decode(BitInputStream* in, ofstream& out) {
int symbol = 0;
for (auto i = 0; i < numBytes; ++i) {
symbol = huffman->decode(*in);
out.put((char)symbol);
out.flush();
}
}
示例8: FileStream
void FileStream() {
char c;
while(infile.get(c)) {
outfile.put(c);
}
}
示例9: doFilter
void FileClass::doFilter(ifstream &input, ofstream &output) {
char letter;
while(!input.eof()) // double checks,
{
input.get(letter);
if (!(input)) break; // this is where the loop actually ends after .get reaches the eof
output.put(transform(letter));
}
}
示例10: doFilter
void FileClass::doFilter(ifstream &input, ofstream &output) {
char letter;
while(!input.eof())
{
input.get(letter);
if (!(input)) break;
output.put(transform(letter));
}
}
示例11: writeSample
void Tone::writeSample(int value, ofstream &out)
{
if(m_bitsPerSample == 16) {
int16_t sample = uint16toLE(value);
out.write((char *)&sample, 2);
}
else {
out.put(value);
}
}
示例12: transfer
//transfer function uses the virtual transform
void AbstractTrans::transfer() {
char ch;
char transCh;
inFile.get(ch);
while(!inFile.fail()) {
transCh = transform(ch);
outFile.put(transCh);
inFile.get(ch);
}
}
示例13: encrypt
//********************************************************************************
// Encrypt function uses the virtual transform member function to transform *
// individual characters. *
//********************************************************************************
void Encryption::encrypt()
{
char ch;
char transCh;
inFile.get(ch);
while (!inFile.fail())
{
transCh = transform(ch);
outFile.put(transCh);
inFile.get(ch);
}
}
示例14: handle_code
Context handle_code(ifstream& inFile, ofstream& outFile) {
char ch;
while(inFile.get(ch)) {
switch(ch) {
case '/':
if(!inFile.get(ch)) {
outFile.put('/');
return file_end;
}
else
{
if(ch == '*')
return c_comment;
else if(ch == '/')
return cpp_comment;
else {
cout << "Context = / followed by reg. text, ch = " << ch << endl;
outFile << keyWord;
keyIndex = 0;
strncpy(keyWord,"\0", 64);
outFile.put('/');
inFile.putback(ch);
break;
}
}
case '\"' : return string_literal;
case '\'' : return char_literal;
case '\n' : return newline;
default:
{
keyMatch(ch, outFile);
}
}
}
return file_end;
}
示例15: copy
void copy()
{
if( optAttributesOnly == false )
{
char c;
while( inputFile.get( c ) ) {
outputFile.put( c );
}
}
}