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

pt_VarSet.h

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

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1