1 /* 2 * Copyright (c) 2023 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 16 #ifndef DATASHARESERVICE_URI_UTILS_H 17 #define DATASHARESERVICE_URI_UTILS_H 18 19 #include <string> 20 namespace OHOS::DataShare { 21 struct UriInfo { 22 std::string bundleName; 23 std::string moduleName; 24 std::string storeName; 25 std::string tableName; 26 }; 27 28 class URIUtils { 29 public: 30 static bool GetInfoFromURI(const std::string &uri, UriInfo &uriInfo); 31 static bool GetBundleNameFromProxyURI(const std::string &uri, std::string &bundleName); 32 static bool GetInfoFromProxyURI( 33 const std::string &uri, int32_t &user, uint32_t &callerTokenId, std::string &calledBundleName); 34 static bool IsDataProxyURI(const std::string &uri); 35 static constexpr const char *DATA_SHARE_SCHEMA = "datashare:///";; 36 static constexpr const char DATA_PROXY_SCHEMA[] = "datashareproxy://"; 37 static constexpr int DATA_PROXY_SCHEMA_LEN = sizeof(DATA_PROXY_SCHEMA) - 1; 38 39 private: 40 enum PATH_PARAM : int32_t { 41 BUNDLE_NAME = 0, 42 MODULE_NAME, 43 STORE_NAME, 44 TABLE_NAME, 45 PARAM_SIZE 46 }; 47 }; 48 } // namespace OHOS::DataShare 49 #endif // DATASHARESERVICE_URI_UTILS_H 50