PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/cli/internal/clarg_with_args.e

http://github.com/tybor/Liberty
Specman e | 144 lines | 98 code | 23 blank | 23 comment | 0 complexity | 204b3d6be5a48915ca9f25bb90af4b4b MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4deferred class CLARG_WITH_ARGS[E_]
  5
  6inherit
  7   TRAVERSABLE[E_]
  8      undefine
  9         out_in_tagged_out_memory
 10      end
 11   COMMAND_LINE_TYPED_ARGUMENT[TRAVERSABLE[E_]]
 12      rename
 13         item as items
 14      undefine
 15         out_in_tagged_out_memory
 16      end
 17
 18insert
 19   CLARG_PARSER
 20      redefine
 21         optional, positional
 22      end
 23
 24feature {ANY}
 25   items: TRAVERSABLE[E_]
 26      do
 27         Result := Current
 28      end
 29
 30   is_repeatable: BOOLEAN True
 31
 32   is_set: BOOLEAN
 33      do
 34         Result := not set.is_empty
 35      end
 36
 37feature {COMMAND_LINE_ARGUMENTS, COMMAND_LINE_ARGUMENT}
 38   prepare_parse
 39      do
 40         set.clear_count
 41      end
 42
 43   is_set_at (context: COMMAND_LINE_CONTEXT): BOOLEAN
 44      do
 45         Result := set.has(context)
 46      end
 47
 48   undo_parse (context: COMMAND_LINE_CONTEXT)
 49      do
 50         set.remove(context)
 51      end
 52
 53   set_data (context: COMMAND_LINE_CONTEXT; data: STRING)
 54      do
 55         set.add(decode(data), context)
 56      end
 57
 58feature {}
 59   decode (data: STRING): E_
 60      require
 61         is_valid_data(data)
 62      deferred
 63      end
 64
 65feature {ANY} -- TRAVERSABLE:
 66   count: INTEGER
 67      do
 68         Result := set.count
 69      end
 70
 71   is_empty: BOOLEAN
 72      do
 73         Result := set.is_empty
 74      end
 75
 76   lower: INTEGER
 77      do
 78         Result := set.lower
 79      end
 80
 81   upper: INTEGER
 82      do
 83         Result := set.upper
 84      end
 85
 86   item (i: INTEGER): E_
 87      do
 88         Result := set.item(i)
 89      end
 90
 91   first: like item
 92      do
 93         Result := set.first
 94      end
 95
 96   last: like item
 97      do
 98         Result := set.last
 99      end
100
101   new_iterator: ITERATOR[E_]
102      do
103         Result := set.new_iterator_on_items
104      end
105
106feature {}
107   set: AVL_DICTIONARY[E_, COMMAND_LINE_CONTEXT]
108
109   optional (a_short, a_long, a_name, a_usage: ABSTRACT_STRING)
110      do
111         create set.make
112         Precursor(a_short, a_long, a_name, a_usage)
113      end
114
115   positional (a_name, a_usage: ABSTRACT_STRING)
116      do
117         create set.make
118         Precursor(a_name, a_usage)
119      end
120
121invariant
122   set /= Void
123
124end -- class CLARG_WITH_ARGS
125--
126-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
127--
128-- Permission is hereby granted, free of charge, to any person obtaining a copy
129-- of this software and associated documentation files (the "Software"), to deal
130-- in the Software without restriction, including without limitation the rights
131-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
132-- copies of the Software, and to permit persons to whom the Software is
133-- furnished to do so, subject to the following conditions:
134--
135-- The above copyright notice and this permission notice shall be included in
136-- all copies or substantial portions of the Software.
137--
138-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
140-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
141-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
142-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
143-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
144-- THE SOFTWARE.