예제 #1
0
/**
 * \brief Print RTL to a stream.
 *
 * Prints this object to a stream in text form.
 *
 * \param os  Stream to output to (often cout or cerr).
 */
void
RTL::print(std::ostream &os /*= cout*/, bool html /*=false*/) const
{
	if (html)
		os << "<tr><td>";
	// print out the instruction address of this RTL
	auto fill = os.fill('0');
	os << std::hex << std::setw(8) << nativeAddr << std::dec;
	os.fill(fill);
	if (html)
		os << "</td>";

	// Print the statements
	// First line has 8 extra chars as above
	bool bFirst = true;
	for (const auto &stmt : stmtList) {
		if (html) {
			if (!bFirst) os << "<tr><td></td>";
		} else {
			if (bFirst) os << " ";
			else        os << std::setw(9) << " ";
		}
		if (stmt) stmt->print(os, html);
		// Note: we only put newlines where needed. So none at the end of
		// Statement::print; one here to separate from other statements
		if (html)
			os << "</tr>";
		os << "\n";
		bFirst = false;
	}
	if (stmtList.empty()) os << std::endl;  // New line for NOP
}
예제 #2
0
static inline void formatGdbmiChar(std::ostream &str, wchar_t c)
{
    switch (c) {
    case L'\n':
        str << "\\n";
        break;
    case L'\t':
        str << "\\t";
        break;
    case L'\r':
        str << "\\r";
        break;
    case L'\\':
    case L'"':
        str << '\\' << char(c);
        break;
    default:
        if (c < 128) {
            str << char(c);
        } else {
            // Always pad up to 3 digits in case a digit follows
            const char oldFill = str.fill('0');
            str << '\\' << std::oct;
            str.width(3);
            str << unsigned(c) << std::dec;
            str.fill(oldFill);
        }
        break;
    }
}
예제 #3
0
void Date::print(std::ostream& out) const {
    auto ch = out.fill('0');
    out << std::setw(2) << day << '.';
    out << std::setw(2) << month << '.';
    out << std::setw(4) << year;
    out.fill(ch);
}
BOOL LLPermissions::exportStream(std::ostream& output_stream) const
{
	if (!output_stream.good()) return FALSE;
	output_stream <<  "\tpermissions 0\n";
	output_stream <<  "\t{\n";

	char prev_fill = output_stream.fill('0');
	output_stream << std::hex;
	output_stream << "\t\tbase_mask\t" << std::setw(8) << mMaskBase << "\n";
	output_stream << "\t\towner_mask\t" << std::setw(8) << mMaskOwner << "\n";
	output_stream << "\t\tgroup_mask\t" << std::setw(8) << mMaskGroup << "\n";
	output_stream << "\t\teveryone_mask\t" << std::setw(8) << mMaskEveryone << "\n";
	output_stream << "\t\tnext_owner_mask\t" << std::setw(8) << mMaskNextOwner << "\n";
	output_stream << std::dec;
	output_stream.fill(prev_fill);

	output_stream <<  "\t\tcreator_id\t" << mCreator << "\n";
	output_stream <<  "\t\towner_id\t" << mOwner << "\n";
	output_stream <<  "\t\tlast_owner_id\t" << mLastOwner << "\n";
	output_stream <<  "\t\tgroup_id\t" << mGroup << "\n";

	if(mIsGroupOwned)
	{
		output_stream <<  "\t\tgroup_owned\t1\n";
	}
	output_stream << "\t}\n";
	return TRUE;
}
예제 #5
0
void print128(std::ostream& out, uint8* data)
{
	out.fill('0');
	out << std::hex;
	for(int i = 15; i >= 0; --i) {
		out.width(2);
		out << int(data[i]);
	}
	out.fill(' ');
	out << std::dec;
}
예제 #6
0
// Format a 128bit vector register by adding digits in reverse order
void formatVectorRegister(std::ostream &str, const unsigned char *array, int size)
{
    const char oldFill = str.fill('0');

    str << "0x" << std::hex;
    for (int i = size - 1; i >= 0; i--) {
        str.width(2);
        str << unsigned(array[i]);
    }
    str << std::dec;

    str.fill(oldFill);
}
예제 #7
0
  void ILogger::WriteTag(std::ostream& theOstream, SeverityType theSeverity,
      const char* theSourceFile, int theSourceLine)
  {
    const struct std::tm* anTm; // Pointer to Time structure
    std::time_t anNow;

    // Get current time in seconds since Jan 1, 1970
    anNow = std::time(NULL);

    // Convert current time value into local time (with help from OS)
    anTm = std::localtime(&anNow);

    // Output time in timestamp format
    theOstream << anTm->tm_year + 1900 << "-";
    theOstream.fill('0');
    theOstream.width(2);
    theOstream << anTm->tm_mon + 1 << "-";
    theOstream.fill('0');
    theOstream.width(2);
    theOstream << anTm->tm_mday << " ";
    theOstream.fill('0');
    theOstream.width(2);
    theOstream << anTm->tm_hour + 1 << ":";
    theOstream.fill('0');
    theOstream.width(2);
    theOstream << anTm->tm_min << ":";
    theOstream.fill('0');
    theOstream.width(2);
    theOstream << anTm->tm_sec << " ";

    // Now print the log level as a single character
    switch(theSeverity)
    {
      case SeverityInfo:
        theOstream << "I";
        break;
      case SeverityWarning:
        theOstream << "W";
        break;
      case SeverityError:
        theOstream << "E";
        break;
      case SeverityFatal:
        theOstream << "F";
        break;
      default:
        theOstream << "U";
        break;
    }
    theOstream << " " << theSourceFile << ":" << theSourceLine << " ";
  }
