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 "types/bluetooth/uuid.h" 22 #include "types/raw_address.h" 23 24 namespace bluetooth { 25 namespace test { 26 namespace headless { 27 28 class GetOpt { 29 public: 30 GetOpt(int argc, char** arv); 31 virtual ~GetOpt() = default; 32 33 virtual void Usage() const; IsValid()34 virtual bool IsValid() const { return valid_; }; 35 GetNextSubTest()36 std::string GetNextSubTest() const { 37 std::string test = non_options_.front(); 38 non_options_.pop_front(); 39 return test; 40 } 41 42 std::list<RawAddress> device_; 43 std::list<bluetooth::Uuid> uuid_; 44 unsigned long loop_{1}; 45 unsigned long msec_{0}; 46 47 bool close_stderr_{true}; 48 49 mutable std::list<std::string> non_options_; 50 51 private: 52 void ParseValue(char* optarg, std::list<std::string>& my_list); 53 void ProcessOption(int option_index, char* optarg); 54 const char* name_{nullptr}; 55 bool valid_{true}; 56 }; 57 58 } // namespace headless 59 } // namespace test 60 } // namespace bluetooth 61