PrevUpHomeNext

esv::wprinte


Give wild animals a free sky.

esv::wprinte - esv::print_class

esv::wprinte is the error output object of esv::print_class, wide string stream based output.

Beside that, esv::wprinte is similar to esv::wprint, see esv::wprint .

Everyone shows ecological charm everywhere.

esv::print_class

esv::print_class is a template class for all esvcpp print api.

template <esv::chara char_xt>
	requires esv::same_as<esv::remove_cvref_t<char_xt>, char_xt>
class print_class;

The esv::chara concept requires the type char_xt must be one of char, char8_t, char16_t, char32_t, wchar_t.

The "requires" concept constrains that the type char_xt must not have const and reference.

So char or wchar_t is accepted by esv::print_class template, but const char, char &, or const char &, etc. are not accepted by esv::print_class template.

Currently, only char and wchar_t are implemented by c++ standard ostream, so char8_t, char16_t, char32_t are not available for esv::print_class now.

(esv::print)

Polymorphism Friendly

esv::print_class is inheritance and polymorphism friendly. It has virtual destructor. Its member data or member functions are protected or public.

Constructors

esv::print_class constructors

A constructor of esv::print_class must initialize __sout to attach an external ostream, such as std::cout, or std::wcout at least.

4x2 constructors

////////////////////////////////////////////////////////////////////////////////
// These two constructors init to attach external ostream

print_class(ostream_type & __external_ostream__);
print_class(ofstream_type & __external_ofstream__);

////////////////////////////////////////////////////////////////////////////////
// These two constructors init to attach external ostream,
// and init the three delimiters.

print_class(
	ostream_type & __external_ostream__,
	const esv::delim_base<string_type> & __init_nested_range_delim__,
	const esv::delim_base<string_type> & __init_range_delim__,
	const esv::delim_base<string_type> & __init_value_delim__
);
print_class(
	ofstream_type & __external_ofstream__,
	const esv::delim_base<string_type> & __init_nested_range_delim__,
	const esv::delim_base<string_type> & __init_range_delim__,
	const esv::delim_base<string_type> & __init_value_delim__
);

////////////////////////////////////////////////////////////////////////////////
// These two constructors init to attach external ostream,
// and init if it prints \n at the end, 
// and if it aligns left for next line printed.


print_class(
	ostream_type & __external_ostream__,
	esv::mb __newline__,
	esv::mb __align_left__
	);
print_class(
	ofstream_type & __external_ofstream__,
	esv::mb __newline__,
	esv::mb __align_left__
);

////////////////////////////////////////////////////////////////////////////////
// These two constructors init what all above constructors can init.

print_class(
	ostream_type & __external_ostream__,
	const esv::delim_base<string_type> & __init_nested_range_delim__,
	const esv::delim_base<string_type> & __init_range_delim__,
	const esv::delim_base<string_type> & __init_value_delim__,
	esv::mb __newline__,
	esv::mb __align_left__
);
print_class(
	ofstream_type & __external_ofstream__,
	const esv::delim_base<string_type> & __init_nested_range_delim__,
	const esv::delim_base<string_type> & __init_range_delim__,
	const esv::delim_base<string_type> & __init_value_delim__,
	esv::mb __newline__,
	esv::mb __align_left__
);

Public Member Functions

List public member functions of esv::print_class. The protected members are nost listed here.

Lock and Mutex Support

esv::print_class object such as esv::print does not include any threading and mutex header, however, you can pass a mutex to esv::print, that mutex will be constrained and matched by esv::param_mutex, then the mutex will be locked and unlocked inside the esv::print calling stack.

std::mutex mutex;

start_a_thread;
// then use mutex ...
esv::print(mutex, "Hell", "World!");	// mutex will be locked and unlocked inside esv::print .

See esv::param_mutex

std::fmtflags rules

Every calling of esv::print, esv::wprint, etc., the std::boolalpha, std::fixed, and std::setprecision(10) will be set. The user-defined flags can change them, but only be kept in the current calling session, and will be lost after ending current print calling, never existed in next print calling. No matter how many times of calling esv::print, esv::wprint, etc., and no matter how the user set fmt-flags to esv::print, esv::wprint, etc., the standard output std::cout, std::cerr, std::wcout etc. will be not affected.

Public Header

#include <esvcpp/core.hpp>

Notice

[Note] Note
  • It prints a newline character at the end, but can be changed with .set_newline member function.
  • It separates each single value by a space, each range or tuple by \n, each two-dim range or tuple by \n\n, but can be changed by .set_delim member function.
  • It can print nested ranges and nested tuples, nested ranges of tuples, and nested tuples of ranges.
  • concept requirements:
    • Every single value must satisfy esv::kspt::printable or esv::kspt::printable_adapter<char_type>, char_type is a related char-type, such as char or wchar_t .
    • All single values stored in the range or tuple must satisfy printable too.
    • Basic printable types satisfy esv::kspt::printable .
    • Non-basic types must implement operator<< to satisfy esv::kspt::printable .

c++ example

#include <esvcpp/core.hpp>

int main()
{
	esv::wprinte(L"Hello", true, 2023, L"c++!");
}

See Also

esv::print

esv::printe

esv::printnl

esv::wprint

esv::wprintnl


PrevUpHomeNext

esv::print