Debian Codegraph @

src/ApvlvUtil.h

raw
1 /*
2 * This file is part of the apvlv package
3 *
4 * Copyright (C) 2008 Alf.
5 *
6 * Contact: Alf <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2.0 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23 /* @CPPFILE ApvlvUtil.h
24 *
25 * Author: Alf <[email protected]>
26 */
27
28 #ifndef _APVLV_UTIL_H_
29 #define _APVLV_UTIL_H_
30
31 #include <QImage>
32 #include <QXmlStreamReader>
33 #include <filesystem>
34 #include <string>
35 #include <vector>
36
37 namespace apvlv
38 {
39
40 // Global files
41 extern std::string ScriptDir;
42 extern std::string HelpPdf;
43 extern std::string IniExam;
44 extern std::string IconDir;
45 extern std::string IconFile;
46 extern std::string IconPage;
47 extern std::string Translations;
48
49 extern std::string IniFile;
50 extern std::string SessionFile;
51 extern std::string LogFile;
52 extern std::string NotesDir;
53 extern std::string UserScriptDir;
54
55 void getRuntimePaths ();
56
57 #ifdef WIN32
58 const char PATH_SEP_C = '\\';
59 const char *const PATH_SEP_S = "\\";
60 #else
61 const char PATH_SEP_C = '/';
62 const char *const PATH_SEP_S = "/";
63 #endif
64
65 std::optional<std::unique_ptr<QXmlStreamReader>>
66 xmlContentGetElement (const char *content, size_t length,
67 const std::vector<std::string> &names);
68
69 std::string xmlStreamGetAttributeValue (QXmlStreamReader *xml,
70 const std::string &key);
71
72 std::string xmlContentGetAttributeValue (const char *content, size_t length,
73 const std::vector<std::string> &names,
74 const std::string &key);
75
76 std::string filenameExtension (const std::string &filename);
77
78 void imageArgb32ToRgb32 (QImage &image, int left, int top, int right,
79 int bottom);
80
81 std::string templateBuild (std::string_view temp, std::string_view token,
82 std::string_view real);
83
84 qint64 parseFormattedDataSize (const QString &sizeStr);
85
86 qint64 filesystemTimeToMSeconds (std::filesystem::file_time_type ftt);
87
88 }
89 #endif
90
91 // Local Variables:
92 // mode: c++
93 // mode: c++
94 // End: