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

📄 ncbireg.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: ncbireg.hpp,v $ * PRODUCTION Revision 1000.0  2003/10/29 15:05:14  gouriano * PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.32 * PRODUCTION * =========================================================================== */#ifndef CORELIB___NCBIREG__HPP#define CORELIB___NCBIREG__HPP/*  $Id: ncbireg.hpp,v 1000.0 2003/10/29 15:05:14 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 ncbireg.hpp/// Process information in the NCBI Registry, including working with/// configuration files.////// Classes to perform NCBI Registry operations including:/// - Read and parse configuration file/// - Search, edit, etc. the retrieved configuration information/// - Write information back to configuration file////// The Registry is defined as a text file with sections and entries in the /// form of "name=value" strings in each section. ////// For an explanation of the syntax of the Registry file, see the/// C++ Toolkit documentation.#include <corelib/ncbistd.hpp>#include <list>#include <map>/** @addtogroup Registry * * @{ */BEGIN_NCBI_SCOPE/////////////////////////////////////////////////////////////////////////////////// CRegistryException --////// Define exceptions generated by CNcbiRegistry.////// CRegistryException inherits its basic functionality from/// CCParseTemplException<CCoreException> and defines additional error codes/// for the Registry.class NCBI_XNCBI_EXPORT CRegistryException :    public CParseTemplException<CCoreException>{public:    /// Error types that the Registry can generate.    enum EErrCode {        eSection,   ///< Section error        eEntry,     ///< Entry error        eValue,     ///< Value error        eErr        ///< Other error    };    /// Translate from the error code value to its string representation.    virtual const char* GetErrCodeString(void) const    {        switch (GetErrCode()) {        case eSection: return "eSection";        case eEntry:   return "eEntry";        case eValue:   return "eValue";        case eErr:     return "eErr";        default:       return CException::GetErrCodeString();        }    }    // Standard exception boilerplate code    NCBI_EXCEPTION_DEFAULT2(CRegistryException,                            CParseTemplException<CCoreException>,                            std::string::size_type);};/////////////////////////////////////////////////////////////////////////////////// CNcbiRegistry --////// Define the Registry.////// Load, access, modify and store runtime information (usually used to/// work with configuration files).class NCBI_XNCBI_EXPORT CNcbiRegistry{public:    /// Registry parameter settings.    ///    /// A Registry parameter can be either transient or persistent,    /// overridable or not overridable, truncatable or not truncatable.    enum EFlags {        eTransient   = 0x1,     ///< Transient -- Wont be saved (by Write())        ePersistent  = 0x100,   ///< Persistent -- Saved when file is written        eOverride    = 0x2,     ///< Existing value can be overriden        eNoOverride  = 0x200,   ///< Cannot change existing value        eTruncate    = 0x4,     ///< Leading, trailing blanks can be truncated        eNoTruncate  = 0x400    ///< Cannot truncate parameter value    };    typedef int TFlags;  ///< Binary OR of "EFlags"    /// Constructor.    CNcbiRegistry(void);    /// Destructor.    ~CNcbiRegistry(void);    /// Constructor.    ///    /// @param is    ///   Input stream to load the Registry from.    ///   NOTE:  if the stream is a file, it must be opened in binary mode!    /// @param flags    ///   How parameters are stored. The default is to store all parameters as    ///   persistent unless the  "eTransient" flag is set in which case the    ///   newly retrieved parameters is stored as transient.    /// @sa    ///   Read()    CNcbiRegistry(CNcbiIstream& is, TFlags flags = 0);     /// Verify if Registry is empty.    ///    /// @return    ///   TRUE if the registry contains no entries.    bool Empty(void) const;    /// Verify if persistent values have been modified.    ///    /// @return    ///   TRUE if the persistent part of the registry (i.e. persistent    ///   value(s) and the all-registry comment) was modified since:    ///   - the last successful Write(), or    ///   - the registry creation and maybe immediate read after the creation.    bool Modified(void) const;    /// Read and parse the stream "is", and merge its content with current    /// Registry entries.    ///    /// Once the Registry has been initialized by the constructor, it is     /// possible to load other parameters from other files using this method.    /// @param is    ///   Input stream to read and parse.    ///   NOTE:  if the stream is a file, it must be opened in binary mode!    /// @param flags    ///   How parameters are stored. The default is for all values to be read    ///   as persistent with the capability of overriding any previously    ///   loaded value associated with the same name. The default can be    ///   modified by specifying "eTransient", "eNoOverride" or     ///   "eTransient | eNoOverride". If there is a conflict between the old    ///   and the new(loaded) entry value and if "eNoOverride" flag is set,    ///   then just ignore the new value; otherwise, replace the old value by    ///   the new one. If "eTransient" flag is set, then store the newly    ///   retrieved parameters as transient;  otherwise, store them as    ///   persistent.    /// @sa    ///   Write()    void Read(CNcbiIstream& is, TFlags flags = 0);    /// Write the registry content to output stream.    /// @param os    ///   Output stream to write the registry to.    ///   NOTE:  if the stream is a file, it must be opened in binary mode!    /// @return    ///   TRUE if operation is successful.    /// @sa    ///   Read()    bool Write(CNcbiOstream& os) const;    /// Reset the registry content.    void Clear(void);    /// Get the parameter value.    ///    /// Get the parameter with the specified "name" from the specified     /// "section".  First, search for the transient parameter value, and if    /// cannot find in there, then continue the search in the non-transient    /// paramters. If "ePersistent" flag is set in "flags", then don't search    /// in the transient transient parameters at all.    /// @param section    ///   Section name to search under.    /// @param name    ///   Parameter name to search for.    /// @param flags    ///   To control search.    /// @return    ///   The parameter value, or empty string if the parameter is not found.    /// @sa    ///   GetString()    const string& Get(const string& section, const string& name,                      TFlags flags = 0) const;    /// Get the parameter string value.    ///    /// Similar to the "Get()", but if the configuration parameter is not    /// found, then return 'default_value' rather than empty string.    /// @sa    ///   Get()    const string GetString(const string& section, const string& name,                           const string& default_value, TFlags flags = 0)        const;    /// What to do if parameter value is present but cannot be converted into    /// the requested type.    enum EErrAction {        eThrow,   ///< Throw an exception if an error occurs        eErrPost, ///< Log the error message and return default value        eReturn   ///< Return default value    };

⌨️ 快捷键说明

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