diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-08-08 01:04:17 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-08-08 01:07:10 +0200 |
commit | c8989e1529b74831e9aad14e5c7307113a272180 (patch) | |
tree | 3155702529d5ce07de186140563d3f110ce083d1 /shell | |
parent | 57cf026739a3d707378ca38f59518b018fccca8f (diff) |
Cleanup/remove CommandLine-related methods in lngconvex.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/tools/lngconvex/cmdline.cxx | 77 | ||||
-rw-r--r-- | shell/source/tools/lngconvex/cmdline.hxx | 42 |
2 files changed, 4 insertions, 115 deletions
diff --git a/shell/source/tools/lngconvex/cmdline.cxx b/shell/source/tools/lngconvex/cmdline.cxx index 350bb7949223..1bd18b65a8a4 100644 --- a/shell/source/tools/lngconvex/cmdline.cxx +++ b/shell/source/tools/lngconvex/cmdline.cxx @@ -40,10 +40,9 @@ // Creation -CommandLine::CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix) : +CommandLine::CommandLine(size_t argc, char* argv[]) : m_argc(argc), - m_argv(argv), - m_argprefix(ArgPrefix) + m_argv(argv) { } @@ -51,57 +50,6 @@ CommandLine::CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix // Query -/** Return the argument count -*/ -size_t CommandLine::get_arg_count() const -{ - return m_argc; -} - -/** Return an argument by index - This method doesn't skip argument - names if any, so if the second - argument is an argument name the - function nevertheless returns it. - - @precond 0 <= Index < GetArgumentCount - - @throws std::out_of_range exception - if the given index is to high -*/ -std::string CommandLine::get_arg(size_t Index) const -{ - OSL_PRECOND(Index < m_argc, "Index out of range"); - - if (Index > (m_argc - 1)) - throw std::out_of_range("Invalid index"); - - return m_argv[Index]; -} - - -/** Returns all argument name found in the - command line. An argument will be identified - by a specified prefix. The standard prefix - is '-'. - If the are no argument names the returned - container is empty. -*/ -StringListPtr_t CommandLine::get_arg_names() const -{ - StringListPtr_t arg_cont(new StringList_t()); - - for (size_t i = 0; i < m_argc; i++) - { - std::string argn = m_argv[i]; - - if (is_arg_name(argn)) - arg_cont->push_back(argn); - } - - return arg_cont; -} - /** Returns an argument by name. If there are duplicate argument names in the command line, the first one wins. @@ -143,30 +91,11 @@ std::string CommandLine::get_arg(const std::string& ArgumentName) const // Command -/** Set the prefix used to identify arguments in - the command line. - - @precond prefix is not empty - - @throws std::invalid_argument exception if - the prefix is empty -*/ -void CommandLine::set_arg_prefix(const std::string& Prefix) -{ - OSL_PRECOND(Prefix.length(), "Empty argument prefix!"); - - if (0 == Prefix.length()) - throw std::invalid_argument("Empty argument prefix not allowed"); - - m_argprefix = Prefix; -} - - /** Returns whether a given argument is an argument name */ bool CommandLine::is_arg_name(const std::string& Argument) const { - return (0 == Argument.compare(0, m_argprefix.length(), m_argprefix)); + return (Argument.length() > 0 && Argument[0] == '-'); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/shell/source/tools/lngconvex/cmdline.hxx b/shell/source/tools/lngconvex/cmdline.hxx index efee314fa9e0..29c16c67e0a3 100644 --- a/shell/source/tools/lngconvex/cmdline.hxx +++ b/shell/source/tools/lngconvex/cmdline.hxx @@ -15,38 +15,12 @@ public: // Creation - CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix = std::string("-")); + CommandLine(size_t argc, char* argv[]); // Query - /** Return the argument count - */ - size_t get_arg_count() const; - - /** Return an argument by index - This method doesn't skip argument - names if any, so if the second - argument is an argument name the - function nevertheless returns it. - - @precond 0 <= Index < GetArgumentCount - - @throws std::out_of_range exception - if the given index is to high - */ - std::string get_arg(size_t Index) const; - - /** Returns all argument name found in the - command line. An argument will be identified - by a specified prefix. The standard prefix - is '-'. - If there are no argument names the returned - container is empty. - */ - StringListPtr_t get_arg_names() const; - /** Returns an argument by name. If there are duplicate argument names in the command line, the first one wins. @@ -66,19 +40,6 @@ public: std::string get_arg(const std::string& ArgumentName) const; - // Command - - - /** Set the prefix used to identify arguments in - the command line. - - @precond prefix is not empty - - @throws std::invalid_argument exception if - the prefix is empty - */ - void set_arg_prefix(const std::string& Prefix); - private: /** Returns whether a given argument is an argument name @@ -88,7 +49,6 @@ private: private: size_t m_argc; char** m_argv; - std::string m_argprefix; // prevent copy and assignment private: |