Fix some doxygen usage in these headers.
[oota-llvm.git] / include / llvm / System / Program.h
1 //===- llvm/System/Program.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Reid Spencer and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the llvm::sys::Program class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SYSTEM_PROGRAM_H
15 #define LLVM_SYSTEM_PROGRAM_H
16
17 #include "llvm/System/Path.h"
18 #include <vector>
19
20 namespace llvm {
21 namespace sys {
22
23   /// This class provides an abstraction for programs that are executable by the
24   /// operating system. It provides a platform generic way to find executable
25   /// programs from the path and to execute them in various ways. The sys::Path
26   /// class is used to specify the location of the Program.
27   /// @since 1.4
28   /// @brief An abstraction for finding and executing programs.
29   class Program {
30     /// @name Methods
31     /// @{
32     public:
33       /// This static constructor (factory) will attempt to locate a program in
34       /// the operating system's file system using some pre-determined set of
35       /// locations to search (e.g. the PATH on Unix).
36       /// @returns A Path object initialized to the path of the program or a
37       /// Path object that is empty (invalid) if the program could not be found.
38       /// @throws nothing
39       /// @brief Construct a Program by finding it by name.
40       static Path FindProgramByName(const std::string& name);
41
42       /// This function executes the program using the \p arguments provided and
43       /// waits for the program to exit. This function will block the current
44       /// program until the invoked program exits. The invoked program will
45       /// inherit the stdin, stdout, and stderr file descriptors, the
46       /// environment and other configuration settings of the invoking program.
47       /// If Path::executable() does not return true when this function is
48       /// called then a std::string is thrown.
49       /// @returns an integer result code indicating the status of the program.
50       /// A zero or positive value indicates the result code of the program. A
51       /// negative value is the signal number on which it terminated.
52       /// @throws std::string on a variety of error conditions or if the invoked
53       /// program aborted abnormally.
54       /// @see FindProgrambyName
55       /// @brief Executes the program with the given set of \p args.
56       static int ExecuteAndWait(
57         const Path& path,  ///< sys::Path object providing the path of the 
58           ///< program to be executed. It is presumed this is the result of 
59           ///< the FindProgramByName method.
60         const char** args, ///< A vector of strings that are passed to the
61           ///< program.  The first element should be the name of the program.
62           ///< The list *must* be terminated by a null char* entry.
63         const char ** env = 0, ///< An optional vector of strings to use for
64           ///< the program's environment. If not provided, the current program's
65           ///< environment will be used.
66         const sys::Path** redirects = 0, ///< An optional array of pointers to
67           ///< Paths. If the array is null, no redirection is done. The array
68           ///< should have a size of at least three. If the pointer in the array
69           ///< are not null, then the inferior process's stdin(0), stdout(1),
70           ///< and stderr(2) will be redirected to the corresponding Paths.
71         unsigned secondsToWait = 0 ///< If non-zero, this specifies the amount
72           ///< of time to wait for the child process to exit. If the time
73           ///< expires, the child is killed and this call returns. If zero,
74           ///< this function will wait until the child finishes or forever if
75           ///< it doesn't.
76       );
77   };
78 }
79 }
80
81
82 #endif