• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstddef>
20 #include <list>
21 #include <string>
22 #include "types/bluetooth/uuid.h"
23 #include "types/raw_address.h"
24 
25 namespace bluetooth {
26 namespace test {
27 namespace headless {
28 
29 class GetOpt {
30  public:
31   GetOpt(int argc, char** arv);
32   virtual ~GetOpt();
33 
34   virtual void Usage() const;
IsValid()35   virtual bool IsValid() const { return valid_; };
36 
GetNextSubTest()37   std::string GetNextSubTest() const {
38     std::string test = non_options_.front();
39     non_options_.pop_front();
40     return test;
41   }
42 
43   const char** StackInitFlags() const;
44 
45   std::list<RawAddress> device_;
46   std::list<std::string> init_flags_;
47   std::list<bluetooth::Uuid> uuid_;
48   unsigned long loop_{1};
49   unsigned long msec_{0};
50 
51   bool close_stderr_{true};
52   bool clear_logcat_{false};
53 
54   mutable std::list<std::string> non_options_;
55 
56   static std::vector<std::string> Split(std::string);
57 
58  private:
59   void ParseValue(char* optarg, std::list<std::string>& my_list);
60   void ProcessOption(int option_index, char* optarg);
61   void ParseStackInitFlags();
62   const char* name_{nullptr};
63   const char** stack_init_flags_{nullptr};
64   bool valid_{true};
65 };
66 
67 }  // namespace headless
68 }  // namespace test
69 }  // namespace bluetooth
70