|
1 /* |
|
2 * Copyright 2006 Intel Corporation |
|
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 #ifndef _ENDPOINTIDOPT_H_ |
|
18 #define _ENDPOINTIDOPT_H_ |
|
19 |
|
20 #include <string> |
|
21 #include <vector> |
|
22 |
|
23 #include "dtn_types.h" |
|
24 #include <oasys/util/Options.h> |
|
25 |
|
26 namespace dtn { |
|
27 |
|
28 /** |
|
29 * Extension class to the oasys Opt hierarchy that validates that the |
|
30 * option is a DTN endpoint identifier (i.e. a URI). |
|
31 */ |
|
32 class APIEndpointIDOpt : public oasys::Opt { |
|
33 public: |
|
34 /** |
|
35 * Basic constructor. |
|
36 * |
|
37 * @param opt the option string |
|
38 * @param valp pointer to the value |
|
39 * @param valdesc short description for the value |
|
40 * @param desc descriptive string |
|
41 * @param setp optional pointer to indicate whether or not |
|
42 the option was set |
|
43 */ |
|
44 APIEndpointIDOpt(const char* opt, dtn_endpoint_id_t* valp, |
|
45 const char* valdesc = "", const char* desc = "", |
|
46 bool* setp = NULL); |
|
47 |
|
48 /** |
|
49 * Alternative constructor with both short and long options, |
|
50 * suitable for getopt calls. |
|
51 * |
|
52 * @param shortopt short option character |
|
53 * @param longopt long option string |
|
54 * @param valp pointer to the value |
|
55 * @param valdesc short description for the value |
|
56 * @param desc descriptive string |
|
57 * @param setp optional pointer to indicate whether or not |
|
58 the option was set |
|
59 */ |
|
60 APIEndpointIDOpt(char shortopt, const char* longopt, |
|
61 dtn_endpoint_id_t* valp, |
|
62 const char* valdesc = "", const char* desc = "", |
|
63 bool* setp = NULL); |
|
64 |
|
65 protected: |
|
66 int set(const char* val, size_t len); |
|
67 void get(oasys::StringBuffer* buf); |
|
68 }; |
|
69 |
|
70 } // namespace dtn |
|
71 |
|
72 #endif /* _ENDPOINTIDOPT_H_ */ |