1 /* 2 * Copyright (c) 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 16 #ifndef OHOS_ABILITY_RUNTIME_SHELL_CMD_RESULT_H 17 #define OHOS_ABILITY_RUNTIME_SHELL_CMD_RESULT_H 18 19 #include <string> 20 #include "shell_command_result.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 class ShellCmdResult { 25 public: 26 /** 27 * Default constructor used to create a ShellCmdResult instance. 28 */ 29 ShellCmdResult() = default; 30 31 /** 32 * A constructor used to create a ShellCmdResult instance with the input parameter passed. 33 * 34 * @param exitCode Indicates the shell cmd exec result. 35 * @param stdResult Indicates the cmd standard result. 36 */ 37 ShellCmdResult(const int32_t exitCode, const std::string &stdResult); 38 39 /** 40 * Copy constructor used to create a ShellCmdResult instance with the input parameter passed. 41 * 42 * @param result Indicates the ShellCommandResult object that already exists. 43 */ 44 explicit ShellCmdResult(const AAFwk::ShellCommandResult &result); 45 46 /** 47 * Default deconstructor used to deconstruct. 48 */ 49 ~ShellCmdResult() = default; 50 51 /** 52 * Sets exit code. 53 * 54 * @param exitCode Indicates the exit code. 55 */ 56 void SetExitCode(const int32_t exitCode); 57 58 /** 59 * Obtains the exit code. 60 * 61 * @return the exit code. 62 */ 63 int32_t GetExitCode() const; 64 65 /** 66 * Sets standard result. 67 * 68 * @param stdResult Indicates the standard result. 69 */ 70 void SetStdResult(const std::string &stdResult); 71 72 /** 73 * Obtains the standard result. 74 * 75 * @return the standard result. 76 */ 77 std::string GetStdResult() const; 78 79 /** 80 * Returns a string representation of the object. 81 * 82 * @return a string representation of the object. 83 */ 84 std::string Dump(); 85 86 private: 87 int32_t exitCode_ {-1}; 88 std::string stdResult_; 89 }; 90 } // namespace AppExecFwk 91 } // namespace OHOS 92 93 #endif // OHOS_ABILITY_RUNTIME_SHELL_CMD_RESULT_H 94