LCOV - code coverage report
Current view: top level - l10ntools/inc - cfgmerge.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 13 0.0 %
Date: 2015-06-13 12:38:46 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 <unordered_map>
      27             : #include <vector>
      28             : #include "po.hxx"
      29             : 
      30             : typedef std::unordered_map<OString, OString, OStringHash> OStringHashMap;
      31             : 
      32             : 
      33             : 
      34             : // class CfgStackData
      35             : 
      36             : 
      37           0 : class CfgStackData
      38             : {
      39             : friend class CfgParser;
      40             : friend class CfgExport;
      41             : friend class CfgMerge;
      42             : private:
      43             :     OString sTagType;
      44             :     OString sIdentifier;
      45             : 
      46             :     OString sResTyp;
      47             : 
      48             :     OString sTextTag;
      49             :     OString sEndTextTag;
      50             : 
      51             :     OStringHashMap sText;
      52             : public:
      53           0 :     CfgStackData(const OString &rTag, const OString &rId)
      54           0 :         : sTagType( rTag ), sIdentifier( rId )
      55           0 :     {}
      56             : 
      57           0 :     const OString &GetTagType() { return sTagType; }
      58           0 :     const OString &GetIdentifier() { return sIdentifier; }
      59             : 
      60             : };
      61             : 
      62             : 
      63             : // class CfgStack
      64             : 
      65             : 
      66             : class CfgStack
      67             : {
      68             : private:
      69             :     std::vector< CfgStackData* > maList;
      70             : 
      71             : public:
      72           0 :     CfgStack() {}
      73             :     ~CfgStack();
      74             : 
      75             :     CfgStackData *Push(const OString &rTag, const OString &rId);
      76           0 :     void Pop()
      77             :     {
      78           0 :         if (!maList.empty())
      79             :         {
      80           0 :             delete maList.back();
      81           0 :             maList.pop_back();
      82             :         }
      83           0 :     }
      84             : 
      85             :     CfgStackData *GetStackData();
      86             : 
      87             :     OString GetAccessPath( size_t nPos );
      88             : 
      89           0 :     size_t size() const { return maList.size(); }
      90             : };
      91             : 
      92             : /// Parser for *.xcu files
      93             : class CfgParser
      94             : {
      95             : protected:
      96             :     OString sCurrentResTyp;
      97             :     OString sCurrentIsoLang;
      98             :     OString sCurrentText;
      99             : 
     100             :     OString sLastWhitespace;
     101             : 
     102             :     CfgStack aStack;
     103             :     CfgStackData *pStackData;
     104             : 
     105             :     bool bLocalize;
     106             : 
     107             :     virtual void WorkOnText(
     108             :         OString &rText,
     109             :         const OString &rLangIndex )=0;
     110             : 
     111             :     virtual void WorkOnResourceEnd()=0;
     112             : 
     113             :     virtual void Output(const OString & rOutput)=0;
     114             : 
     115             :     static void Error(const OString &rError);
     116             : 
     117             : private:
     118             :     int ExecuteAnalyzedToken( int nToken, char *pToken );
     119             :     void AddText(
     120             :         OString &rText,
     121             :         const OString &rIsoLang,
     122             :         const OString &rResTyp );
     123             : 
     124             :     static bool IsTokenClosed(const OString &rToken);
     125             : 
     126             : public:
     127             :     CfgParser();
     128             :     virtual ~CfgParser();
     129             : 
     130             :     int Execute( int nToken, char * pToken );
     131             : };
     132             : 
     133             : /// Export strings from *.xcu files
     134             : class CfgExport : public CfgParser
     135             : {
     136             : private:
     137             :     OString sPath;
     138             :     PoOfstream pOutputStream;
     139             : 
     140             : protected:
     141             :     virtual void WorkOnText(
     142             :         OString &rText,
     143             :         const OString &rIsoLang
     144             :         ) SAL_OVERRIDE;
     145             : 
     146             :     void WorkOnResourceEnd() SAL_OVERRIDE;
     147             :     void Output(const OString& rOutput) SAL_OVERRIDE;
     148             : public:
     149             :     CfgExport(
     150             :         const OString &rOutputFile,
     151             :         const OString &rFilePath
     152             :     );
     153             :     virtual ~CfgExport();
     154             : };
     155             : 
     156             : /// Merge strings to *.xcu files
     157             : class CfgMerge : public CfgParser
     158             : {
     159             : private:
     160             :     MergeDataFile *pMergeDataFile;
     161             :     std::vector<OString> aLanguages;
     162             :     ResData *pResData;
     163             : 
     164             :     OString sFilename;
     165             :     bool bEnglish;
     166             : 
     167             :     std::ofstream pOutputStream;
     168             : 
     169             : protected:
     170             :     virtual void WorkOnText(OString &rText, const OString &rLangIndex) SAL_OVERRIDE;
     171             : 
     172             :     void WorkOnResourceEnd() SAL_OVERRIDE;
     173             : 
     174             :     void Output(const OString& rOutput) SAL_OVERRIDE;
     175             : public:
     176             :     CfgMerge(
     177             :         const OString &rMergeSource, const OString &rOutputFile,
     178             :         const OString &rFilename, const OString &rLanguage );
     179             :     virtual ~CfgMerge();
     180             : };
     181             : 
     182             : #endif
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11