* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_BASE_ZCHAR_WRAPPER_H
#define OHOS_ABILITY_BASE_ZCHAR_WRAPPER_H
#include "base_obj.h"
#include "refbase.h"
namespace OHOS {
namespace AAFwk {
class Char final : public Object, public IChar {
public:
Char(zchar value) : value_(value)
{}
~Char()
{}
IINTERFACE_DECL();
ErrCode GetValue(zchar &value) override;
bool Equals(IObject &other) override;
std::string ToString() override;
static sptr<IChar> Box(zchar value);
static zchar Unbox(IChar *object);
static sptr<IChar> Parse(const std::string &str);
static int GetByteSize(zchar c);
static void WriteUTF8Bytes(char *dst,
zchar c,
int size);
static zchar GetChar(const std::string &str,
int index);
static constexpr char SIGNATURE = 'C';
static constexpr zchar INVALID_CHAR = 0x110000;
private:
static zchar GetCharInternal(const unsigned char *cur,
unsigned int &size);
static constexpr int MAX_CODE_POINT = 0x10FFFF;
static constexpr int MIN_HIGH_SURROGATE = 0xD800;
static constexpr int MAX_LOW_SURROGATE = 0xDFFF;
static constexpr int BYTE_COUNT_1 = 1;
static constexpr int BYTE_COUNT_2 = 2;
static constexpr int BYTE_COUNT_3 = 3;
static constexpr int BYTE_COUNT_4 = 4;
static constexpr zchar BYTE_MASK = 0x000000BF;
static constexpr zchar BYTE_MARK = 0x00000080;
static constexpr int BYTE_SHIFT = 6;
static constexpr zchar FIRST_BYTE_MARK[] = {0x00000000, 0x00000000, 0x000000C0, 0x000000E0, 0x000000F0};
zchar value_;
};
}
}
#endif