예제 #8
0
파일: common.cpp 프로젝트: abners/brpc
void PrintRealDateTime(std::ostream& os, int64_t tm,
                       bool ignore_microseconds) {
    char buf[32];
    const time_t tm_s = tm / 1000000L;
    struct tm lt;
    strftime(buf, sizeof(buf), "%Y/%m/%d-%H:%M:%S", localtime_r(&tm_s, &lt));
    if (ignore_microseconds) {
        os << buf;
    } else {
        const char old_fill = os.fill('0');
        os << buf << '.' << std::setw(6) << tm % 1000000L;
        os.fill(old_fill);
    }
}
예제 #9
0
void
FormattedTable::printNoDataRow(char intersect_char, char fill_char,
                               std::ostream & out, std::map<std::string, unsigned short> & col_widths,
                               std::set<std::string>::iterator & col_begin, std::set<std::string>::iterator & col_end) const
{
  out.fill(fill_char);
  out << std::right << intersect_char << std::setw(_column_width+2) << intersect_char;
  for (std::set<std::string>::iterator header = col_begin; header != col_end; ++header)
    out << std::setw(col_widths[*header]+2) << intersect_char;
  out << "\n";

  // Clear the fill character
  out.fill(' ');
}
void StackFrame::Print(std::ostream &stream) const {
  char old_fill = stream.fill('0');

  stream << std::hex << std::setw(8)
         << reinterpret_cast<long>(return_address_)
         << std::dec;

  stream.fill(old_fill);

  if (!callee_name_.empty()) {
    stream << " in " << callee_name_ << " ()";
  } else {
    stream << " in ?? ()";
  }
}
예제 #11
0
// printAlignedFP - Simulate the printf "%A.Bf" format, where A is the
// TotalWidth size, and B is the AfterDec size.
//
static void printAlignedFP(double Val, unsigned AfterDec, unsigned TotalWidth,
                           std::ostream &OS) {
  assert(TotalWidth >= AfterDec+1 && "Bad FP Format!");
  OS.width(TotalWidth-AfterDec-1);
  char OldFill = OS.fill();
  OS.fill(' ');
  OS << (int)Val;  // Integer part;
  OS << ".";
  OS.width(AfterDec);
  OS.fill('0');
  unsigned ResultFieldSize = 1;
  while (AfterDec--) ResultFieldSize *= 10;
  OS << (int)(Val*ResultFieldSize) % ResultFieldSize;
  OS.fill(OldFill);
}
예제 #12
0
파일: Memory.cpp 프로젝트: Jach/luciddb
void hexDump(std::ostream &o,void const *v,uint cb,uint cbDone)
{
    boost::io::ios_all_saver streamStateSaver(o);

    PConstBuffer b = (PConstBuffer) v;
    uint cbLine = 16, cbThis;
    o.fill('0');
    for (; cb; cb -= cbThis, cbDone += cbThis) {
        cbThis = std::min(cbLine, cb);
        o << std::hex;
        o.width(4);
        o << cbDone << ": ";
        uint i;
        for (i = 0; i < cbThis; i++, b++) {
            o.width(2);
            o << (uint) *b << " ";
        }
        for (i = cbThis; i < cbLine; i++) {
            o << "   ";
        }
        o << "| ";
        for (i = 0, b -= cbThis; i < cbThis; i++, b++) {
            if (isprint(*b)) {
                o << *b;
            } else {
                o << " ";
            }
        }
        o << std::endl;
    }
}
예제 #13
0
void print_in_readelf_style(std::ostream& s, const core::Cie& cie)
{
	// first line is section-offset, length-not-including-length-field, zeroes, "CIE"
	s.width(8);
	s.fill('0');
	s 	<< setw(8) << setfill('0') << std::hex << cie.get_offset()
		<< ' ' 
		<< setw(16) << setfill('0') << std::hex << cie.get_bytes_in_cie()
		<< ' ' 
		<< setw(8) << setfill('0') << 0 << std::dec
		<< " CIE"
		<< endl;
	// cie fields come next
	s 	<< "  Version:               " << (int) cie.get_version()                 << endl
		<< "  Augmentation:          \"" << cie.get_augmenter() << "\""  << endl
		<< "  Code alignment factor: " << cie.get_code_alignment_factor() << endl
		<< "  Data alignment factor: " << cie.get_data_alignment_factor() << endl
		<< "  Return address column: " << cie.get_return_address_register_rule() << endl
		<< "  Augmentation data:     ";
	auto augbytes = cie.get_augmentation_bytes();
	for (auto i_byte = augbytes.begin(); i_byte != augbytes.end(); ++i_byte)
	{
		if (i_byte != augbytes.begin()) s << ' ';
		s << std::hex << setw(2) << setfill('0') << (unsigned) *i_byte;
	}
	s << std::dec << endl;
	
	s << endl;
	
	/* Now we need to print the "initial instructions". */
	encap::frame_instrlist initial_instrs(cie, /* FIXME */ 8, cie.initial_instructions_seq());
	print_in_readelf_style(s, initial_instrs, -1);
}
예제 #14
0
파일: bfg.cpp 프로젝트: tom42/txtvc
void generate_source_font_data(std::ostream& os, const txtvc::bfgfont& font,
    const std::string& font_data_identifier)
{
    const int bytes_per_line = 8;
    const boost::io::ios_fill_saver fill_saver(os);
    const boost::io::ios_width_saver width_saver(os);
    const boost::io::ios_flags_saver flags_saver(os);

    // Dump font data
    os << "static const uint8_t " << font_data_identifier << "[] =" << std::endl;
    os << "{" << std::endl;
    os << std::hex;
    os.fill('0');
    int count = 0;
    for (auto byte : font.data())
    {
        if (count % bytes_per_line == 0)
        {
            os << indent;
        }
        os << "0x" << std::setw(2) << int(byte) << ", ";
        if (count % bytes_per_line == bytes_per_line - 1)
        {
            os << std::endl;
        }
        ++count;
    }
    os << "};" << std::endl << std::endl;
}
예제 #15
0
파일: fmt.cpp 프로젝트: zbigg/tinfra
size_t basic_fmt::check_command(std::ostream& formatter)
{
    fmt_command cmd;
    ostream_string_output output(formatter);
    
    size_t cmd_pos = process_fmt(this->fmt_, this->pos_, cmd, output);
    if( cmd_pos == (size_t)-1 ) 
        throw format_exception("basic_fmt: too many actual arguments");
    if( cmd.fill )
        formatter.fill(cmd.fill);
    if( cmd.width )
        formatter.width(cmd.width);
    if( cmd.precision )
        formatter.precision(cmd.precision);
    
    switch( cmd.command ) {
    case 's':
    case 'i':
    case 'd':
        std::dec(formatter);
        break;
    case 'x':
        std::hex(formatter);
        break;
    default:
        throw format_exception(fmt("basic_fmt: bad format command %s") % cmd.command);
    }
    return cmd_pos;
}
예제 #16
0
파일: utils.cpp 프로젝트: Hadel/Orion
void Utils::DisplayTime( const timespec& disp, std::ostream& Cout)
{
	Cout << disp.tv_sec << ".";
	Cout.width(9);
	Cout.fill('0');
	Cout << disp.tv_nsec << " second(s)";
}
예제 #17
0
void print_in_readelf_style(std::ostream& s, const Cie& cie)
{
	// first line is section-offset, length-not-including-length-field, zeroes, "CIE"
	s.width(8);
	s.fill('0');
	s 	<< setw(8) << setfill('0') << std::hex << cie.get_offset()
		<< ' ' 
		<< setw(16) << setfill('0') << std::hex << cie.get_bytes_in_cie()
		<< ' ' 
		<< setw(8) << setfill('0') << 0 << std::dec
		<< " CIE "
		<< "\"" << cie.get_augmenter() << "\" cf=" << cie.get_code_alignment_factor()
		<< " df=" << cie.get_data_alignment_factor()
		<< " ra=" << cie.get_return_address_register_rule() << endl;
	
	/* Now we need to print the "initial instructions" in decoded form. */
	auto result = cie.get_owner().interpret_instructions(
		cie, 
		0, 
		cie.get_initial_instructions(),
		cie.get_initial_instructions_length()
	);
	// encap::frame_instrlist initial_instrs(cie, /* FIXME */ 8, cie.initial_instructions_seq());
	/* Add the unfinished row as if it were a real row. */
	result.add_unfinished_row(/* HACK */ result.unfinished_row_addr + 1);

	print_in_readelf_style(s, result, cie);
}
예제 #18
0
void print_in_readelf_style(std::ostream& s, const Fde& fde)
{
	// auto decoded = decode_fde(dbg, fde);
	// don't decode -- that's for -wF

	// first line is section-offset, length-not-including-length-field, id, "FDE"
	s.width(8);
	s.fill('0');
	s 	<< setw(8) << setfill('0') << std::hex << fde.get_fde_offset()
		<< ' ' 
		<< setw(16) << setfill('0') << std::hex << fde.get_fde_byte_length()
		<< ' ' 
		<< setw(8) << setfill('0') << fde.get_id() << std::dec
		<< " FDE cie="
		<< setw(8) << setfill('0') << std::hex << fde.find_cie()->get_cie_offset()
		<< " pc="
		<< setw(16) << setfill('0') << std::hex << fde.get_low_pc()
		<< ".." 
		<< setw(16) << setfill('0') << std::hex << (fde.get_low_pc() + fde.get_func_length())
		<< endl;
		
	/* Now we need to print the "initial instructions" in decoded form. */
	auto result = fde.decode();
	result.add_unfinished_row(fde.get_low_pc() + fde.get_func_length());

	print_in_readelf_style(s, result, *fde.find_cie());
}
inline
arma_ostream_state::arma_ostream_state(const std::ostream& o)
  : orig_flags    (o.flags())
  , orig_precision(o.precision())
  , orig_width    (o.width())
  , orig_fill     (o.fill())
  {
  }
