STD::__CODECVT_ABSTRACT_BASE(3)

πŸ“¦
version 16.2.1+r23+gd564253eb6c8 Β· 7 versions
, in arch rolling, fedora 43, fedora 44

✨ 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 from codecvt_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 from extern_type to intern_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 __max of 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 to 0, iconic
  • virtual bool do_always_noconv () const throw () =0 β€” pure virtual, you must implement it, no exceptions (literally, it's throw ()) πŸ™ˆ
  • 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 __old defaulting to 0 πŸŽ€
  • 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 an LC_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