timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::data::base::stream_entry Struct Reference

#include "timemory/data/stream.hpp"

+ Collaboration diagram for tim::data::base::stream_entry:

Public Types

using string_t = std::string
 
using stringstream_t = std::stringstream
 
using format_flags = std::ios_base::fmtflags
 

Public Member Functions

 stream_entry (int _row=-1, int _col=-1, format_flags _fmt={}, int _width=0, int _prec=0, bool _center=false)
 
 ~stream_entry ()=default
 
 stream_entry (const stream_entry &)=default
 
 stream_entry (stream_entry &&)=default
 
stream_entryoperator= (const stream_entry &)=default
 
stream_entryoperator= (stream_entry &&)=default
 
string_t get () const
 
bool center () const
 
bool left () const
 
int row () const
 
int width () const
 
int column () const
 
int precision () const
 
format_flags flags () const
 
void center (bool v)
 
void left (bool v)
 
void row (int v)
 
void width (int v)
 
void column (int v)
 
void precision (int v)
 
void setf (format_flags v)
 
void operator() (const string_t &val)
 
template<typename Tp >
void construct (const Tp &val)
 
template<>
void construct (const timestamp_value_t &val)
 
template<>
void construct (const timestamp_value_t &val)
 

Protected Attributes

bool m_center = false
 
bool m_left = false
 
int m_row = 0
 
int m_column = 0
 
int m_width = 0
 
int m_precision = 0
 
format_flags m_format = {}
 
string_t m_value = {}
 

Friends

bool operator< (const stream_entry &lhs, const stream_entry &rhs)
 

Detailed Description

Definition at line 55 of file stream.hpp.

Member Typedef Documentation

◆ format_flags

using tim::data::base::stream_entry::format_flags = std::ios_base::fmtflags

Definition at line 59 of file stream.hpp.

◆ string_t

Definition at line 57 of file stream.hpp.

◆ stringstream_t

Definition at line 58 of file stream.hpp.

Constructor & Destructor Documentation

◆ stream_entry() [1/3]

tim::data::base::stream_entry::stream_entry ( int  _row = -1,
int  _col = -1,
format_flags  _fmt = {},
int  _width = 0,
int  _prec = 0,
bool  _center = false 
)
inlineexplicit

Definition at line 61 of file stream.hpp.

61 {},
62 int _width = 0, int _prec = 0, bool _center = false)
63 : m_center(_center)
64 , m_row(_row)
65 , m_column(_col)
66 , m_width(_width)
67 , m_precision(_prec)
68 , m_format(_fmt)
69 {}
format_flags m_format
Definition: stream.hpp:134
int m_width
Definition: stream.hpp:132
int m_precision
Definition: stream.hpp:133
int m_column
Definition: stream.hpp:131
bool m_center
Definition: stream.hpp:128
int m_row
Definition: stream.hpp:130

◆ ~stream_entry()

tim::data::base::stream_entry::~stream_entry ( )
default

◆ stream_entry() [2/3]

tim::data::base::stream_entry::stream_entry ( const stream_entry )
default

◆ stream_entry() [3/3]

tim::data::base::stream_entry::stream_entry ( stream_entry &&  )
default

Member Function Documentation

◆ center() [1/2]

bool tim::data::base::stream_entry::center ( ) const
inline

Definition at line 79 of file stream.hpp.

79{ return m_center; }

References m_center.

Referenced by tim::data::stream::operator()().

◆ center() [2/2]

void tim::data::base::stream_entry::center ( bool  v)
inline

Definition at line 87 of file stream.hpp.

87{ m_center = v; }

References m_center.

◆ column() [1/2]

int tim::data::base::stream_entry::column ( ) const
inline

Definition at line 83 of file stream.hpp.

83{ return m_column; }

References m_column.

Referenced by tim::data::stream::operator()().

◆ column() [2/2]

void tim::data::base::stream_entry::column ( int  v)
inline

Definition at line 91 of file stream.hpp.

91{ m_column = v; }

References m_column.

◆ construct() [1/3]

template<>
void tim::data::base::stream_entry::construct ( const timestamp_value_t val)

Definition at line 144 of file timestamp.cpp.

146{
148 ss.setf(m_format);
149 ss << std::setprecision(m_precision) << component::timestamp::as_string(val) << " / "
150 << val.time_since_epoch().count();
151 m_value = ss.str();
152 if(settings::max_width() > 0 && m_value.length() > (size_t) settings::max_width())
153 {
154 //
155 // don't truncate and add ellipsis if max width is really small
156 //
157 if(settings::max_width() > 20)
158 {
159 m_value = m_value.substr(0, settings::max_width() - 3);
160 m_value += "...";
161 }
162 else
163 {
164 m_value = m_value.substr(0, settings::max_width());
165 }
166 }
167}
max_width
Definition: settings.cpp:1645
static std::string as_string(const time_point_type &_tp)
Definition: timestamp.cpp:64
std::stringstream stringstream_t
Definition: stream.hpp:58
string_t m_value
Definition: stream.hpp:135

References tim::component::timestamp::as_string(), m_format, m_precision, m_value, and tim::max_width.

◆ construct() [2/3]

template<>
void tim::data::base::stream_entry::construct ( const timestamp_value_t val)

