HelenOS sources
This source file includes following definitions.
- flags
- flags
- setf
- setf
- unsetf
- precision
- precision
- width
- width
- imbue
- getloc
- iword
- pword
- register_callback
- boolalpha
- noboolalpha
- showbase
- noshowbase
- showpoint
- noshowpoint
- showpos
- noshowpos
- skipws
- noskipws
- uppercase
- nouppercase
- unitbuf
- nounitbuf
- internal
- left
- right
- dec
- hex
- oct
- fixed
- scientific
- hexfloat
- defaultfloat
#include <ios>
namespace std
{
int ios_base::index_{};
bool ios_base::sync_{true};
long ios_base::ierror_{0};
void* ios_base::perror_{nullptr};
ios_base::ios_base()
: iarray_{}, parray_{}, iarray_size_{}, parray_size_{},
flags_{}, precision_{}, width_{}, locale_{},
callbacks_{}
{ }
ios_base::~ios_base()
{
for (auto& callback: callbacks_)
callback.first(erase_event, *this, callback.second);
}
auto ios_base::flags() const -> fmtflags
{
return flags_;
}
auto ios_base::flags(fmtflags fmtfl) -> fmtflags
{
auto old = flags_;
flags_ = fmtfl;
return old;
}
auto ios_base::setf(fmtflags fmtfl) -> fmtflags
{
auto old = flags_;
flags_ |= fmtfl;
return old;
}
auto ios_base::setf(fmtflags fmtfl, fmtflags mask) -> fmtflags
{
auto old = flags_;
flags_ &= ~mask;
flags_ |= fmtfl & mask;
return old;
}
void ios_base::unsetf(fmtflags fmtfl)
{
flags_ &= ~fmtfl;
}
streamsize ios_base::precision() const
{
return precision_;
}
streamsize ios_base::precision(streamsize prec)
{
auto old = precision_;
precision_ = prec;
return old;
}
streamsize ios_base::width() const
{
return width_;
}
streamsize ios_base::width(streamsize wide)
{
auto old = width_;
width_ = wide;
return old;
}
locale ios_base::imbue(const locale& loc)
{
auto old = locale_;
locale_ = loc;
for (auto& callback: callbacks_)
callback.first(imbue_event, *this, callback.second);
return old;
}
locale ios_base::getloc() const
{
return locale_;
}
long& ios_base::iword(int index)
{
if (!iarray_)
{
iarray_ = new long[initial_size_];
iarray_size_ = initial_size_;
}
auto idx = static_cast<size_t>(index);
if (idx > iarray_size_)
{
size_t new_size = max(iarray_size_ * 2, idx + 1);
auto tmp = new long[new_size];
for (size_t i = 0; i < iarray_size_; ++i)
tmp[i] = iarray_[i];
for (size_t i = iarray_size_; i < new_size; ++i)
tmp[i] = 0;
swap(tmp, iarray_);
delete[] tmp;
iarray_size_ = new_size;
return iarray_[idx];
}
else
return iarray_[idx];
return ierror_;
}
void*& ios_base::pword(int index)
{
if (!parray_)
{
parray_ = new void*[initial_size_];
parray_size_ = initial_size_;
}
auto idx = static_cast<size_t>(index);
if (idx > parray_size_)
{
size_t new_size = max(parray_size_ * 2, idx + 1);
auto tmp = new void*[new_size];
for (size_t i = 0; i < parray_size_; ++i)
tmp[i] = parray_[i];
for (size_t i = parray_size_; i < new_size; ++i)
tmp[i] = nullptr;
swap(tmp, parray_);
delete[] tmp;
parray_size_ = new_size;
return parray_[idx];
}
else
return parray_[idx];
return perror_;
}
void ios_base::register_callback(event_callback fn, int index)
{
callbacks_.emplace_back(fn, index);
}
ios_base& boolalpha(ios_base& str)
{
str.setf(ios_base::boolalpha);
return str;
}
ios_base& noboolalpha(ios_base& str)
{
str.unsetf(ios_base::boolalpha);
return str;
}
ios_base& showbase(ios_base& str)
{
str.setf(ios_base::showbase);
return str;
}
ios_base& noshowbase(ios_base& str)
{
str.unsetf(ios_base::showbase);
return str;
}
ios_base& showpoint(ios_base& str)
{
str.setf(ios_base::showpoint);
return str;
}
ios_base& noshowpoint(ios_base& str)
{
str.unsetf(ios_base::showpoint);
return str;
}
ios_base& showpos(ios_base& str)
{
str.setf(ios_base::showpos);
return str;
}
ios_base& noshowpos(ios_base& str)
{
str.unsetf(ios_base::showpos);
return str;
}
ios_base& skipws(ios_base& str)
{
str.setf(ios_base::skipws);
return str;
}
ios_base& noskipws(ios_base& str)
{
str.unsetf(ios_base::skipws);
return str;
}
ios_base& uppercase(ios_base& str)
{
str.setf(ios_base::uppercase);
return str;
}
ios_base& nouppercase(ios_base& str)
{
str.unsetf(ios_base::uppercase);
return str;
}
ios_base& unitbuf(ios_base& str)
{
str.setf(ios_base::unitbuf);
return str;
}
ios_base& nounitbuf(ios_base& str)
{
str.unsetf(ios_base::unitbuf);
return str;
}
ios_base& internal(ios_base& str)
{
str.setf(ios_base::internal, ios_base::adjustfield);
return str;
}
ios_base& left(ios_base& str)
{
str.setf(ios_base::left, ios_base::adjustfield);
return str;
}
ios_base& right(ios_base& str)
{
str.setf(ios_base::right, ios_base::adjustfield);
return str;
}
ios_base& dec(ios_base& str)
{
str.setf(ios_base::dec, ios_base::basefield);
return str;
}
ios_base& hex(ios_base& str)
{
str.setf(ios_base::hex, ios_base::basefield);
return str;
}
ios_base& oct(ios_base& str)
{
str.setf(ios_base::oct, ios_base::basefield);
return str;
}
ios_base& fixed(ios_base& str)
{
str.setf(ios_base::fixed, ios_base::floatfield);
return str;
}
ios_base& scientific(ios_base& str)
{
str.setf(ios_base::scientific, ios_base::floatfield);
return str;
}
ios_base& hexfloat(ios_base& str)
{
str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
return str;
}
ios_base& defaultfloat(ios_base& str)
{
str.unsetf(ios_base::floatfield);
return str;
}
}
HelenOS homepage, sources at GitHub