LCOV - code coverage report
Current view: top level - libreoffice/l10ntools/inc - po.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-12-27 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef _PO_INCLUDED
      11             : #define _PO_INCLUDED
      12             : 
      13             : #include <fstream>
      14             : #include <rtl/string.hxx>
      15             : #include <boost/noncopyable.hpp>
      16             : 
      17             : class PoOfstream;
      18             : class PoIfstream;
      19             : class GenPoEntry;
      20             : 
      21             : 
      22             : /** Interface to use po entries in localization
      23             : 
      24             :     PoEntry based on GenPoEntry class which stores attributes
      25             :     of general po entry(see po.cxx). It makes easy to get/set
      26             :     all information needed to localize one english(US) string.
      27             :     It contains some basic checkings and some string
      28             :     transformations between po string and string used by
      29             :     localization tools.
      30             : */
      31             : class PoEntry
      32             : {
      33             : private:
      34             : 
      35             :     GenPoEntry* m_pGenPo;
      36             :     bool m_bIsInitialized;
      37             : 
      38             : public:
      39             : 
      40             :     friend class PoOfstream;
      41             :     friend class PoIfstream;
      42             : 
      43             :     enum SDFPART { PROJECT, SOURCEFILE, DUMMY, RESOURCETYPE, GROUPID,
      44             :                     LOCALID, HELPID, PLATFORM, WIDTH, LANGUAGEID,
      45             :                     TEXT, HELPTEXT, QUICKHELPTEXT, TITLE, TIMESTAMP };
      46             :     enum TYPE { TTEXT=TEXT, TQUICKHELPTEXT=QUICKHELPTEXT, TTITLE=TITLE };
      47             :     enum Exception { INVALIDSDFLINE };
      48             : 
      49             :                     PoEntry();
      50             :                     PoEntry(const OString& rSDFLine,
      51             :                             const TYPE eType = TTEXT);
      52             :                     ~PoEntry();
      53             : 
      54             :                     PoEntry( const PoEntry& rPo );
      55             :     PoEntry&        operator=( const PoEntry& rPo );
      56             : 
      57             :     OString         getSourceFile() const;
      58             :     OString         getGroupId() const;
      59             :     OString         getLocalId() const;
      60             :     OString         getResourceType() const;
      61             :     TYPE            getType() const;
      62             :     OString         getMsgId() const;
      63             :     OString         getMsgStr() const;
      64             :     bool            isFuzzy() const;
      65             :     OString         getKeyId() const;
      66             :     void            setMsgId(const OString& rUnTransStr);
      67             :     void            setMsgStr(const OString& rTransStr);
      68             :     void            setFuzzy(const bool bFuzzy);
      69             : 
      70             :     static bool     IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2);
      71             : 
      72             : };
      73             : 
      74             : /** Interface to work with header of po/pot files
      75             : 
      76             :     This class stores informations which are in header of
      77             :     a po file. It's main function to generate header to
      78             :     template po files(pot).
      79             : */
      80             : class PoHeader: private boost::noncopyable
      81             : {
      82             : private:
      83             : 
      84             :     GenPoEntry* m_pGenPo;
      85             :     bool m_bIsInitialized;
      86             : 
      87             : public:
      88             : 
      89             :     friend class PoOfstream;
      90             :     friend class PoIfstream;
      91             : 
      92             :                     PoHeader();
      93             :                     PoHeader( const OString& rExtSrc );
      94             :                     PoHeader( std::ifstream& rOldPo );
      95             :                     ~PoHeader();
      96             : };
      97             : 
      98             : /** Interface to write po entry to files as output streams
      99             : */
     100             : class PoOfstream: private boost::noncopyable
     101             : {
     102             : private:
     103             : 
     104             :     std::ofstream   m_aOutPut;
     105             :     bool            m_bIsAfterHeader;
     106             : 
     107             : public:
     108             :             PoOfstream();
     109             :             ~PoOfstream();
     110           0 :     bool    isOpen() const  { return m_aOutPut.is_open(); }
     111             : 
     112             :     void    open(const OString& rFileName);
     113             :     void    close();
     114             :     void    writeHeader(const PoHeader& rHeader);
     115             :     void    writeEntry(const PoEntry& rPo);
     116             : };
     117             : 
     118             : /** Interface to read po entry from files as input streams
     119             : */
     120             : class PoIfstream: private boost::noncopyable
     121             : {
     122             : private:
     123             : 
     124             :     std::ifstream   m_aInPut;
     125             :     bool            m_bEof;
     126             : 
     127             : public:
     128             : 
     129             :     enum Exception { INVALIDENTRY };
     130             : 
     131             :             PoIfstream();
     132             :             ~PoIfstream();
     133           0 :     bool    isOpen() const  { return m_aInPut.is_open(); }
     134           0 :     bool    eof() const     { return m_bEof; }
     135             : 
     136             :     void    open(const OString& rFileName);
     137             :     void    close();
     138             :     void    readEntry(PoEntry& rPo);
     139             : };
     140             : 
     141             : #endif // _PO_INCLUDED
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10