• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "exec_env.h"
16 #include "option_args.h"
17 
18 namespace OHOS {
19 namespace Media {
20 namespace MediaTool {
AppendStr(std::string & str,const std::string paramName,const int param)21 static inline void AppendStr(std::string &str, const std::string paramName, const int param)
22 {
23     if (str.empty()) {
24         str.append(paramName + ":[");
25         str.append(to_string(param));
26         str.append("]");
27     } else {
28         str.append(", " + paramName + ":[");
29         str.append(to_string(param));
30         str.append("]");
31     }
32 }
33 
AppendStr(std::string & str,const std::string paramName,const std::string param)34 static inline void AppendStr(std::string &str, const std::string paramName, const std::string param)
35 {
36     if (str.empty()) {
37         str.append(paramName + ":[");
38         str.append(param);
39         str.append("]");
40     } else {
41         str.append(", " + paramName + ":[");
42         str.append(param);
43         str.append("]");
44     }
45 }
46 
ToStr() const47 std::string ExecEnv::ToStr() const
48 {
49     std::string str;
50     if (optArgs.cmdType == OptCmdType::TYPE_LIST) {
51         AppendStr(str, "listUri", listParam.listUri);
52         AppendStr(str, "isListAll", listParam.isListAll);
53     }
54     if (optArgs.cmdType == OptCmdType::TYPE_RECV) {
55         AppendStr(str, "recvTarget", recvParam.recvTarget);
56         AppendStr(str, "recvPath", recvParam.recvPath);
57         AppendStr(str, "isRecvAll", recvParam.isRecvAll);
58         AppendStr(str, "isRecvPathDir", recvParam.isRecvPathDir);
59     }
60     if (optArgs.cmdType == OptCmdType::TYPE_SEND) {
61         AppendStr(str, "sendPath", sendParam.sendPath);
62         AppendStr(str, "isFile", sendParam.isFile);
63         AppendStr(str, "isRemoveOriginFileInSend", sendParam.isRemoveOriginFileInSend);
64         AppendStr(str, "isRemoveOriginFileInSend", sendParam.isRemoveOriginFileInSend);
65     }
66     if (optArgs.cmdType == OptCmdType::TYPE_DELETE) {
67         AppendStr(str, "isOnlyDeleteDb", deleteParam.isOnlyDeleteDb);
68     }
69     AppendStr(str, "workPath", workPath);
70     AppendStr(str, "isRoot", isRoot);
71     return str;
72 }
73 } // namespace MediaTool
74 } // namespace Media
75 } // namespace OHOS
76