49 lines · c
1//===-- Definition of a class for mbstate_t and conversion -----*-- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_SRC___SUPPORT_CHARACTER_CONVERTER_H10#define LLVM_LIBC_SRC___SUPPORT_CHARACTER_CONVERTER_H11 12#include "hdr/types/char32_t.h"13#include "hdr/types/char8_t.h"14#include "hdr/types/size_t.h"15#include "src/__support/CPP/type_traits.h"16#include "src/__support/common.h"17#include "src/__support/error_or.h"18#include "src/__support/wchar/mbstate.h"19 20namespace LIBC_NAMESPACE_DECL {21namespace internal {22 23class CharacterConverter {24private:25 mbstate *state;26 27public:28 CharacterConverter(mbstate *mbstate);29 30 void clear();31 bool isFull();32 bool isEmpty();33 bool isValidState();34 35 template <typename CharType> size_t sizeAs();36 37 int push(char8_t utf8_byte);38 int push(char32_t utf32);39 40 ErrorOr<char8_t> pop_utf8();41 ErrorOr<char32_t> pop_utf32();42 template <typename CharType> ErrorOr<CharType> pop();43};44 45} // namespace internal46} // namespace LIBC_NAMESPACE_DECL47 48#endif // LLVM_LIBC_SRC___SUPPORT_CHARACTER_CONVERTER_H49