OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMEOS_DBUS_DBUS_COMMAND_LINE_HELPER_H_ |
| 6 #define CHROMEOS_DBUS_DBUS_COMMAND_LINE_HELPER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "chromeos/chromeos_export.h" |
| 12 |
| 13 namespace dbus_command_line_helper { |
| 14 |
| 15 // Parses a single name,value pair. Returns 'true' if parsed successfully. |
| 16 typedef base::Callback< |
| 17 bool(const std::string& arg0, const std::string& arg1)> ParseOptionCallback; |
| 18 |
| 19 // Parses a command line switch containing comma-separated name-value pairs. |
| 20 // Invokes |callback| for each name-value pair. Returns false only if the |
| 21 // option is not set in the command line. |
| 22 // Examples: |
| 23 // Invokes |callback| once with ("foo", ""): |
| 24 // --option=foo |
| 25 // Invokes |callback| three times with ("foo", ""), ("bar", "1"), ("a", "b") |
| 26 // --option=foo,bar=1,a=b |
| 27 CHROMEOS_EXPORT bool ParseOptions(const std::string& switch_name, |
| 28 const ParseOptionCallback& callback); |
| 29 |
| 30 } // namespace dbus_command_line_helper |
| 31 |
| 32 |
| 33 #endif // CHROMEOS_DBUS_DBUS_COMMAND_LINE_HELPER_H_ |
OLD | NEW |