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

📄 strbuffer.inl

📁 ncbi源码
💻 INL
字号:
/* * =========================================================================== * PRODUCTION $Log: strbuffer.inl,v $ * PRODUCTION Revision 1000.1  2004/06/01 19:38:59  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * PRODUCTION * =========================================================================== */#if defined(STRBUFFER__HPP)  &&  !defined(STRBUFFER__INL)#define STRBUFFER__INL/*  $Id: strbuffer.inl,v 1000.1 2004/06/01 19:38:59 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: Eugene Vasilchenko** File Description:*   !!! PUT YOUR DESCRIPTION HERE !!!** ---------------------------------------------------------------------------* $Log: strbuffer.inl,v $* Revision 1000.1  2004/06/01 19:38:59  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5** Revision 1.5  2004/05/24 18:12:44  gouriano* In text output files make indentation optional** Revision 1.4  2001/08/15 20:53:09  juran* Heed warnings.** Revision 1.3  2001/03/14 17:59:24  vakatov* COStreamBuffer::  renamed GetFreeSpace() -> GetAvailableSpace()* to avoid clash with MS-Win system headers' #define** Revision 1.2  2001/01/05 20:08:53  vasilche* Added util directory for various algorithms and utility classes.** Revision 1.1  2000/12/26 22:23:45  vasilche* Fixed errors of compilation on Mac.** ===========================================================================*/inlinebool CIStreamBuffer::fail(void) const{    return m_Error != 0;}inlinevoid CIStreamBuffer::ResetFail(void){    m_Error = 0;}inlineconst char* CIStreamBuffer::GetError(void) const{    return m_Error;}inlinechar CIStreamBuffer::PeekChar(size_t offset)    THROWS1((CIOException, bad_alloc)){    char* pos = m_CurrentPos + offset;    if ( pos >= m_DataEndPos )        pos = FillBuffer(pos);    return *pos;}inlinechar CIStreamBuffer::PeekCharNoEOF(size_t offset)    THROWS1((CIOException, bad_alloc)){    char* pos = m_CurrentPos + offset;    if ( pos >= m_DataEndPos )        return FillBufferNoEOF(pos);    return *pos;}inlinechar CIStreamBuffer::GetChar(void)    THROWS1((CIOException, bad_alloc)){    char* pos = m_CurrentPos;    if ( pos >= m_DataEndPos )        pos = FillBuffer(pos);    m_CurrentPos = pos + 1;    return *pos;}inlinevoid CIStreamBuffer::UngetChar(char _DEBUG_ARG(c)){    char* pos = m_CurrentPos;    _ASSERT(pos > m_Buffer);    _ASSERT(pos[-1] == c);    m_CurrentPos = pos - 1;}inlinevoid CIStreamBuffer::SkipChars(size_t count){    _ASSERT(m_CurrentPos + count > m_CurrentPos);    _ASSERT(m_CurrentPos + count <= m_DataEndPos);    m_CurrentPos += count;}inlinevoid CIStreamBuffer::SkipChar(void){    SkipChars(1);}inlineconst char* CIStreamBuffer::GetCurrentPos(void) const    THROWS1_NONE{    return m_CurrentPos;}inlinesize_t CIStreamBuffer::GetLine(void) const    THROWS1_NONE{    return m_Line;}inlinesize_t CIStreamBuffer::GetStreamOffset(void) const    THROWS1_NONE{    return m_BufferOffset + (m_CurrentPos - m_Buffer);}inlinebool COStreamBuffer::fail(void) const{    return m_Error != 0;}inlinevoid COStreamBuffer::ResetFail(void){    m_Error = 0;}inlineconst char* COStreamBuffer::GetError(void) const{    return m_Error;}inlinesize_t COStreamBuffer::GetLine(void) const    THROWS1_NONE{    return m_Line;}inlinesize_t COStreamBuffer::GetStreamOffset(void) const    THROWS1_NONE{    return m_BufferOffset + (m_CurrentPos - m_Buffer);}inlinesize_t COStreamBuffer::GetCurrentLineLength(void) const    THROWS1_NONE{    return m_LineLength;}inlinebool COStreamBuffer::ZeroIndentLevel(void) const    THROWS1_NONE{    return m_IndentLevel == 0;}inlinesize_t COStreamBuffer::GetIndentLevel(size_t step) const    THROWS1_NONE{    return m_IndentLevel / step;}inlinevoid COStreamBuffer::IncIndentLevel(size_t step)    THROWS1_NONE{    m_IndentLevel += step;}inlinevoid COStreamBuffer::DecIndentLevel(size_t step)    THROWS1_NONE{    _ASSERT(m_IndentLevel >= step);    m_IndentLevel -= step;}inlinevoid COStreamBuffer::SetBackLimit(size_t limit){    m_BackLimit = limit;}inlinechar* COStreamBuffer::DoSkip(size_t reserve)    THROWS1((CIOException, bad_alloc)){    char* pos = DoReserve(reserve);    m_CurrentPos = pos + reserve;    m_LineLength += reserve;    return pos;}inlinechar* COStreamBuffer::Skip(size_t count)    THROWS1((CIOException, bad_alloc)){    char* pos = m_CurrentPos;    char* end = pos + count;    if ( end <= m_BufferEnd ) {        // enough space in buffer        m_CurrentPos = end;        m_LineLength += count;        return pos;    }    else {        return DoSkip(count);    }}inlinechar* COStreamBuffer::Reserve(size_t count)    THROWS1((CIOException, bad_alloc)){    char* pos = m_CurrentPos;    char* end = pos + count;    if ( end <= m_BufferEnd ) {        // enough space in buffer        return pos;    }    else {        return DoReserve(count);    }}inlinevoid COStreamBuffer::PutChar(char c)    THROWS1((CIOException)){    *Skip(1) = c;}inlinevoid COStreamBuffer::BackChar(char _DEBUG_ARG(c)){    _ASSERT(m_CurrentPos > m_Buffer);    --m_CurrentPos;    _ASSERT(*m_CurrentPos == c);}inlinevoid COStreamBuffer::PutString(const char* str, size_t length)    THROWS1((CIOException, bad_alloc)){    if ( length < 1024 ) {        memcpy(Skip(length), str, length);    }    else {        Write(str, length);    }}inlinevoid COStreamBuffer::PutString(const char* str)    THROWS1((CIOException, bad_alloc)){    PutString(str, strlen(str));}inlinevoid COStreamBuffer::PutString(const string& str)    THROWS1((CIOException, bad_alloc)){    PutString(str.data(), str.size());}inlinevoid COStreamBuffer::PutIndent(void)    THROWS1((CIOException, bad_alloc)){    if (GetUseIndentation()) {        size_t count = m_IndentLevel;        memset(Skip(count), ' ', count);    }}inlinevoid COStreamBuffer::PutEol(bool indent)    THROWS1((CIOException, bad_alloc)){    char* pos = Reserve(1);    *pos = '\n';    m_CurrentPos = pos + 1;    ++m_Line;    m_LineLength = 0;    if ( indent )        PutIndent();}inlinevoid COStreamBuffer::WrapAt(size_t lineLength, bool keepWord)    THROWS1((CIOException, bad_alloc)){    if ( keepWord ) {        if ( GetCurrentLineLength() > lineLength )            PutEolAtWordEnd(lineLength);    }    else {        if ( GetCurrentLineLength() >= lineLength )            PutEol(false);    }}inlinesize_t COStreamBuffer::GetUsedSpace(void) const{    return static_cast<size_t>(m_CurrentPos - m_Buffer);}inlinesize_t COStreamBuffer::GetAvailableSpace(void) const{    return static_cast<size_t>(m_BufferEnd - m_CurrentPos);}inlinesize_t COStreamBuffer::GetBufferSize(void) const{    return static_cast<size_t>(m_BufferEnd - m_Buffer);}inlinevoid COStreamBuffer::SetUseIndentation(bool set){    m_UseIndentation = set;}inlinebool COStreamBuffer::GetUseIndentation(void) const{    return m_UseIndentation;}#endif /* def STRBUFFER__HPP  &&  ndef STRBUFFER__INL */

⌨️ 快捷键说明

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