1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
10 class codecvt : public std::codecvt<char, char, mbstate_t>
22 #ifndef CMAKE_BOOTSTRAP
28 bool do_always_noconv() const noexcept override;
29 result do_out(mbstate_t& state, const char* from, const char* from_end,
30 const char*& from_next, char* to, char* to_end,
31 char*& to_next) const override;
32 result do_unshift(mbstate_t& state, char* to, char*,
33 char*& to_next) const override;
34 int do_max_length() const noexcept override;
35 int do_encoding() const noexcept override;
38 // The mbstate_t argument to do_out and do_unshift is responsible
39 // for storing state between calls. We cannot control the type
40 // since we want to imbue on standard streams. However, we do
41 // know that it is a trivial type. Define our own type to overlay
42 // on it safely with no alignment requirements.
45 // Buffer bytes we have consumed from a partial codepoint.
48 // Number of bytes we have buffered from a partial codepoint.
49 unsigned char buffered : 4;
51 // Size of the current codepoint in bytes.
52 unsigned char size : 4;
57 unsigned int m_codepage;
58 result Decode(mbstate_t& state, int need, const char*& from_next,
59 char*& to_next, char* to_end) const;
60 result DecodePartial(mbstate_t& state, char*& to_next, char* to_end) const;
61 void BufferPartial(mbstate_t& state, int need, const char*& from_next) const;