◆ construct() [3/3]

template<typename Tp >
void tim::data::base::stream_entry::construct ( const Tp &  val)
inline

Definition at line 98 of file stream.hpp.

99 {
101 ss.setf(m_format);
102 ss << std::setprecision(m_precision) << val;
103 m_value = ss.str();
104 if(settings::max_width() > 0 && m_value.length() > (size_t) settings::max_width())
105 {
106 //
107 // don't truncate and add ellipsis if max width is really small
108 //
109 if(settings::max_width() > 20)
110 {
111 m_value = m_value.substr(0, settings::max_width() - 3);
112 m_value += "...";
113 }
114 else
115 {
116 m_value = m_value.substr(0, settings::max_width());
117 }
118 }
119 }

References m_format, m_precision, m_value, and tim::max_width.

Referenced by tim::data::entry::entry(), and tim::data::header::header().

◆ flags()

format_flags tim::data::base::stream_entry::flags ( ) const
inline

Definition at line 85 of file stream.hpp.

85{ return m_format; }

References m_format.

Referenced by tim::data::entry::flags().

◆ get()

string_t tim::data::base::stream_entry::get ( ) const
inline

Definition at line 77 of file stream.hpp.

77{ return m_value; }

References m_value.

Referenced by tim::data::stream::operator()().

◆ left() [1/2]

bool tim::data::base::stream_entry::left ( ) const
inline

Definition at line 80 of file stream.hpp.

80{ return m_left; }
bool m_left
Definition: stream.hpp:129

References m_left.

◆ left() [2/2]

void tim::data::base::stream_entry::left ( bool  v)
inline

Definition at line 88 of file stream.hpp.

88{ m_left = v; }

References m_left.

◆ operator()()

void tim::data::base::stream_entry::operator() ( const string_t val)
inline

Definition at line 95 of file stream.hpp.

95{ m_value = val; }

References m_value.

◆ operator=() [1/2]

stream_entry & tim::data::base::stream_entry::operator= ( const stream_entry )
default

◆ operator=() [2/2]

stream_entry & tim::data::base::stream_entry::operator= ( stream_entry &&  )
default

◆ precision() [1/2]

int tim::data::base::stream_entry::precision ( ) const
inline

Definition at line 84 of file stream.hpp.

84{ return m_precision; }

References m_precision.

Referenced by tim::data::entry::precision().

◆ precision() [2/2]

void tim::data::base::stream_entry::precision ( int  v)
inline

Definition at line 92 of file stream.hpp.

92{ m_precision = v; }

References m_precision.

◆ row() [1/2]

int tim::data::base::stream_entry::row ( ) const
inline

Definition at line 81 of file stream.hpp.

81{ return m_row; }

References m_row.

Referenced by tim::data::stream::operator()().

◆ row() [2/2]

void tim::data::base::stream_entry::row ( int  v)
inline

Definition at line 89 of file stream.hpp.

89{ m_row = v; }

References m_row.

◆ setf()

void tim::data::base::stream_entry::setf ( format_flags  v)
inline

Definition at line 93 of file stream.hpp.

93{ m_format = v; }

References m_format.

Referenced by tim::data::entry::setf().

◆ width() [1/2]

int tim::data::base::stream_entry::width ( ) const
inline

Definition at line 82 of file stream.hpp.

82{ return m_width; }

References m_width.

Referenced by tim::data::stream::operator()(), and tim::data::entry::width().

◆ width() [2/2]

void tim::data::base::stream_entry::width ( int  v)
inline

Definition at line 90 of file stream.hpp.

90{ m_width = v; }

References m_width.

Friends And Related Function Documentation

◆ operator<

bool operator< ( const stream_entry lhs,
const stream_entry rhs 
)
friend

Definition at line 121 of file stream.hpp.

122 {
123 return (lhs.row() == rhs.row()) ? (lhs.column() < rhs.column())
124 : (lhs.row() < rhs.row());
125 }

Member Data Documentation

◆ m_center

bool tim::data::base::stream_entry::m_center = false
protected

Definition at line 128 of file stream.hpp.

Referenced by tim::data::entry::entry(), and center().

◆ m_column

int tim::data::base::stream_entry::m_column = 0
protected

Definition at line 131 of file stream.hpp.

Referenced by column().

◆ m_format

format_flags tim::data::base::stream_entry::m_format = {}
protected

Definition at line 134 of file stream.hpp.

Referenced by construct(), flags(), and setf().

◆ m_left

bool tim::data::base::stream_entry::m_left = false
protected

Definition at line 129 of file stream.hpp.

Referenced by tim::data::entry::entry(), and left().

◆ m_precision

int tim::data::base::stream_entry::m_precision = 0
protected

Definition at line 133 of file stream.hpp.

Referenced by construct(), and precision().

◆ m_row

int tim::data::base::stream_entry::m_row = 0
protected

Definition at line 130 of file stream.hpp.

Referenced by row().

◆ m_value

string_t tim::data::base::stream_entry::m_value = {}
protected

Definition at line 135 of file stream.hpp.

Referenced by construct(), get(), and operator()().

◆ m_width

int tim::data::base::stream_entry::m_width = 0
protected

Definition at line 132 of file stream.hpp.

Referenced by width().


The documentation for this struct was generated from the following files: