<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: tokstack.hxx,v $
 *
 *  $Revision: 1.12 $
 *
 *  last change: $Author: obo $ $Date: 2007-06-13 09:12:06 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _TOKSTACK_HXX
#define _TOKSTACK_HXX

#ifndef _INC_STRING
#include <string.h>
#endif

#ifndef _DEBUG_HXX //autogen
#include <tools/debug.hxx>
#endif

#ifndef SC_COMPILER_HXX
#include "compiler.hxx"
#endif


typedef OpCode DefTokenId;
// in PRODUCT version: ambiguity between OpCode (being USHORT) and UINT16
// Unfortunately a typedef is just a dumb alias and not a real type ...
//typedef UINT16 TokenId;
struct TokenId
{
        UINT16          nId;

                        TokenId() : nId( 0 ) {}
                        TokenId( UINT16 n ) : nId( n ) {}
                        TokenId( const TokenId& r ) : nId( r.nId ) {}
    inline  TokenId&    operator =( const TokenId& r ) { nId = r.nId; return *this; }
    inline  TokenId&    operator =( UINT16 n ) { nId = n; return *this; }
    inline              operator UINT16&() { return nId; }
    inline              operator const UINT16&() const { return nId; }
    inline  BOOL        operator <( UINT16 n ) const { return nId < n; }
    inline  BOOL        operator >( UINT16 n ) const { return nId > n; }
    inline  BOOL        operator <=( UINT16 n ) const { return nId <= n; }
    inline  BOOL        operator >=( UINT16 n ) const { return nId >= n; }
    inline  BOOL        operator ==( UINT16 n ) const { return nId == n; }
    inline  BOOL        operator !=( UINT16 n ) const { return nId != n; }
};


//------------------------------------------------------------------------
struct ComplRefData;
class TokenStack;
class ScToken;


enum E_TYPE
{
    T_Id,       // Id-Folge
    T_Str,      // String
    T_D,        // Double
    T_RefC,     // Cell Reference
    T_RefA,     // Area Reference
    T_RN,       // Range Name
    T_Ext,      // irgendwas Unbekanntes mit Funktionsnamen
    T_Nlf,      // token for natural language formula
    T_Matrix,   // token for inline arrays
    T_Error     // fuer Abfrage im Fehlerfall
};




class TokenPool
{
    // !ACHTUNG!: externe Id-Basis ist 1, interne 0!
    // Ausgabe Id = 0 -> Fehlerfall
    private:
        String**                    ppP_Str;    // Pool fuer Strings
        UINT16                      nP_Str;     // ...mit Groesse
        UINT16                      nP_StrAkt;  // ...und Schreibmarke

        double*                     pP_Dbl;     // Pool fuer Doubles
        UINT16                      nP_Dbl;
        UINT16                      nP_DblAkt;

        SingleRefData**             ppP_RefTr;  // Pool fuer Referenzen
        UINT16                      nP_RefTr;
        UINT16                      nP_RefTrAkt;

        UINT16*                     pP_Id;      // Pool fuer Id-Folgen
        UINT16                      nP_Id;
        UINT16                      nP_IdAkt;
        UINT16                      nP_IdLast;  // letzter Folgen-Beginn

        struct  EXTCONT
        {
            DefTokenId              eId;
            String                  aText;
                                    EXTCONT( const DefTokenId e, const String& r ) :
                                        eId( e ), aText( r ){}
        };
        EXTCONT**                   ppP_Ext;
        UINT16                      nP_Ext;
        UINT16                      nP_ExtAkt;

        struct  NLFCONT
        {
            SingleRefData           aRef;
                                    NLFCONT( const SingleRefData& r ) : aRef( r )   {}
        };
        NLFCONT**                   ppP_Nlf;
        UINT16                      nP_Nlf;
        UINT16                      nP_NlfAkt;

        ScMatrix**                  ppP_Matrix;     // Pool fuer Matricies
        UINT16                      nP_Matrix;
        UINT16                      nP_MatrixAkt;

        UINT16*                     pElement;   // Array mit Indizes fuer Elemente
        E_TYPE*                     pType;      // ...mit Typ-Info
        UINT16*                     pSize;      // ...mit Laengenangabe (Anz. UINT16)
        UINT16                      nElement;
        UINT16                      nElementAkt;

