1 #ifndef OST_IO_FORMATTED_LINE_HH
2 #define OST_IO_FORMATTED_LINE_HH
5 #define snprintf _snprintf
16 namespace ost {
namespace io {
61 for (
size_t i=0, e=(curr-
int(minus))/2; i<e; ++i) {
62 std::swap(
data[
int(minus)+i],
data[curr-i-1]);
91 Real rounded_val=round(val*pow(
Real(10), prec))*pow(
Real(0.1), prec);
93 bool minus=rounded_val<0;
94 rounded_val=std::abs(rounded_val);
95 int int_val=int(rounded_val);
107 for (
size_t i=0, e=(curr-
int(minus))/2; i<e; ++i) {
108 std::swap(
data[
int(minus)+i],
data[curr-i-1]);
117 rounded_val-=int(rounded_val);
120 int m=int(rounded_val);
121 rounded_val-=int(rounded_val);
146 assert(str.
length()==len_);
147 memcpy(data_, str.
data(), str.
size());
153 assert(str.
size()<=len_);
160 assert(str.
size()<=len_);
161 memcpy(data_, str.
data(), str.
size());
180 memset(data_,
' ', len_);
190 data_(new char[width]), len_(width)
197 memset(data_,
' ', len_);
203 assert(start>=0 && start+len<=static_cast<int>(len_));
207 const char*
Data()
const {
return data_; }
convenient datatype for referencing character data
LineSlice & operator=(const fmt::RPadded &str)
RPadded(const char *s, size_t l)
LineSlice & operator=(const fmt::LPadded &str)
LineSlice & operator=(const fmt::LPaddedFloat &f)
LineSlice(char *data, size_t l)
LPaddedFloat(Real val, int prec)
LineSlice & operator=(const StringRef &str)
LPadded(const char *s, size_t l)
const char * data() const
std::ostream & operator<<(std::ostream &stream, const FormattedLine &line)
LineSlice & operator=(const fmt::LPaddedInt &i)