1 /*
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
54
55 class MemorySizeArgument {
56 public:
57 u8 _size;
58 u8 _val;
59 char _multiplier;
60 };
61
62 class GenDCmdArgument : public ResourceObj {
63 protected:
64 GenDCmdArgument* _next;
65 const char* const _name;
66 const char* const _description;
67 const char* const _type;
68 const char* const _default_string;
69 bool _is_set;
70 const bool _is_mandatory;
71 bool _allow_multiple;
72 GenDCmdArgument(const char* name, const char* description, const char* type,
73 const char* default_string, bool mandatory)
74 : _next(NULL)
75 , _name(name)
76 , _description(description)
77 , _type(type)
78 , _default_string(default_string)
79 , _is_set(false)
80 , _is_mandatory(mandatory)
81 , _allow_multiple(false) {}
82
83 public:
84 const char* name() const { return _name; }
85 const char* description() const { return _description; }
86 const char* type() const { return _type; }
87 const char* default_string() const { return _default_string; }
88 bool is_set() const { return _is_set; }
89 void set_is_set(bool b) { _is_set = b; }
90 bool allow_multiple() const { return _allow_multiple; }
91 bool is_mandatory() const { return _is_mandatory; }
92 bool has_value() const { return _is_set || _default_string != NULL; }
93 bool has_default() const { return _default_string != NULL; }
94 void read_value(const char* str, size_t len, TRAPS);
95 virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
96 virtual void init_value(TRAPS) = 0;
97 virtual void reset(TRAPS) = 0;
98 virtual void cleanup() = 0;
99 virtual void value_as_str(char* buf, size_t len) const = 0;
100 void set_next(GenDCmdArgument* arg) {
101 _next = arg;
102 }
|
1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
54
55 class MemorySizeArgument {
56 public:
57 u8 _size;
58 u8 _val;
59 char _multiplier;
60 };
61
62 class GenDCmdArgument : public ResourceObj {
63 protected:
64 GenDCmdArgument* _next;
65 const char* const _name;
66 const char* const _description;
67 const char* const _type;
68 const char* const _default_string;
69 bool _is_set;
70 const bool _is_mandatory;
71 bool _allow_multiple;
72 GenDCmdArgument(const char* name, const char* description, const char* type,
73 const char* default_string, bool mandatory)
74 : _next(NULL), _name(name), _description(description), _type(type),
75 _default_string(default_string), _is_set(false), _is_mandatory(mandatory),
76 _allow_multiple(false) {}
77 public:
78 const char* name() const { return _name; }
79 const char* description() const { return _description; }
80 const char* type() const { return _type; }
81 const char* default_string() const { return _default_string; }
82 bool is_set() const { return _is_set; }
83 void set_is_set(bool b) { _is_set = b; }
84 bool allow_multiple() const { return _allow_multiple; }
85 bool is_mandatory() const { return _is_mandatory; }
86 bool has_value() const { return _is_set || _default_string != NULL; }
87 bool has_default() const { return _default_string != NULL; }
88 void read_value(const char* str, size_t len, TRAPS);
89 virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
90 virtual void init_value(TRAPS) = 0;
91 virtual void reset(TRAPS) = 0;
92 virtual void cleanup() = 0;
93 virtual void value_as_str(char* buf, size_t len) const = 0;
94 void set_next(GenDCmdArgument* arg) {
95 _next = arg;
96 }
|