tdf#140726 Change func func(<?>) to func <?>(<?>) in Math
[LibreOffice.git] / l10ntools / inc / export.hxx
blob183cecea2531593629474cbbd2db7b9b3a0d67db
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_L10NTOOLS_INC_EXPORT_HXX
21 #define INCLUDED_L10NTOOLS_INC_EXPORT_HXX
23 #include <sal/config.h>
24 #include "po.hxx"
26 #include <cstddef>
27 #include <fstream>
29 #include <osl/file.hxx>
30 #include <osl/file.h>
32 #include <iterator>
33 #include <set>
34 #include <unordered_map>
35 #include <memory>
36 #include <vector>
37 #include <queue>
38 #include <string>
39 #include <string_view>
41 #ifdef _WIN32
42 #include <direct.h>
43 #else
44 #include <unistd.h>
45 #endif
47 #define NO_TRANSLATE_ISO "x-no-translate"
49 class MergeEntrys;
51 typedef std::unordered_map<OString, OString>
52 OStringHashMap;
54 typedef std::unordered_map<OString, bool>
55 OStringBoolHashMap;
57 #define SOURCE_LANGUAGE "en-US"
58 #define X_COMMENT "x-comment"
63 /// Purpose: holds mandatory data to export a single res
64 class ResData
66 public:
67 ResData( const OString &rGId );
68 ResData( const OString &rGId , const OString &rFilename );
70 OString sResTyp;
71 OString sId;
72 OString sGId;
73 OString sFilename;
75 OStringHashMap sText;
81 class ParserQueue;
85 /// Purpose: holds information of data to merge
86 class MergeEntrys
88 friend class MergeDataFile;
89 private:
90 OStringHashMap sText;
91 OStringBoolHashMap bTextFirst;
92 OStringHashMap sQuickHelpText;
93 OStringBoolHashMap bQuickHelpTextFirst;
94 OStringHashMap sTitle;
95 OStringBoolHashMap bTitleFirst;
97 public:
98 MergeEntrys(){};
99 void InsertEntry(const OString &rId, const OString &rText,
100 const OString &rQuickHelpText, const OString &rTitle)
103 sText[ rId ] = rText;
104 bTextFirst[ rId ] = true;
105 sQuickHelpText[ rId ] = rQuickHelpText;
106 bQuickHelpTextFirst[ rId ] = true;
107 sTitle[ rId ] = rTitle;
108 bTitleFirst[ rId ] = true;
110 bool GetText( OString &rReturn, const OString &nLangIndex, bool bDel = false );
113 Generate QTZ string with ResData
114 For executable which works one language and without PO files.
116 static OString GetQTZText(const ResData& rResData, std::string_view rOrigText);
122 /// Purpose: holds information of data to merge, read from PO file
123 class MergeDataFile
125 private:
126 std::unordered_map<OString, std::unique_ptr<MergeEntrys>> aMap;
127 std::set<OString> aLanguageSet;
129 MergeEntrys *GetMergeData( ResData *pResData , bool bCaseSensitive = false );
130 void InsertEntry(std::string_view rTYP, std::string_view rGID,
131 std::string_view rLID, const OString &nLang,
132 const OString &rTEXT, const OString &rQHTEXT,
133 const OString &rTITLE, const OString &sFilename,
134 bool bFirstLang, bool bCaseSensitive);
135 public:
136 explicit MergeDataFile(
137 const OString &rFileName, const OString& rFile,
138 bool bCaseSensitive, bool bWithQtz = true );
139 ~MergeDataFile();
142 std::vector<OString> GetLanguages() const;
144 MergeEntrys *GetMergeEntrys( ResData *pResData );
145 MergeEntrys *GetMergeEntrysCaseSensitive( ResData *pResData );
147 static OString CreateKey(std::string_view rTYP, std::string_view rGID,
148 std::string_view rLID, const OString& rFilename, bool bCaseSensitive);
152 #endif // INCLUDED_L10NTOOLS_INC_EXPORT_HXX
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */