Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.0 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // argument parsing
  4. //
  5. // 3-3-99 sburns
  6. #ifndef ARGS_HPP_INCLUDED
  7. #define ARGS_HPP_INCLUDED
  8. // args of the form "/argname:value" create an entry such that
  9. // (argmap["argname"] == value) is true. '/' or '-' are treated synonymously.
  10. //
  11. // args of the form "argspec" creates an entry such that
  12. // argmap.find(arg) != argmap.end().
  13. //
  14. // args are case-preserving but not case sensitive, so
  15. // argmap["myarg"], argmap["MYARG"], and argmap["MyArG"] all are equivalent.
  16. //
  17. // To test for the presence of a arg in a map, use std::map::find().
  18. //
  19. typedef
  20. std::map<
  21. String,
  22. String,
  23. String::LessIgnoreCase,
  24. Burnslib::Heap::Allocator<String> >
  25. ArgMap;
  26. // Populates a map of command line arguments and their values from the
  27. // command line arguements of the currently executing program.
  28. //
  29. // argmap - map to receive the key/value pairs. Prior contents are not
  30. // changed.
  31. //
  32. // The first command-line argument is the command used to start the program.
  33. // This value is mapped to the key "_command"
  34. void
  35. MapCommandLineArgs(ArgMap& argmap);
  36. // Populates a map of arguments and their values from the given
  37. // string.
  38. //
  39. // args - text containing args separated by spaces/tabs.
  40. //
  41. // argmap - map to receive the key/value pairs. Prior contents are not
  42. // changed.
  43. void
  44. MapArgs(const String& args, ArgMap& argmap);
  45. // Populates a map of command line arguments and their values from the list
  46. //
  47. //
  48. // args - list of Strings, where each node is an arg.
  49. //
  50. // argmap - map to receive the key/value pairs. Prior contents are not
  51. // changed.
  52. void
  53. MapArgsHelper(const String& arg, ArgMap& argmap);
  54. template <class InputIterator>
  55. void
  56. MapArgs(InputIterator first, const InputIterator& last, ArgMap& argmap)
  57. {
  58. for (
  59. ;
  60. first != last;
  61. ++first)
  62. {
  63. MapArgsHelper(*first, argmap);
  64. }
  65. }
  66. #endif // ARGS_HPP_INCLUDED