        static const UINT16         nScTokenOff;// Offset fuer SC-Token
#ifdef DBG_UTIL
        UINT16                      nRek;       // Rekursionszaehler
#endif
        ScTokenArray*               pScToken;   // Tokenbastler

        void                        GrowString( void );
        void                        GrowDouble( void );
        void                        GrowTripel( void );
        void                        GrowId( void );
        void                        GrowElement( void );
        void                        GrowExt( void );
        void                        GrowNlf( void );
        void                        GrowMatrix( void );
        void                        GetElement( const UINT16 nId );
        void                        GetElementRek( const UINT16 nId );
    public:
                                    TokenPool( void );
                                    ~TokenPool();
        inline TokenPool&           operator <<( const TokenId nId );
        inline TokenPool&           operator <<( const DefTokenId eId );
        inline TokenPool&           operator <<( TokenStack& rStack );
        void                        operator >>( TokenId& rId );
        inline void                 operator >>( TokenStack& rStack );
        inline const TokenId        Store( void );
        const TokenId               Store( const double& rDouble );

                                    // nur fuer Range-Names
        const TokenId               Store( const UINT16 nIndex );
        inline const TokenId        Store( const INT16 nWert );
        const TokenId               Store( const String& rString );
        const TokenId               Store( const SingleRefData& rTr );
        const TokenId               Store( const ComplRefData& rTr );

        const TokenId               Store( const DefTokenId eId, const String& rName );
                                        // 4 externals (e.g. AddIns, Makros...)
        const TokenId               StoreNlf( const SingleRefData& rTr );
        const TokenId               StoreMatrix( SCSIZE nC, SCSIZE nR );

        inline const TokenId        LastId( void ) const;
        inline const ScTokenArray*  operator []( const TokenId nId );
        void                        Reset( void );<commit_msg>INTEGRATION: CWS odff (1.12.90); FILE MERGED 2008/01/10 14:40:27 dr 172.16.58.3: import/export error codes<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: tokstack.hxx,v $
 *
 *  $Revision: 1.13 $
 *
 *  last change: $Author: kz $ $Date: 2008-03-06 15:49:21 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _TOKSTACK_HXX
#define _TOKSTACK_HXX

#ifndef _INC_STRING
#include <string.h>
#endif

#ifndef _DEBUG_HXX //autogen
#include <tools/debug.hxx>
#endif

#ifndef SC_COMPILER_HXX
#include "compiler.hxx"
#endif


typedef OpCode DefTokenId;
// in PRODUCT version: ambiguity between OpCode (being USHORT) and UINT16
// Unfortunately a typedef is just a dumb alias and not a real type ...
//typedef UINT16 TokenId;
struct TokenId
{
        UINT16          nId;

                        TokenId() : nId( 0 ) {}
                        TokenId( UINT16 n ) : nId( n ) {}
                        TokenId( const TokenId& r ) : nId( r.nId ) {}
    inline  TokenId&    operator =( const TokenId& r ) { nId = r.nId; return *this; }
    inline  TokenId&    operator =( UINT16 n ) { nId = n; return *this; }
    inline              operator UINT16&() { return nId; }
    inline              operator const UINT16&() const { return nId; }
    inline  BOOL        operator <( UINT16 n ) const { return nId < n; }
    inline  BOOL        operator >( UINT16 n ) const { return nId > n; }
    inline  BOOL        operator <=( UINT16 n ) const { return nId <= n; }
    inline  BOOL        operator >=( UINT16 n ) const { return nId >= n; }
    inline  BOOL        operator ==( UINT16 n ) const { return nId == n; }
    inline  BOOL        operator !=( UINT16 n ) const { return nId != n; }
};


//------------------------------------------------------------------------
struct ComplRefData;
class TokenStack;
class ScToken;


enum E_TYPE
{
    T_Id,       // Id-Folge
    T_Str,      // String
    T_D,        // Double
    T_Err,      // Error code
    T_RefC,     // Cell Reference
    T_RefA,     // Area Reference
    T_RN,       // Range Name
    T_Ext,      // irgendwas Unbekanntes mit Funktionsnamen
    T_Nlf,      // token for natural language formula
    T_Matrix,   // token for inline arrays
    T_Error     // fuer Abfrage im Fehlerfall
};




class TokenPool
{
    // !ACHTUNG!: externe Id-Basis ist 1, interne 0!
    // Ausgabe Id = 0 -> Fehlerfall
    private:
        String**                    ppP_Str;    // Pool fuer Strings
        UINT16                      nP_Str;     // ...mit Groesse
        UINT16                      nP_StrAkt;  // ...und Schreibmarke

        double*                     pP_Dbl;     // Pool fuer Doubles
        UINT16                      nP_Dbl;
        UINT16                      nP_DblAkt;

        USHORT*                     pP_Err;     // Pool for error codes
        UINT16                      nP_Err;
        UINT16                      nP_ErrAkt;

        SingleRefData**             ppP_RefTr;  // Pool fuer Referenzen
        UINT16                      nP_RefTr;
        UINT16                      nP_RefTrAkt;

        UINT16*                     pP_Id;      // Pool fuer Id-Folgen
        UINT16                      nP_Id;
        UINT16                      nP_IdAkt;
        UINT16                      nP_IdLast;  // letzter Folgen-Beginn

        struct  EXTCONT
        {
            DefTokenId              eId;
            String                  aText;
                                    EXTCONT( const DefTokenId e, const String& r ) :
                                        eId( e ), aText( r ){}
        };
        EXTCONT**                   ppP_Ext;
        UINT16                      nP_Ext;
        UINT16                      nP_ExtAkt;

        struct  NLFCONT
        {
            SingleRefData           aRef;
                                    NLFCONT( const SingleRefData& r ) : aRef( r )   {}
        };
        NLFCONT**                   ppP_Nlf;
        UINT16                      nP_Nlf;
        UINT16                      nP_NlfAkt;

        ScMatrix**                  ppP_Matrix;     // Pool fuer Matricies
        UINT16                      nP_Matrix;
        UINT16                      nP_MatrixAkt;

        UINT16*                     pElement;   // Array mit Indizes fuer Elemente
        E_TYPE*                     pType;      // ...mit Typ-Info
        UINT16*                     pSize;      // ...mit Laengenangabe (Anz. UINT16)
        UINT16                      nElement;
        UINT16                      nElementAkt;

        static const UINT16         nScTokenOff;// Offset fuer SC-Token
#ifdef DBG_UTIL
        UINT16                      nRek;       // Rekursionszaehler
#endif
        ScTokenArray*               pScToken;   // Tokenbastler

        void                        GrowString( void );
        void                        GrowDouble( void );
        void                        GrowError( void );
        void                        GrowTripel( void );
        void                        GrowId( void );
        void                        GrowElement( void );
        void                        GrowExt( void );
        void                        GrowNlf( void );
        void                        GrowMatrix( void );
        void                        GetElement( const UINT16 nId );
        void                        GetElementRek( const UINT16 nId );
    public:
                                    TokenPool( void );
                                    ~TokenPool();
        inline TokenPool&           operator <<( const TokenId nId );
        inline TokenPool&           operator <<( const DefTokenId eId );
        inline TokenPool&           operator <<( TokenStack& rStack );
        void                        operator >>( TokenId& rId );
        inline void                 operator >>( TokenStack& rStack );
        inline const TokenId        Store( void );
        const TokenId               Store( const double& rDouble );
        const TokenId               StoreError( USHORT nError );

                                    // nur fuer Range-Names
        const TokenId               Store( const UINT16 nIndex );
        inline const TokenId        Store( const INT16 nWert );
        const TokenId               Store( const String& rString );
        const TokenId               Store( const SingleRefData& rTr );
        const TokenId               Store( const ComplRefData& rTr );

        const TokenId               Store( const DefTokenId eId, const String& rName );
                                        // 4 externals (e.g. AddIns, Makros...)
        const TokenId               StoreNlf( const SingleRefData& rTr );
        const TokenId               StoreMatrix( SCSIZE nC, SCSIZE nR );

        inline const TokenId        LastId( void ) const;
        inline const ScTokenArray*  operator []( const TokenId nId );
        void                        Reset( void );
{'fraction_non_alphanumeric': 0.10327455919395466, 'fraction_numerical': 0.018828715365239293, 'mean_word_length': 1.2735862562634217, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648921', 'n_tokens_mistral': 4424, 'n_tokens_neox': 4030, 'n_words': 1345}