STD::__CODECVT_ABSTRACT_BASE(3)
β¨ NAME β¨
okay bestie, so this is std::__codecvt_abstract_base< _InternT, _ExternT, _StateT > β the common base for codecvt functions π
and like, this whole thing lives in the Library Functions Manual (the libstdc++ one, iykyk), so consider this your backstage pass π
π¦ SYNOPSIS π¦
#include <locale>
Inherits std::locale::facet, and std::codecvt_base.
Inherited by std::codecvt< char_type, char, __state_type >, and std::codecvt< _InternT, _ExternT, _StateT >.
πΈ Public Types πΈ
typedef _ExternT extern_typeβ the outside-world char type, the one the rest of the world speaks π«Άtypedef _InternT intern_typeβ the inside-our-house char type, the one we speak β¨typedef codecvt_base::result resultβ the result enum, borrowed straight fromcodecvt_baseπtypedef _StateT state_typeβ the state type, for when conversion has β¨memoryβ¨
π Public Member Functions π
bool always_noconv () const throw ()β does this facet just... not convert? asks the question, throws nothing πint encoding () const throw ()β how many extern chars per intern char, basically. throws nothing π₯result in (state_type &__state, const extern_type *__from, const extern_type *__from_end, const extern_type *&__from_next, intern_type *__to, intern_type *__to_end, intern_type *&__to_next) constβ Convert from external to internal character set. the glow-up goes fromextern_typetointern_typeπ¦int length (state_type &__state, const extern_type *__from, const extern_type *__end, size_t __max) constβ how long is this input, in intern chars, max__maxof them βint max_length () const throw ()β the absolute most extern chars one intern char could ever need. throws nothing πresult out (state_type &__state, const intern_type *__from, const intern_type *__from_end, const intern_type *&__from_next, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ Convert from internal to external character set. the other direction, no cap πresult unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ Reset conversion state. getting that state back to factory settings π
π§ Protected Member Functions π§
__codecvt_abstract_base (size_t __refs=0)β the constructor, refs default to0, iconicvirtual bool do_always_noconv () const throw () =0β pure virtual, you must implement it, no exceptions (literally, it'sthrow ()) πvirtual int do_encoding () const throw () =0β pure virtual, implement it or perish πvirtual result do_in (state_type &__state, const extern_type *__from, const extern_type *__from_end, const extern_type *&__from_next, intern_type *__to, intern_type *__to_end, intern_type *&__to_next) const =0β pure virtual, the actual externalβinternal work πΈvirtual int do_length (state_type &, const extern_type *__from, const extern_type *__end, size_t __max) const =0β pure virtual, note the first param is unnamed, it said "we don't need to name it, we know what it is" πvirtual int do_max_length () const throw () =0β pure virtual, max length, throws nothing πvirtual result do_out (state_type &__state, const intern_type *__from, const intern_type *__from_end, const intern_type *&__from_next, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) const =0β Convert from internal to external character set. pure virtual π₯virtual result do_unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) const =0β pure virtual, reset that state β¨
β Static Protected Member Functions β
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()β clone the C locale, throws nothing π«Άstatic void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)β make a C locale from__s, with__olddefaulting to0πstatic void _S_destroy_c_locale (__c_locale &__cloc)β bye bye locale, destroy it πstatic __c_locale _S_get_c_locale ()β grab the C locale πΈstatic const char * _S_get_c_name () throw ()β get the C locale's name, throws nothing βstatic __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)β build anLC_CTYPE-flavoured C locale from__sπ¦
π₯ Detailed Description π₯
template<typename _InternT, typename _ExternT, typename _StateT>
class std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >
"Common base for codecvt functions."
no fr, that's the vibe. so here's the tea β:
This template class provides implementations of the public functions that forward to the protected virtual functions. π«
This template also provides abstract stubs for the protected virtual functions. (stubs = "you go implement that, bestie, i'm just the blueprint") π
π Member Function Documentation π
π do_out
template<typename _InternT, typename _ExternT, typename _StateT> virtual
result std::__codecvt_abstract_base< _InternT, _ExternT, _StateT
>::do_out (state_type & __state, const intern_type * __from, const
intern_type * __from_end, const intern_type *& __from_next, extern_type
* __to, extern_type * __to_end, extern_type *& __to_next) const
[protected], [pure virtual]
Convert from internal to external character set. Converts input string of intern_type to output string of extern_type. This function is a hook for derived classes to change the value returned. πͺβ¨
See also
out for more information.
Implemented in std::codecvt< _InternT, _ExternT, _StateT >, std::codecvt< _Elem, char, mbstate_t >, std::codecvt< _InternT, _ExternT, encoding_state >, std::codecvt< char, char, mbstate_t >, std::codecvt< char16_t, char, mbstate_t >, std::codecvt< char32_t, char, mbstate_t >, and std::codecvt< wchar_t, char, mbstate_t >. π
Referenced by out().
π in
template<typename _InternT, typename _ExternT, typename _StateT> result
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::in
(state_type & __state, const extern_type * __from, const extern_type *
__from_end, const extern_type *& __from_next, intern_type * __to,
intern_type * __to_end, intern_type *& __to_next) const [inline]
Convert from external to internal character set. Converts input string of extern_type to output string of intern_type. This is analogous to mbsrtowcs. It does this by calling codecvt::do_in. π¦
The source and destination character sets are determined by the facet's locale, internal and external types. πΈ
The characters in [from,from_end) are converted and written to [to,to_end). from_next and to_next are set to point to the character following the last successfully converted character, respectively. If the result needed no conversion, from_next and to_next are not affected. β
The state argument should be initialized if the input is at the beginning and carried from a previous call if continuing conversion. There are no guarantees about how state is used. (no cap, that's literally what it says π)
The result returned is a member of codecvt_base::result. If all the input is converted, returns codecvt_base::ok. If no conversion is necessary, returns codecvt_base::noconv. If the input ends early or there is insufficient space in the output, returns codecvt_base::partial. Otherwise the conversion failed and codecvt_base::error is returned. π
Parameters
__stateβ Persistent conversion state data.__fromβ Start of input.__from_endβ End of input.__from_nextβ Returns start of unconverted data.__toβ Start of output buffer.__to_endβ End of output buffer.__to_nextβ Returns start of unused output area.
Returns
codecvt_base::result.
π out
template<typename _InternT, typename _ExternT, typename _StateT> result
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::out
(state_type & __state, const intern_type * __from, const intern_type *
__from_end, const intern_type *& __from_next, extern_type * __to,
extern_type * __to_end, extern_type *& __to_next) const [inline]
Convert from internal to external character set. Converts input string of intern_type to output string of extern_type. This is analogous to wcsrtombs. It does this by calling codecvt::do_out. π₯
The source and destination character sets are determined by the facet's locale, internal and external types. πΈ
The characters in [from,from_end) are converted and written to [to,to_end). from_next and to_next are set to point to the character following the last successfully converted character, respectively. If the result needed no conversion, from_next and to_next are not affected. β
The state argument should be initialized if the input is at the beginning and carried from a previous call if continuing conversion. There are no guarantees about how state is used. (same energy as before, it's giving "trust me bro" π)
The result returned is a member of codecvt_base::result. If all the input is converted, returns codecvt_base::ok. If no conversion is necessary, returns codecvt_base::noconv. If the input ends early or there is insufficient space in the output, returns codecvt_base::partial. Otherwise the conversion failed and codecvt_base::error is returned. π
Parameters
__stateβ Persistent conversion state data.__fromβ Start of input.__from_endβ End of input.__from_nextβ Returns start of unconverted data.__toβ Start of output buffer.__to_endβ End of output buffer.__to_nextβ Returns start of unused output area.
Returns
codecvt_base::result.
References do_out().
π unshift
template<typename _InternT, typename _ExternT, typename _StateT> result
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::unshift
(state_type & __state, extern_type * __to, extern_type * __to_end,
extern_type *& __to_next) const [inline]
Reset conversion state. Writes characters to output that would restore state to initial conditions. The idea is that if a partial conversion occurs, then the converting the characters written by this function would leave the state in initial conditions, rather than partial conversion state. It does this by calling codecvt::do_unshift(). β¨
For example, if 4 external characters always converted to 1 internal character, and input to in() had 6 external characters with state saved, this function would write two characters to the output and set the state to initialized conditions. π§ β¨
The source and destination character sets are determined by the facet's locale, internal and external types. πΈ
The result returned is a member of codecvt_base::result. If the state could be reset and data written, returns codecvt_base::ok. If no conversion is necessary, returns codecvt_base::noconv. If the output has insufficient space, returns codecvt_base::partial. Otherwise the reset failed and codecvt_base::error is returned. π
Parameters
__stateβ Persistent conversion state data.__toβ Start of output buffer.__to_endβ End of output buffer.__to_nextβ Returns start of unused output area.
Returns
codecvt_base::result.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. so no, a human did not hand-write this beautiful mess, the robots did π€π
and that's the whole page bestie!! it's libstdc++, it's the Library Functions Manual, and the source is the source code itself β generated automatically by Doxygen for libstdc++. go forth and convert characters responsibly π¦πβ¨
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 43: libstdc++-docs 15.2.1-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.3.1-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms