PrevUpHomeNext

utx::wprint


utx::wprint - utx::print_class

utx::wprint is the class object of template class utx::print_class, to print many different printable values to std::wostream based stream. The values to be printed must satisfy utx::wprintable to be printed by utx::wprint.

utx::wprint is similar to utx::print, see utx::print .

utx::print_class

utx::print_class is a template class

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

The utx::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 utx::print_class template, but const char, char &, or const char &, etc. are not accepted by utx::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 utx::print_class now.

Polymorphism Friendly

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

Constructors

utx::print_class constructors

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

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 utx::delim_base<string_type> & __init_nested_range_delim__,
	const utx::delim_base<string_type> & __init_range_delim__,
	const utx::delim_base<string_type> & __init_value_delim__
);
print_class(
	ofstream_type & __external_ofstream__,
	const utx::delim_base<string_type> & __init_nested_range_delim__,
	const utx::delim_base<string_type> & __init_range_delim__,
	const utx::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__,
	utx::mb __newline__,
	utx::mb __align_left__
	);
print_class(
	ofstream_type & __external_ofstream__,
	utx::mb __newline__,
	utx::mb __align_left__
);

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

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

Public Member Functions

Lock and Mutex Support

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

std::mutex mutex;

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

See utx::param_mutex

std::fmtflags rules

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

Public Header

#include <utxcpp/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 utx::kspt::printable or utx::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 utx::kspt::printable .
    • Non-basic types must implement operator<< to satisfy utx::kspt::printable .

c++ example

#include <utxcpp/core.hpp>

int main()
{
	utx::wprint(L"Hello", 2023, L"c++!", true, L'M');
}

See Also

utx::print

utx::printe

utx::printnl

utx::wprinte

utx::wprintnl


PrevUpHomeNext

utx::print