/* * 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_ARRAY_WRAPPER_H #define OHOS_ABILITY_BASE_ARRAY_WRAPPER_H #include #include #include "base_obj.h" namespace OHOS { namespace AAFwk { class Array : public Object, public IArray { public: Array(long size, const InterfaceID &id); inline ~Array() {} IINTERFACE_DECL(); ErrCode Get(long index, /* [in] */ sptr &value) override; /* [out] */ ErrCode GetLength(long &size) override; /* [out] */ ErrCode GetType(InterfaceID &id) override; /* [out] */ ErrCode Set(long index, /* [in] */ IInterface *value) override; /* [in] */ bool Equals(IObject &other) override; /* [in] */ std::string ToString() override; static sptr Parse(const std::string &arrayStr); /* [in] */ static bool IsBooleanArray(IArray *array); /* [in] */ static bool IsCharArray(IArray *array); /* [in] */ static bool IsByteArray(IArray *array); /* [in] */ static bool IsShortArray(IArray *array); /* [in] */ static bool IsIntegerArray(IArray *array); /* [in] */ static bool IsLongArray(IArray *array); /* [in] */ static bool IsFloatArray(IArray *array); /* [in] */ static bool IsDoubleArray(IArray *array); /* [in] */ static bool IsStringArray(IArray *array); /* [in] */ static bool IsWantParamsArray(IArray *array); /* [in] */ static void ForEach(IArray *array, /* [in] */ std::function func); /* [in] */ static constexpr char SIGNATURE = '['; private: static void ParseElement(IArray *array, /* [in] */ std::function(std::string &)> func, /* [in] */ const std::string &values, /* [in] */ long size); /* [in] */ std::vector> values_; long size_; InterfaceID typeId_; static sptr ParseString(const std::string &values, long size); static sptr ParseBoolean(const std::string &values, long size); static sptr ParseByte(const std::string &values, long size); static sptr ParseShort(const std::string &values, long size); static sptr ParseInteger(const std::string &values, long size); static sptr ParseLong(const std::string &values, long size); static sptr ParseFloat(const std::string &values, long size); static sptr ParseDouble(const std::string &values, long size); static sptr ParseChar(const std::string &values, long size); static sptr ParseArray(const std::string &values, long size); static sptr ParseWantParams(const std::string &values, long size); }; } // namespace AAFwk } // namespace OHOS #endif // OHOS_ABILITY_BASE_ARRAY_WRAPPER_H