예제 #20
0
 void MatrixArchive::writeName(std::ostream & fout, std::string const & name) const
 {
   // fixed size character name
   validateName(name, SM_SOURCE_FILE_POS);
   fout.fill(' ');
   fout.width(s_fixedNameSize);
   fout << name;
 }
예제 #21
0
void FileLogger::writeTag(std::ostream& outStream, SeverityType severity, const char* sourceFile, int sourceLine)
{
    const struct std::tm* timeStruct;
    std::time_t now;

    now = std::time(nullptr);

    timeStruct = std::localtime(&now);

    outStream << timeStruct->tm_year + 1900 << "-";
    outStream.fill('0');
    outStream.width(2);
    outStream << timeStruct->tm_mon + 1 << "-";
    outStream.fill('0');
    outStream.width(2);
    outStream << timeStruct->tm_mday << " ";
    outStream.fill('0');
    outStream.width(2);
    outStream << timeStruct->tm_hour + 1 << ":";
    outStream.fill('0');
    outStream.width(2);
    outStream << timeStruct->tm_min << ":";
    outStream.fill('0');
    outStream.width(2);
    outStream << timeStruct->tm_sec << " ";

    switch(severity)
    {
    case SeverityInfo:
        outStream << "Information :";
        break;
    case SeverityWarning:
        outStream << "Warning     :";
        break;
    case SeverityError:
        outStream << "Error       :";
        break;
    case SeverityFatal:
        outStream << "Fatal error :";
        break;
    default:
        outStream << "Unknown     :";
        break;
    }
    outStream << " " << sourceFile << " : line " << sourceLine << " ";
}
inline
void
arma_ostream_state::restore(std::ostream& o) const
  {
  o.flags    (orig_flags);
  o.precision(orig_precision);
  o.width    (orig_width);
  o.fill     (orig_fill);
  }
