1 /* 2 * Copyright (C) 2024 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 PARAM_PARSING_H 17 #define PARAM_PARSING_H 18 19 #include <napi_api.h> 20 21 #include <base/containers/string.h> 22 23 /** 24 * @brief Extract node path from SceneNodeParameters args. 25 * @param sceneNodeParameters a JS object that fulfills the SceneNodeParameters interface. 26 * @return If the path member is set, return that. Otherwise return the name member. 27 */ 28 BASE_NS::string ExtractNodePath(NapiApi::Object sceneNodeParameters); 29 30 /** 31 * @brief Extract name from SceneNodeParameters args. 32 * @param sceneNodeParameters a JS object that fulfills the SceneNodeParameters interface. 33 * @return The name member. 34 */ 35 BASE_NS::string ExtractName(NapiApi::Object sceneNodeParameters); 36 37 /** 38 * @brief Extract URI from a Resource arg. 39 * @param resource a JS object that fulfills the Resource interface. 40 * @return The URI or an empty string if no URI is found. 41 */ 42 BASE_NS::string ExtractUri(NapiApi::FunctionContext<>& ctx); 43 44 /** 45 * @brief Extract URI from a Resource arg. 46 * @param resource a JS object that fulfills the Resource interface. 47 * @return The URI or an empty string if no URI is found. 48 */ 49 BASE_NS::string ExtractUri(NapiApi::Object resource); 50 51 /** 52 * @brief Extract URI from a Resource arg. 53 * @param resource a JS object that fulfills the Resource interface. 54 * @return The URI or an empty string if no URI is found. 55 */ 56 BASE_NS::string ExtractUri(BASE_NS::string uri); 57 58 59 #endif 60