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 COMMAND_LEXER_H
17 #define COMMAND_LEXER_H
18 
19 #include <string>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace AppSpawn {
24 
25 class CommandLexer {
26 public:
CommandLexer(const std::string & str)27     explicit CommandLexer(const std::string &str) : str_(str) {}
28     // Disable copy and move semantics to avoid extension of the lifecyle of the
29     // resource not owned by this class.
30     CommandLexer(const CommandLexer &other) = delete;
31     CommandLexer(CommandLexer &&other) = delete;
32     CommandLexer &operator=(const CommandLexer &other) = delete;
33     CommandLexer &operator=(CommandLexer &&other) = delete;
34     // Return true, and args will be populated with all argument. Otherwise,
35     // false is returned, and args will be cleared.
36     bool GetAllArguments(std::vector<std::string> &args);
37 
38 private:
39     const std::string &str_;
40 };
41 
42 } // namespace AppSpawn
43 } // namespace OHOS
44 
45 #endif // COMMAND_LEXER_H
46