예제 #23
0
void
printHex(std::ostream& os, const uint8_t* buffer, size_t length, bool isUpperCase/* = true*/)
{
  if (buffer == nullptr || length == 0)
    return;

  auto newFlags = std::ios::hex;
  if (isUpperCase) {
    newFlags |= std::ios::uppercase;
  }
  auto oldFlags = os.flags(newFlags);
  auto oldFill = os.fill('0');
  for (size_t i = 0; i < length; ++i) {
    os << std::setw(2) << static_cast<unsigned int>(buffer[i]);
  }
  os.fill(oldFill);
  os.flags(oldFlags);
}
예제 #24
0
	static void setPos(std::ostream& _os, const std::streamsize& _x, const std::streamsize& _y)
	{
		char tmp = _os.fill();

		if (_y > 0)
		{
			_os.fill('\n');
			_os.width(_y);
			_os << '\n';
		}
		if (_x > 0)
		{
			_os.fill(' ');
			_os.width(_x);
			_os << ' ';
		}
		_os.flush();
		_os.fill(tmp);
	}
예제 #25
0
파일: main.cpp 프로젝트: DanSciortino/ODU
void printHeading( std::ostream& outs, std::string title, int width, char border_char )
{

    printHorizontalLine( outs, border_char, width );
    printCenteredTitle( outs, title, width);
    printHorizontalLine( outs, border_char, width );

    //reset outs
    outs.clear();
    outs.fill(' ');
}
예제 #26
0
void init_iosflags(std::ostream& ss, const PrintfSpec& spec) {
	if (spec.width != -1)
		ss.width(spec.width);
	if (spec.precision != -1)
		ss.precision(spec.precision);

	if (spec.flags & PrintfSpec::AlignLeft)
		ss.setf(std::ios::left, std::ios::adjustfield);
	else {
		if (spec.flags & PrintfSpec::PadZero)
			ss.setf(std::ios::internal, std::ios::adjustfield);
		else
			ss.setf(std::ios::right, std::ios::adjustfield);
	}
	if (spec.flags & PrintfSpec::PadZero) ss.fill('0');
	if (spec.flags & PrintfSpec::ForceSign) ss.setf(std::ios::showpos);
	if (spec.flags & PrintfSpec::ShowType) {
		ss.setf(std::ios::showpoint);
		ss.setf(std::ios::showbase);
	}
}
예제 #27
0
파일: printer.hpp 프로젝트: Jiish/prophy
inline void print_byte(std::ostream& out, uint8_t x)
{
    switch (x)
    {
        case 9: out << "\\t"; return;
        case 10: out << "\\n"; return;
        case 13: out << "\\r"; return;
        case 92: out << "\\\\"; return;
    }
    if ((x >= 32) && (x <= 126))
    {
        out << char(x);
    }
    else
    {
        out << "\\x";
        out.width(2);
        out.fill('0');
        out << std::hex << unsigned(x);
    }
}
예제 #28
0
void print_in_readelf_style(std::ostream& s, const core::Fde& fde)
{
	// auto decoded = decode_fde(dbg, fde);
	// don't decode -- that's for -wF

	// first line is section-offset, length-not-including-length-field, id, "FDE"
	s.width(8);
	s.fill('0');
	s 	<< setw(8) << setfill('0') << std::hex << fde.get_fde_offset()
		<< ' ' 
		<< setw(16) << setfill('0') << std::hex << fde.get_fde_byte_length()
		<< ' ' 
		<< setw(8) << setfill('0') << fde.get_id() << std::dec
		<< " FDE cie="
		<< setw(8) << setfill('0') << std::hex << fde.find_cie()->get_cie_offset()
		<< " pc="
		<< setw(16) << setfill('0') << std::hex << fde.get_low_pc()
		<< ".." 
		<< setw(16) << setfill('0') << std::hex << (fde.get_low_pc() + fde.get_func_length())
		<< endl;
	auto augbytes = fde.get_augmentation_bytes();
	if (augbytes.size() > 0) 
	{
		s << "  Augmentation data:     ";
		for (auto i_byte = augbytes.begin(); i_byte != augbytes.end(); ++i_byte)
		{
			if (i_byte != augbytes.begin()) s << ' ';
			s << std::hex << setw(2) << setfill('0') << (unsigned) *i_byte;
		}
		s << endl << endl;
	}
	s << std::dec;
	
	/* Now we need to print the instructions. */
	// TODO: eliminate this once the assertion below assures me that it's the same as 
	// instrbytes etc..
	auto instr_seq = fde.instr_bytes_seq();
	encap::frame_instrlist instrs(*fde.find_cie(), /* FIXME */ 8, instr_seq);
	print_in_readelf_style(s, instrs, fde.get_low_pc());
}
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, const std::complex<T>* data, const uword n_elem)
  {
  arma_ignore(data);
  arma_ignore(n_elem);
  
  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.fill(' ');
  
  o.setf(ios::scientific);
  o.setf(ios::showpos);
  o.setf(ios::right);
  o.unsetf(ios::fixed);
  
  std::streamsize cell_width;
  
  o.precision(3);
  cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1;
  
  return cell_width;
  }
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, typename SpMat<T>::const_iterator begin, const uword n_elem, const typename arma_cx_only<T>::result* junk)
  {
  arma_ignore(begin);
  arma_ignore(n_elem);
  arma_ignore(junk);
  
  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.fill(' ');
  
  o.setf(ios::scientific);
  o.setf(ios::showpos);
  o.setf(ios::right);
  o.unsetf(ios::fixed);
  
  std::streamsize cell_width;
  
  o.precision(3);
  cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1;
  
  return cell_width;
  }