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

📄 ncbidiag.inl

📁 ncbi源码
💻 INL
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: ncbidiag.inl,v $ * PRODUCTION Revision 1000.3  2004/06/01 19:08:00  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.43 * PRODUCTION * =========================================================================== */#if defined(CORELIB___NCBIDIAG__HPP)  &&  !defined(CORELIB___NCBIDIAG__INL)#define CORELIB___NCBIDIAG__INL/*  $Id: ncbidiag.inl,v 1000.3 2004/06/01 19:08:00 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:  Denis Vakatov * * File Description: *   NCBI C++ diagnostic API * *//////////////////////////////////////////////////////////////////////////////// WARNING -- all the beneath is for INTERNAL "ncbidiag" use only,//            and any classes, typedefs and even "extern" functions and//            variables declared in this file should not be used anywhere//            but inside "ncbidiag.inl" and/or "ncbidiag.cpp"!!!///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CDiagBuffer// (can be accessed only by "CNcbiDiag" and "CDiagRestorer"// and created only by GetDiagBuffer())//class CDiagBuffer{    CDiagBuffer(const CDiagBuffer&);    CDiagBuffer& operator= (const CDiagBuffer&);    friend CDiagBuffer& GetDiagBuffer(void);    // Flags    friend bool IsSetDiagPostFlag(EDiagPostFlag flag, TDiagPostFlags flags);    NCBI_XNCBI_EXPORT    friend TDiagPostFlags         SetDiagPostAllFlags(TDiagPostFlags flags);    NCBI_XNCBI_EXPORT friend void SetDiagPostFlag(EDiagPostFlag flag);    NCBI_XNCBI_EXPORT friend void UnsetDiagPostFlag(EDiagPostFlag flag);    NCBI_XNCBI_EXPORT    friend TDiagPostFlags         SetDiagTraceAllFlags(TDiagPostFlags flags);    NCBI_XNCBI_EXPORT friend void SetDiagTraceFlag(EDiagPostFlag flag);    NCBI_XNCBI_EXPORT friend void UnsetDiagTraceFlag(EDiagPostFlag flag);    NCBI_XNCBI_EXPORT friend void SetDiagPostPrefix(const char* prefix);    NCBI_XNCBI_EXPORT friend void PushDiagPostPrefix(const char* prefix);    NCBI_XNCBI_EXPORT friend void PopDiagPostPrefix(void);    //    friend class CNcbiDiag;    friend const CNcbiDiag& Reset(const CNcbiDiag& diag);    friend const CNcbiDiag& Endm(const CNcbiDiag& diag);    // Severity    NCBI_XNCBI_EXPORT    friend EDiagSev SetDiagPostLevel(EDiagSev post_sev);    NCBI_XNCBI_EXPORT    friend void SetDiagFixedPostLevel(EDiagSev post_sev);    NCBI_XNCBI_EXPORT    friend bool DisableDiagPostLevelChange(bool disable_change);    NCBI_XNCBI_EXPORT    friend EDiagSev SetDiagDieLevel(EDiagSev die_sev);    NCBI_XNCBI_EXPORT    friend void IgnoreDiagDieLevel(bool ignore, EDiagSev* prev_sev);    // Others    NCBI_XNCBI_EXPORT    friend void SetDiagTrace(EDiagTrace how, EDiagTrace dflt);    NCBI_XNCBI_EXPORT friend bool IsDiagStream(const CNcbiOstream* os);    // Handler    NCBI_XNCBI_EXPORT friend void    SetDiagHandler(CDiagHandler* handler, bool can_delete);    NCBI_XNCBI_EXPORT friend CDiagHandler* GetDiagHandler(bool take_ownership);    NCBI_XNCBI_EXPORT friend bool IsSetDiagHandler(void);    // Error code information    NCBI_XNCBI_EXPORT    friend void SetDiagErrCodeInfo(CDiagErrCodeInfo* info, bool can_delete);    NCBI_XNCBI_EXPORT    friend CDiagErrCodeInfo* GetDiagErrCodeInfo(bool take_ownership);    NCBI_XNCBI_EXPORT    friend bool IsSetDiagErrCodeInfo(void);private:    friend class CDiagRestorer;    const CNcbiDiag* m_Diag;    // present user    CNcbiOstream*    m_Stream;  // storage for the diagnostic message    // user-specified string to add to each posted message    // (can be constructed from "m_PrefixList" after push/pop operations)    string m_PostPrefix;    // list of prefix strings to compose the "m_PostPrefix" from    typedef list<string> TPrefixList;    TPrefixList m_PrefixList;    CDiagBuffer(void);    //### This is a temporary workaround to allow call the destructor of    //### static instance of "CDiagBuffer" defined in GetDiagBuffer()public:    ~CDiagBuffer(void);private:    //###    // formatted output    template<class X> void Put(const CNcbiDiag& diag, const X& x) {        if ( SetDiag(diag) )            (*m_Stream) << x;    }    NCBI_XNCBI_EXPORT    void Flush  (void);    void Reset  (const CNcbiDiag& diag);   // reset content of the diag.message    void EndMess(const CNcbiDiag& diag);   // output current diag. message    NCBI_XNCBI_EXPORT    bool SetDiag(const CNcbiDiag& diag);    // flush & detach the current user    void Detach(const CNcbiDiag* diag);    // compose the post prefix using "m_PrefixList"    void UpdatePrefix(void);    // the bitwise OR combination of "EDiagPostFlag"    static TDiagPostFlags sm_PostFlags;    // extra flags ORed in for traces    static TDiagPostFlags sm_TraceFlags;    // static members    static EDiagSev       sm_PostSeverity;    static EDiagSevChange sm_PostSeverityChange;                                           // severity level changing status    static EDiagSev       sm_DieSeverity;    static EDiagTrace     sm_TraceDefault; // default state of tracing    static bool           sm_TraceEnabled; // current state of tracing                                           // (enable/disable)    static bool GetTraceEnabled(void);     // dont access sm_TraceEnabled                                            // directly    static bool GetTraceEnabledFirstTime(void);    static bool GetSeverityChangeEnabledFirstTime(void);    // call the current diagnostics handler directly    static void DiagHandler(SDiagMessage& mess);    // Symbolic name for the severity levels(used by CNcbiDiag::SeverityName)    static const char* sm_SeverityName[eDiag_Trace+1];    // Application-wide diagnostic handler    static CDiagHandler* sm_Handler;    static bool          sm_CanDeleteHandler;    // Error codes info    static CDiagErrCodeInfo* sm_ErrCodeInfo;    static bool              sm_CanDeleteErrCodeInfo;};extern CDiagBuffer& GetDiagBuffer(void);/////////////////////////////////////////////////////////  CNcbiDiag::inline CNcbiDiag::~CNcbiDiag(void) {    m_Buffer.Detach(this);}#ifdef NCBIDIAG_DEFER_GENERIC_PUTtemplate<class X>inline const CNcbiDiag& CNcbiDiag::operator<< (const X& x) const {    m_Buffer.Put(*this, x);    return *this;}#endifinline const CNcbiDiag& CNcbiDiag::SetLine(size_t line) const {    m_Line = line;    return *this;}inline const CNcbiDiag& CNcbiDiag::SetErrorCode(int code, int subcode) const {    m_ErrCode = code;    m_ErrSubCode = subcode;    return *this;}inline EDiagSev CNcbiDiag::GetSeverity(void) const {    return m_Severity;}inline const char* CNcbiDiag::GetFile(void) const {    return m_File;}inline size_t CNcbiDiag::GetLine(void) const {    return m_Line;}inline int CNcbiDiag::GetErrorCode(void) const {    return m_ErrCode;}inline int CNcbiDiag::GetErrorSubCode(void) const {    return m_ErrSubCode;}inline TDiagPostFlags CNcbiDiag::GetPostFlags(void) const {    return (m_PostFlags & eDPF_Default) ?        (m_PostFlags | CDiagBuffer::sm_PostFlags) & ~eDPF_Default :        m_PostFlags;}inlineconst char* CNcbiDiag::SeverityName(EDiagSev sev) {    return CDiagBuffer::sm_SeverityName[sev];}/////////////////////////////////////////////////////////  ErrCode - class for manipulator ErrCodeinlineconst CNcbiDiag& CNcbiDiag::operator<< (const ErrCode& err_code) const{    return SetErrorCode(err_code.m_Code, err_code.m_SubCode);}inlinebool operator< (const ErrCode& ec1, const ErrCode& ec2){    return (ec1.m_Code == ec2.m_Code)        ? (ec1.m_SubCode < ec2.m_SubCode)        : (ec1.m_Code < ec2.m_Code);}/////////////////////////////////////////////////////////  Other CNcbiDiag:: manipulatorsinlineconst CNcbiDiag& Reset(const CNcbiDiag& diag)  {    diag.m_Buffer.Reset(diag);    diag.SetErrorCode(0, 0);    return diag;}inlineconst CNcbiDiag& Endm(const CNcbiDiag& diag)  {    diag.m_Buffer.EndMess(diag);    diag.SetErrorCode(0, 0);    return diag;}inlineconst CNcbiDiag& Info(const CNcbiDiag& diag)  {    diag << Endm;    diag.m_Severity = eDiag_Info;    return diag;}inlineconst CNcbiDiag& Warning(const CNcbiDiag& diag)  {    diag << Endm;    diag.m_Severity = eDiag_Warning;    return diag;}inlineconst CNcbiDiag& Error(const CNcbiDiag& diag)  {    diag << Endm;    diag.m_Severity = eDiag_Error;    return diag;

⌨️ 快捷键说明

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