⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncbiexec.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: ncbiexec.hpp,v $ * PRODUCTION Revision 1000.1  2004/04/21 14:34:43  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.13 * PRODUCTION * =========================================================================== */#ifndef CORELIB__NCBIEXEC__HPP#define CORELIB__NCBIEXEC__HPP/*  $Id: ncbiexec.hpp,v 1000.1 2004/04/21 14:34:43 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Author:  Vladimir Ivanov * * *//// @file ncbiexec.hpp /// Defines a portable execute class.#include <corelib/ncbistd.hpp>#include <corelib/ncbi_limits.hpp>/** @addtogroup Exec * * @{ */BEGIN_NCBI_SCOPE/////////////////////////////////////////////////////////////////////////////////// CExecException --////// Define exceptions generated by CExec.////// CExecException inherits its basic functionality from/// CErrnoTemplException<CCoreException> and defines additional error codes/// for errors generated by CExec.class NCBI_XNCBI_EXPORT CExecException :                         public CErrnoTemplException<CCoreException>{public:    /// Error types that CExec can generate.    enum EErrCode {        eSystem,        ///< System error        eSpawn          ///< Spawn error    };    /// Translate from the error code value to its string representation.    virtual const char* GetErrCodeString(void) const    {        switch (GetErrCode()) {        case eSystem: return "eSystem";        case eSpawn:  return "eSpawn";        default:      return CException::GetErrCodeString();        }    }    // Standard exception boilerplate code.    NCBI_EXCEPTION_DEFAULT(CExecException,                           CErrnoTemplException<CCoreException>);};/////////////////////////////////////////////////////////////////////////////////// CExec --////// Define portable exec class.////// Defines the different ways a process can be spawned./// NOTE:  In the eNoWait and eDetach modes Spawn functions returns a process///        handle. On MS Windows it is a real process handle of type HANDLE.///        On UNIX it is a process identifier (pid).class NCBI_XNCBI_EXPORT CExec{public:    /// Which exec mode the spawned process is called with.    enum EMode {        eOverlay = 0, ///< Overlays calling process with new process,                      ///< destroying calling process.         eWait    = 1, ///< Suspends calling thread until execution of new                       ///< process is complete (synchronous operation).        eNoWait  = 2, ///< Continues to execute calling process concurrently                       ///< with new process (asynchronous process).        eDetach  = 3  ///< Continues to execute calling process; new process                       ///< is run in background with no access to console or                       ///< keyboard; calls to Wait() against new process will                      ///< fail; this is an asynchronous spawn.    };    /// Execute the specified command.    ///    /// Execute the command and return the executed command's exit code.    /// Throw an exception if command failed to execute. If cmdline is a null    /// pointer, System() checks if the shell (command interpreter) exists and    /// is executable. If the shell is available, System() returns a non-zero    /// value; otherwise, it returns 0.    static int System(const char* cmdline);    /// Spawn a new process with specified command-line arguments.    ///    /// In the SpawnL() version, the command-line arguments are passed    /// individually. SpawnL() is typically used when number of parameters to    /// the new process is known in advance.    ///    /// Meaning of the suffix "L" in method name:    /// - The letter "L" as suffix refers to the fact that command-line    ///   arguments are passed separately as arguments.    ///    /// NOTE: At least one argument must be present. This argument is always,     /// by convention, the name of the file being spawned (argument with     /// number 0).    /// @param mode    ///   Mode for running the process.    /// @param cmdline    ///   Command-line string.    /// @param argv    ///   Argument vector.    /// @return     ///   On success, return:    ///     - exit code      - in eWait mode.    ///     - process handle - in eNoWait and eDetach modes.    ///     - nothing        - in eOverlay mode.       ///   Throw an exception if command failed to execute.    /// @sa    ///   SpawnLE(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(),     ///   SpawnVPE().    static int SpawnL(EMode mode, const char *cmdname,                       const char *argv, ... /*, NULL */);    /// Spawn a new process with specified command-line arguments and    /// environment settings.    ///    /// In the SpawnLE() version, the command-line arguments and environment    /// pointer are passed individually. SpawnLE() is typically used when    /// number of parameters to the new process and individual environment     /// parameter settings are known in advance.    ///    /// Meaning of the suffix "LE" in method name:    /// - The letter "L" as suffix refers to the fact that command-line    ///   arguments are passed separately as arguments.    /// - The letter "E" as suffix refers to the fact that environment pointer,    ///   envp, is passed as an array of pointers to environment settings to     ///   the new process. The NULL environment pointer indicates that the new     ///   process will inherit the parents process's environment.    ///    /// NOTE: At least one argument must be present. This argument is always,     /// by convention, the name of the file being spawned (argument with     /// number 0).    /// @param mode    ///   Mode for running the process.    /// @param cmdline    ///   Command-line string.    /// @param argv    ///   Argument vector.    /// @param ...    ///   NULL, const char* envp[]    /// @return     ///   On success, return:    ///     - exit code      - in eWait mode.    ///     - process handle - in eNoWait and eDetach modes.    ///     - nothing        - in eOverlay mode.       ///   Throw an exception if command failed to execute.    /// @sa    ///   SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(),     ///   SpawnVPE().    static int SpawnLE (EMode mode, const char *cmdname,                         const char *argv, ... /*, NULL, const char *envp[] */);    /// Spawn a new process with variable number of command-line arguments and    /// find file to execute from the PATH environment variable.    ///    /// In the SpawnLP() version, the command-line arguments are passed    /// individually and the PATH environment variable is used to find the    /// file to execute. SpawnLP() is typically used when number    /// of parameters to the new process is known in advance but the exact    /// path to the executable is not known.    ///    /// Meaning of the suffix "LP" in method name:    /// - The letter "L" as suffix refers to the fact that command-line    ///   arguments are passed separately as arguments.    /// - The letter "P" as suffix refers to the fact that the PATH    ///   environment variable is used to find file to execute - on a Unix    ///   platform this feature works in functions without letter "P" in    ///   function name.     ///    /// NOTE: At least one argument must be present. This argument is always,     /// by convention, the name of the file being spawned (argument with     /// number 0).    /// @param mode    ///   Mode for running the process.    /// @param cmdline    ///   Command-line string.    /// @param argv    ///   Argument vector.    /// @param ...    ///   NULL    /// @return     ///   On success, return:    ///     - exit code      - in eWait mode.    ///     - process handle - in eNoWait and eDetach modes.    ///     - nothing        - in eOverlay mode.       ///   Throw an exception if command failed to execute.    /// @sa    ///   SpawnL(), SpawnLE(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(),     ///   SpawnVPE().    static int SpawnLP(EMode mode, const char *cmdname,                        const char *argv, ... /*, NULL */);    /// Spawn a new process with specified command-line arguments,     /// environment settings and find file to execute from the PATH    /// environment variable.    ///    /// In the SpawnLPE() version, the command-line arguments and environment    /// pointer are passed individually, and the PATH environment variable    /// is used to find the file to execute. SpawnLPE() is typically used when    /// number of parameters to the new process and individual environment    /// parameter settings are known in advance, but the exact path to the    /// executable is not known.    ///    /// Meaning of the suffix "LPE" in method name:    /// - The letter "L" as suffix refers to the fact that command-line    ///   arguments are passed separately as arguments.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -