• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pt_VarSet.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t -*- */
00002 /* AbiWord
00003  * Copyright (C) 1998 AbiSource, Inc.
00004  * Copyright (c) 2016 Hubert Figuière
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 
00023 #ifndef PT_VARSET_H
00024 #define PT_VARSET_H
00025 
00026 #include "ut_types.h"
00027 #include "ut_growbuf.h"
00028 #include "pt_Types.h"
00029 #include "pp_TableAttrProp.h"
00030 
00031 class PD_Document;
00032 
00033 class ABI_EXPORT pt_VarSet
00034 {
00035 public:
00036     pt_VarSet();
00037     ~pt_VarSet();
00038 
00039     void                    setPieceTableState(PTState pts);
00040     bool                    appendBuf(const UT_UCSChar * pBuf, UT_uint32 length, PT_BufIndex * pbi);
00041     bool                    storeAP(const PP_PropertyVector & vecAttributes, PT_AttrPropIndex * papi);
00042     inline const UT_UCSChar *getPointer(PT_BufIndex bi) const {  return (UT_UCSChar *)m_buffer[_varsetFromBufIndex(bi)].getPointer(_subscriptFromBufIndex(bi)); }
00043     inline PT_BufIndex      getBufIndex(PT_BufIndex bi, UT_uint32 offset) const
00044     {     return _makeBufIndex(_varsetFromBufIndex(bi),
00045                                _subscriptFromBufIndex(bi)+offset);
00046     }
00047 
00048     bool                    isContiguous(PT_BufIndex bi, UT_uint32 length, PT_BufIndex bi2) const;
00049     inline const PP_AttrProp *getAP(PT_AttrPropIndex api) const
00050     {
00051         return m_tableAttrProp[_varsetFromAPIndex(api)].getAP(_subscriptFromAPIndex(api));
00052     }
00053     bool                    mergeAP(PTChangeFmt ptc,PT_AttrPropIndex apiOld,
00054                                     const PP_PropertyVector & attributes,
00055                                     const PP_PropertyVector & properties,
00056                                     PT_AttrPropIndex * papiNew,
00057                                     PD_Document * pDoc);
00058     bool                    addIfUniqueAP(PP_AttrProp * pAP, PT_AttrPropIndex * papi);
00059     bool                 overwriteBuf(UT_UCSChar * pBuf, UT_uint32 length, PT_BufIndex * pbi);
00060 
00061 private:
00062     inline UT_uint32 _subscriptFromBufIndex(PT_BufIndex bi) const
00063     {
00064         return (bi & 0x7fffffff);
00065     }
00066     inline UT_uint32 _subscriptFromAPIndex(PT_AttrPropIndex api) const
00067     {
00068         return (api & 0x7fffffff);
00069     }
00070 
00071     inline UT_uint32 _varsetFromBufIndex(PT_BufIndex bi) const
00072     {
00073         return (bi >> 31);
00074     }
00075 
00076     inline UT_uint32 _varsetFromAPIndex(PT_AttrPropIndex api) const
00077     {
00078         return (api >> 31);
00079     }
00080 
00081     inline PT_BufIndex _makeBufIndex(UT_uint32 varset, UT_uint32 subscript) const
00082     {
00083         return ((varset<<31)|subscript);
00084     }
00085 
00086     inline PT_AttrPropIndex _makeAPIndex(UT_uint32 varset, UT_uint32 subscript) const
00087     {
00088         return ((varset<<31)|subscript);
00089     }
00090 
00091     bool                    _finishConstruction(void);
00092 
00093     bool                    m_bInitialized;
00094     UT_uint32               m_currentVarSet;
00095 
00096     UT_GrowBuf              m_buffer[2];
00097     pp_TableAttrProp        m_tableAttrProp[2];
00098 };
00099 
00100 
00101 #endif /* PT_VARSET_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1