LCOV - code coverage report
Current view: top level - l10ntools/inc - cfgmerge.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 14 0.0 %
Date: 2014-04-14 Functions: 0 7 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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_L10NTOOLS_INC_CFGMERGE_HXX
      21             : #define INCLUDED_L10NTOOLS_INC_CFGMERGE_HXX
      22             : 
      23             : #include "sal/config.h"
      24             : 
      25             : #include <fstream>
      26             : #include <vector>
      27             : 
      28             : #include "boost/unordered_map.hpp"
      29             : #include "po.hxx"
      30             : 
      31             : typedef boost::unordered_map<OString, OString, OStringHash> OStringHashMap;
      32             : 
      33             : 
      34             : 
      35             : // class CfgStackData
      36             : 
      37             : 
      38           0 : class CfgStackData
      39             : {
      40             : friend class CfgParser;
      41             : friend class CfgExport;
      42             : friend class CfgMerge;
      43             : private:
      44             :     OString sTagType;
      45             :     OString sIdentifier;
      46             : 
      47             :     OString sResTyp;
      48             : 
      49             :     OString sTextTag;
      50             :     OString sEndTextTag;
      51             : 
      52             :     OStringHashMap sText;
      53             : public:
      54           0 :     CfgStackData(const OString &rTag, const OString &rId)
      55           0 :         : sTagType( rTag ), sIdentifier( rId )
      56           0 :     {}
      57             : 
      58           0 :     const OString &GetTagType() { return sTagType; }
      59           0 :     const OString &GetIdentifier() { return sIdentifier; }
      60             : 
      61             : };
      62             : 
      63             : 
      64             : // class CfgStack
      65             : 
      66             : 
      67             : class CfgStack
      68             : {
      69             : private:
      70             :     std::vector< CfgStackData* > maList;
      71             : 
      72             : public:
      73           0 :     CfgStack() {}
      74             :     ~CfgStack();
      75             : 
      76             :     CfgStackData *Push(const OString &rTag, const OString &rId);
      77           0 :     CfgStackData *Pop()
      78             :     {
      79           0 :         if (maList.empty())
      80           0 :             return NULL;
      81           0 :         CfgStackData* temp = maList.back();
      82           0 :         maList.pop_back();
      83           0 :         return temp;
      84             :     }
      85             : 
      86             :     CfgStackData *GetStackData();
      87             : 
      88             :     OString GetAccessPath( size_t nPos );
      89             : 
      90           0 :     size_t size() const { return maList.size(); }
      91             : };
      92             : 
      93             : /// Parser for *.xcu files
      94             : class CfgParser
      95             : {
      96             : protected:
      97             :     OString sCurrentResTyp;
      98             :     OString sCurrentIsoLang;
      99             :     OString sCurrentText;
     100             : 
     101             :     OString sLastWhitespace;
     102             : 
     103             :     CfgStack aStack;
     104             :     CfgStackData *pStackData;
     105             : 
     106             :     bool bLocalize;
     107             : 
     108             :     virtual void WorkOnText(
     109             :         OString &rText,
     110             :         const OString &rLangIndex )=0;
     111             : 
     112             :     virtual void WorkOnResourceEnd()=0;
     113             : 
     114             :     virtual void Output(const OString & rOutput)=0;
     115             : 
     116             :     void Error(const OString &rError);
     117             : 
     118             : private:
     119             :     int ExecuteAnalyzedToken( int nToken, char *pToken );
     120             :     void AddText(
     121             :         OString &rText,
     122             :         const OString &rIsoLang,
     123             :         const OString &rResTyp );
     124             : 
     125             :     bool IsTokenClosed(const OString &rToken);
     126             : 
     127             : public:
     128             :     CfgParser();
     129             :     virtual ~CfgParser();
     130             : 
     131             :     int Execute( int nToken, char * pToken );
     132             : };
     133             : 
     134             : /// Export strings from *.xcu files
     135             : class CfgExport : public CfgParser
     136             : {
     137             : private:
     138             :     OString sPath;
     139             :     PoOfstream pOutputStream;
     140             : 
     141             : protected:
     142             :     virtual void WorkOnText(
     143             :         OString &rText,
     144             :         const OString &rIsoLang
     145             :         ) SAL_OVERRIDE;
     146             : 
     147             :     void WorkOnResourceEnd() SAL_OVERRIDE;
     148             :     void Output(const OString& rOutput) SAL_OVERRIDE;
     149             : public:
     150             :     CfgExport(
     151             :         const OString &rOutputFile,
     152             :         const OString &rFilePath
     153             :     );
     154             :     virtual ~CfgExport();
     155             : };
     156             : 
     157             : /// Merge strings to *.xcu files
     158             : class CfgMerge : public CfgParser
     159             : {
     160             : private:
     161             :     MergeDataFile *pMergeDataFile;
     162             :     std::vector<OString> aLanguages;
     163             :     ResData *pResData;
     164             : 
     165             :     OString sFilename;
     166             :     bool bEnglish;
     167             : 
     168             :     std::ofstream pOutputStream;
     169             : 
     170             : protected:
     171             :     virtual void WorkOnText(OString &rText, const OString &rLangIndex) SAL_OVERRIDE;
     172             : 
     173             :     void WorkOnResourceEnd() SAL_OVERRIDE;
     174             : 
     175             :     void Output(const OString& rOutput) SAL_OVERRIDE;
     176             : public:
     177             :     CfgMerge(
     178             :         const OString &rMergeSource, const OString &rOutputFile,
     179             :         const OString &rFilename, const OString &rLanguage );
     180             :     virtual ~CfgMerge();
     181             : };
     182             : 
     183             : #endif
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10