1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef UTIL_H 16 #define UTIL_H 17 18 #include <map> 19 #include <string> 20 #include <ctime> 21 #include <vector> 22 #include "struct_multimodal.h" 23 #include "define_multimodal.h" 24 25 namespace OHOS { 26 namespace MMI { 27 const char *GetMmiErrorTypeDesc(int32_t errorCodeEnum); 28 std::string GetEnv(const std::string& name); 29 std::string UuIdGenerate(); 30 int64_t GetMicrotime(); 31 int64_t GetSysClockTime(); 32 int64_t GetMillisTime(); 33 std::string GetUUid(); 34 std::string GetThisThreadIdOfString(); 35 uint64_t GetThisThreadIdOfLL(); 36 size_t StringToken(std::string& str, const std::string& sep, std::string& token); 37 size_t StringSplit(const std::string& str, const std::string& sep, std::vector<std::string>& vecList); 38 std::string IdsListToString(const std::vector<int32_t>& list, const std::string& sep); 39 void LocalTime(tm& t, time_t curTime = 0); 40 std::string Strftime(const std::string& format = "%F %T", time_t curTime = 0); 41 void PrintEventJoyStickAxisInfo(const EventJoyStickAxis& r, const int32_t fd, 42 const int32_t abilityId, const int32_t focusId, const int64_t preHandlerTime); 43 void PrintWMSInfo(const std::string& str, const int32_t fd, const int32_t abilityId, const int32_t focusId); 44 int32_t GetPid(); 45 std::string GetFileName(const std::string& strPath); 46 const char* GetProgramName(); 47 char* MmiBasename(char* path); 48 void SetThreadName(const std::string& name); 49 const std::string& GetThreadName(); 50 void AddId(std::vector<int32_t> &list, int32_t id); 51 size_t CalculateDifference(const std::vector<int32_t> &list1, std::vector<int32_t> &list2, 52 std::vector<int32_t> &difList); 53 std::string StringFmt(const char* str, ...); 54 } // namespace MMI 55 } // namespace OHOS 56 57 #endif // UTIL_H 58