diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-09 11:29:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-13 09:38:13 +0000 |
commit | e2e76df7e48fb77f1e802f57c7d9a22eb8c74c5a (patch) | |
tree | 15a072f5563c843939b0900aed256b7c89340407 /rsc | |
parent | 417bc898802630c567d970d0283312697acdd5ff (diff) |
create strong_int template and use it in tools::UniqueIndex
an experiment to see how useful a strong_int template works out
Change-Id: Ib77700350f0fa3b018a1926233adf7a40d728d16
Reviewed-on: https://gerrit.libreoffice.org/34072
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'rsc')
-rw-r--r-- | rsc/inc/rscclobj.hxx | 8 | ||||
-rw-r--r-- | rsc/inc/rscdef.hxx | 179 | ||||
-rw-r--r-- | rsc/inc/rscpar.hxx | 13 | ||||
-rw-r--r-- | rsc/inc/rscrsc.hxx | 4 | ||||
-rw-r--r-- | rsc/source/parser/rscdb.cxx | 10 | ||||
-rw-r--r-- | rsc/source/parser/rscpar.cxx | 4 | ||||
-rw-r--r-- | rsc/source/res/rscclobj.cxx | 4 | ||||
-rw-r--r-- | rsc/source/rsc/rsc.cxx | 4 | ||||
-rw-r--r-- | rsc/source/tools/rscdef.cxx | 12 |
9 files changed, 122 insertions, 116 deletions
diff --git a/rsc/inc/rscclobj.hxx b/rsc/inc/rscclobj.hxx index 7bbc5f1c1f46..c8adca501b6d 100644 --- a/rsc/inc/rscclobj.hxx +++ b/rsc/inc/rscclobj.hxx @@ -28,18 +28,18 @@ class ObjNode : public IdNode { RscId aRscId; // Id der Resource CLASS_DATA pRscObj;// pointer to a resourceobject - sal_uLong lFileKey;// Dateischluessel + RscFileTab::Index lFileKey;// Dateischluessel protected: using NameNode::Search; public: using NameNode::Insert; - ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ); - ObjNode * DelObjNode( RscTop * pClass, sal_uLong lFileKey ); + ObjNode( const RscId & rId, CLASS_DATA pData, RscFileTab::Index lKey ); + ObjNode * DelObjNode( RscTop * pClass, RscFileTab::Index lFileKey ); sal_uInt32 GetId() const override; const RscId& GetRscId() const { return aRscId; } - sal_uLong GetFileKey() const { return lFileKey; }; + RscFileTab::Index GetFileKey() const { return lFileKey; }; ObjNode* Search( const RscId &rName ) const //< search the index in the b-tree { return static_cast<ObjNode *>(IdNode::Search( rName.GetNumber() )); diff --git a/rsc/inc/rscdef.hxx b/rsc/inc/rscdef.hxx index e336fac9608c..1aeeead37e1c 100644 --- a/rsc/inc/rscdef.hxx +++ b/rsc/inc/rscdef.hxx @@ -113,67 +113,8 @@ public: bool IsId() const { return !aExp.IsNothing(); } }; -/*********** R s c D e f i n e *******************************************/ -class RscDefine : public NameNode -{ -friend class RscFileTab; -friend class RscDefineList; -friend class RscDefTree; -friend class RscExpression; -friend class RscId; - - sal_uLong lFileKey; // file the define belongs to - sal_uInt32 nRefCount; // reference count to this object - sal_Int32 lId; // identifier - RscExpression * pExp; // expression - OString m_aName; - - virtual COMPARE Compare( const NameNode * ) const override; - virtual COMPARE Compare( const void * ) const override; - -protected: - - RscDefine( sal_uLong lFileKey, const OString& rDefName, - sal_Int32 lDefId ); - RscDefine( sal_uLong lFileKey, const OString& rDefName, - RscExpression * pExpression ); - virtual ~RscDefine() override; - - void IncRef() { nRefCount++; } - void DecRef(); - void DefineToNumber(); - -public: - sal_uLong GetFileKey() const { return lFileKey; } - void Evaluate(); - sal_Int32 GetNumber() const { return lId; } - RscDefine* Search( const char * ) const; - const OString& GetName() const { return m_aName; } -}; - typedef ::std::vector< RscDefine* > RscSubDefList; -class RscDefineList -{ -friend class RscFile; -friend class RscFileTab; -private: - RscSubDefList maList; - // pExpression always belongs to the list - RscDefine * New( sal_uLong lFileKey, const OString& rDefName, - sal_Int32 lDefId, size_t lPos ); - RscDefine * New( sal_uLong lFileKey, const OString& rDefName, - RscExpression * pExpression, size_t lPos ); - bool Remove(); - size_t GetPos( RscDefine* item ) - { - for ( size_t i = 0, n = maList.size(); i < n; ++i ) - if ( maList[ i ] == item ) - return i; - return size_t(-1); - } -}; - /*********** R s c E x p r e s s i o n ***********************************/ class RscExpression { @@ -190,37 +131,10 @@ public: }; /********************** R S C F I L E ************************************/ -class RscDepend -{ - sal_uLong lKey; -public: - RscDepend( sal_uLong lIncKey ){ lKey = lIncKey; }; - sal_uLong GetFileKey(){ return lKey; } -}; +class RscDepend; typedef ::std::vector< RscDepend* > RscDependList; -// table containing al file names -class RscFile -{ -friend class RscFileTab; - bool bIncFile; // whether it is an include file -public: - bool bLoaded; // whether the file is loaded - bool bScanned; // whether the file searches for include - OString aFileName; // file name - OString aPathName; // file path and name - RscDefineList aDefLst; // list of defines - RscDependList aDepLst; // list of depend - - RscFile(); - ~RscFile(); - void InsertDependFile( sal_uLong lDepFile ); - bool Depend( sal_uLong lDepend, sal_uLong lFree ); - void SetIncFlag(){ bIncFile = true; }; - bool IsIncFile(){ return bIncFile; }; -}; - class RscDefTree { RscDefine * pDefRoot; @@ -234,6 +148,8 @@ public: void Remove( RscDefine * pDef ); }; +class RscFile; + class RscFileTab : public UniqueIndex<RscFile> { public: @@ -271,6 +187,95 @@ public: RscFile * GetFile( Index lFileKey ){ return Get( lFileKey ); } }; +class RscDepend +{ + RscFileTab::Index lKey; +public: + RscDepend( RscFileTab::Index lIncKey ){ lKey = lIncKey; }; + RscFileTab::Index GetFileKey(){ return lKey; } +}; + +class RscDefineList +{ +friend class RscFile; +friend class RscFileTab; +private: + RscSubDefList maList; + // pExpression always belongs to the list + RscDefine * New( RscFileTab::Index lFileKey, const OString& rDefName, + sal_Int32 lDefId, size_t lPos ); + RscDefine * New( RscFileTab::Index lFileKey, const OString& rDefName, + RscExpression * pExpression, size_t lPos ); + bool Remove(); + size_t GetPos( RscDefine* item ) + { + for ( size_t i = 0, n = maList.size(); i < n; ++i ) + if ( maList[ i ] == item ) + return i; + return size_t(-1); + } +}; + +// table containing all file names +class RscFile +{ +friend class RscFileTab; + bool bIncFile; // whether it is an include file +public: + bool bLoaded; // whether the file is loaded + bool bScanned; // whether the file searches for include + OString aFileName; // file name + OString aPathName; // file path and name + RscDefineList aDefLst; // list of defines + RscDependList aDepLst; // list of depend + + RscFile(); + ~RscFile(); + void InsertDependFile( RscFileTab::Index lDepFile ); + bool Depend( RscFileTab::Index lDepend, RscFileTab::Index lFree ); + void SetIncFlag(){ bIncFile = true; }; + bool IsIncFile(){ return bIncFile; }; +}; + +/*********** R s c D e f i n e *******************************************/ +class RscDefine : public NameNode +{ +friend class RscFileTab; +friend class RscDefineList; +friend class RscDefTree; +friend class RscExpression; +friend class RscId; + + RscFileTab::Index lFileKey; // file the define belongs to + sal_uInt32 nRefCount; // reference count to this object + sal_Int32 lId; // identifier + RscExpression * pExp; // expression + OString m_aName; + + virtual COMPARE Compare( const NameNode * ) const override; + virtual COMPARE Compare( const void * ) const override; + +protected: + + RscDefine( RscFileTab::Index lFileKey, const OString& rDefName, + sal_Int32 lDefId ); + RscDefine( RscFileTab::Index lFileKey, const OString& rDefName, + RscExpression * pExpression ); + virtual ~RscDefine() override; + + void IncRef() { nRefCount++; } + void DecRef(); + void DefineToNumber(); + +public: + RscFileTab::Index GetFileKey() const { return lFileKey; } + void Evaluate(); + sal_Int32 GetNumber() const { return lId; } + RscDefine* Search( const char * ) const; + const OString& GetName() const { return m_aName; } +}; + + #endif // INCLUDED_RSC_INC_RSCDEF_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/inc/rscpar.hxx b/rsc/inc/rscpar.hxx index 695ea6e3e988..265158ba185c 100644 --- a/rsc/inc/rscpar.hxx +++ b/rsc/inc/rscpar.hxx @@ -21,6 +21,7 @@ #include <rsctools.hxx> #include <rscerror.h> +#include <rscdef.hxx> #include <tools/solar.h> class RscTypCont; @@ -33,8 +34,8 @@ class RscFileInst sal_uInt32 nErrorLine; // Zeile des ersten Fehlers sal_uInt32 nErrorPos; // Position des ersten Fehlers sal_uInt32 nLineNo; // Zeile in der Eingabedatei - sal_uLong lFileIndex; // Index auf Eingabedatei - sal_uLong lSrcIndex; // Index auf Basisdatei + RscFileTab::Index lFileIndex; // Index auf Eingabedatei + RscFileTab::Index lSrcIndex; // Index auf Basisdatei FILE * fInputFile; // Eingabedatei char * pInput; // Lesepuffer static const sal_uInt32 nInputBufLen = READBUFFER_MAX; // Laenge des Lesepuffers @@ -49,12 +50,12 @@ class RscFileInst public: RscTypCont * pTypCont; void Init(); // ctor initialisieren - RscFileInst( RscTypCont * pTC, sal_uLong lIndexSrc, - sal_uLong lFileIndex, FILE * fFile ); + RscFileInst( RscTypCont * pTC, RscFileTab::Index lIndexSrc, + RscFileTab::Index lFileIndex, FILE * fFile ); ~RscFileInst(); bool IsEof() const { return bEof; } - void SetFileIndex( sal_uLong lFIndex ) { lFileIndex = lFIndex; } - sal_uLong GetFileIndex() { return lFileIndex; } + void SetFileIndex( RscFileTab::Index lFIndex ) { lFileIndex = lFIndex; } + RscFileTab::Index GetFileIndex() { return lFileIndex; } void SetLineNo( sal_uInt32 nLine ) { nLineNo = nLine; } sal_uInt32 GetLineNo() { return nLineNo; } sal_uInt32 GetScanPos() { return nScanPos; } diff --git a/rsc/inc/rscrsc.hxx b/rsc/inc/rscrsc.hxx index 8f2bc6c4c7bf..4dccfa9f227a 100644 --- a/rsc/inc/rscrsc.hxx +++ b/rsc/inc/rscrsc.hxx @@ -88,8 +88,8 @@ public: ERRTYPE Start(); // read include statements - ERRTYPE IncludeParser( sal_uLong lFileKey ); - ERRTYPE ParseOneFile( sal_uLong lFileKey, const RscCmdLine::OutputFile* pOutputFile, const WriteRcContext* pContext ); + ERRTYPE IncludeParser( RscFileTab::Index lFileKey ); + ERRTYPE ParseOneFile( RscFileTab::Index lFileKey, const RscCmdLine::OutputFile* pOutputFile, const WriteRcContext* pContext ); ERRTYPE Link(); void EndCompile(); }; diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx index bb0fecf03706..1675cc4f8d1e 100644 --- a/rsc/source/parser/rscdb.cxx +++ b/rsc/source/parser/rscdb.cxx @@ -239,7 +239,7 @@ private: ERRTYPE aError; // contains the first field RscTypCont* pTypCont; FILE * fOutput; // output file - sal_uLong lFileKey; // what source file + RscFileTab::Index lFileKey; // what source file RscTop * pClass; RscEnumerateObj(RscTypCont* pTC, FILE* pOutputFile) @@ -358,7 +358,7 @@ public: pRoot->EnumNodes( LINK( this, RscEnumerateRef, CallBackWriteRc ) ); return aEnumObj.aError; } - ERRTYPE const & WriteSrc( sal_uLong lFileKey ) + ERRTYPE const & WriteSrc( RscFileTab::Index lFileKey ) { aEnumObj.lFileKey = lFileKey; @@ -424,14 +424,14 @@ void RscTypCont::WriteSrc( FILE * fOutput, RscFileTab::Index nFileKey ) class RscDel { - sal_uLong lFileKey; + RscFileTab::Index lFileKey; DECL_LINK( Delete, const NameNode&, void ); public: - RscDel( RscTop * pRoot, sal_uLong lKey ); + RscDel( RscTop * pRoot, RscFileTab::Index lKey ); }; -inline RscDel::RscDel( RscTop * pRoot, sal_uLong lKey ) +inline RscDel::RscDel( RscTop * pRoot, RscFileTab::Index lKey ) : lFileKey(lKey) { pRoot->EnumNodes( LINK( this, RscDel, Delete ) ); diff --git a/rsc/source/parser/rscpar.cxx b/rsc/source/parser/rscpar.cxx index d81d3aae9c57..4fc1b11f8cdf 100644 --- a/rsc/source/parser/rscpar.cxx +++ b/rsc/source/parser/rscpar.cxx @@ -32,8 +32,8 @@ void RscFileInst::Init() bEof = false; } -RscFileInst::RscFileInst( RscTypCont * pTC, sal_uLong lIndexSrc, - sal_uLong lFIndex, FILE * fFile ) +RscFileInst::RscFileInst( RscTypCont * pTC, RscFileTab::Index lIndexSrc, + RscFileTab::Index lFIndex, FILE * fFile ) : nErrorLine(0) , nErrorPos(0) { diff --git a/rsc/source/res/rscclobj.cxx b/rsc/source/res/rscclobj.cxx index 80969f704553..29184286cd8d 100644 --- a/rsc/source/res/rscclobj.cxx +++ b/rsc/source/res/rscclobj.cxx @@ -56,14 +56,14 @@ ObjNode * RefNode::GetObjNode( const RscId & rRscId ) return nullptr; } -ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ) +ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, RscFileTab::Index lKey ) : aRscId(rId) , pRscObj(pData) , lFileKey(lKey) { } -ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ) +ObjNode * ObjNode::DelObjNode( RscTop * pClass, RscFileTab::Index nFileKey ) { ObjNode * pRetNode = this; diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx index 0b44a618e5f7..8ccfd83f6c77 100644 --- a/rsc/source/rsc/rsc.cxx +++ b/rsc/source/rsc/rsc.cxx @@ -405,7 +405,7 @@ void RscCompiler::EndCompile() } } -ERRTYPE RscCompiler::IncludeParser( sal_uLong lFileKey ) +ERRTYPE RscCompiler::IncludeParser( RscFileTab::Index lFileKey ) { FILE * finput; RscFile * pFName; @@ -448,7 +448,7 @@ ERRTYPE RscCompiler::IncludeParser( sal_uLong lFileKey ) return aError; } -ERRTYPE RscCompiler::ParseOneFile( sal_uLong lFileKey, +ERRTYPE RscCompiler::ParseOneFile( RscFileTab::Index lFileKey, const RscCmdLine::OutputFile* pOutputFile, const WriteRcContext* pContext ) { diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx index 2e2a05767bfb..4ff0216cc547 100644 --- a/rsc/source/tools/rscdef.cxx +++ b/rsc/source/tools/rscdef.cxx @@ -114,7 +114,7 @@ OString RscId::GetName() const return aStr.makeStringAndClear(); } -RscDefine::RscDefine( sal_uLong lKey, const OString& rDefName, sal_Int32 lDefId ) +RscDefine::RscDefine( RscFileTab::Index lKey, const OString& rDefName, sal_Int32 lDefId ) : m_aName( rDefName ) { nRefCount = 0; @@ -123,7 +123,7 @@ RscDefine::RscDefine( sal_uLong lKey, const OString& rDefName, sal_Int32 lDefId pExp = nullptr; } -RscDefine::RscDefine( sal_uLong lKey, const OString& rDefName, +RscDefine::RscDefine( RscFileTab::Index lKey, const OString& rDefName, RscExpression * pExpression ) : lId(0), m_aName( rDefName ) { @@ -192,7 +192,7 @@ COMPARE RscDefine::Compare( const void * pSearch ) const return EQUAL; } -RscDefine * RscDefineList::New( sal_uLong lFileKey, const OString& rDefName, +RscDefine * RscDefineList::New( RscFileTab::Index lFileKey, const OString& rDefName, sal_Int32 lDefId, size_t lPos ) { RscDefine * pDef; @@ -212,7 +212,7 @@ RscDefine * RscDefineList::New( sal_uLong lFileKey, const OString& rDefName, return pDef; } -RscDefine * RscDefineList::New( sal_uLong lFileKey, const OString& rDefName, +RscDefine * RscDefineList::New( RscFileTab::Index lFileKey, const OString& rDefName, RscExpression * pExpression, size_t lPos ) { RscDefine * pDef; @@ -386,7 +386,7 @@ RscFile::~RscFile() while( aDefLst.Remove() ) ; } -bool RscFile::Depend( sal_uLong lDepend, sal_uLong lFree ) +bool RscFile::Depend( RscFileTab::Index lDepend, RscFileTab::Index lFree ) { for ( size_t i = aDepLst.size(); i > 0; ) { @@ -405,7 +405,7 @@ bool RscFile::Depend( sal_uLong lDepend, sal_uLong lFree ) return true; } -void RscFile::InsertDependFile( sal_uLong lIncFile ) +void RscFile::InsertDependFile( RscFileTab::Index lIncFile ) { for ( size_t i = 0, n = aDepLst.size(); i < n; ++i ) { |