"Fossies" - the Fresh Open Source Software Archive 
Member "cb2bib-2.0.1/src/c2bConsole.cpp" (12 Feb 2021, 3004 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "c2bConsole.cpp" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
2.0.0_vs_2.0.1.
1 /***************************************************************************
2 * Copyright (C) 2004-2021 by Pere Constans
3 * constans@molspaces.com
4 * cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
5 * See the LICENSE file that comes with this distribution.
6 ***************************************************************************/
7 #include "c2bConsole.h"
8
9 #include "c2bNetworkQuery.h"
10 #include "c2bSettings.h"
11 #include "c2bTests.h"
12
13 #include <bibExtractor.h>
14 #include <bibParser.h>
15 #include <collectionIndex.h>
16 #include <metadataParser.h>
17 #include <texToHtml.h>
18
19 #include <QCoreApplication>
20 #include <QTimer>
21
22
23 c2bConsole::c2bConsole(QObject* parento) : QObject(parento) {}
24
25 c2bConsole::~c2bConsole() {}
26
27
28 void c2bConsole::load()
29 {
30 // Send _process to application cue
31 QTimer::singleShot(0, this, SLOT(_process()));
32 }
33
34 void c2bConsole::_process()
35 {
36 int code(0);
37 if (c2bSettingsP->cl_html_annote)
38 code = cl_html_annote();
39 else if (c2bSettingsP->cl_doc2bib)
40 code = cl_doc2bib();
41 else if (c2bSettingsP->cl_txt2bib)
42 code = cl_txt2bib();
43 else if (c2bSettingsP->cl_index)
44 code = cl_index();
45 else if (c2bSettingsP->cl_cb2bib_tests)
46 code = cl_cb2bib_tests();
47 else if (c2bSettingsP->cl_cb2bib_information)
48 code = cl_cb2bib_information();
49 QCoreApplication::exit(code);
50 }
51
52 int c2bConsole::cl_html_annote()
53 {
54 if (QFileInfo::exists(c2bSettingsP->cl_annote_filename))
55 {
56 const QString tex(c2bUtils::fileToString(c2bSettingsP->cl_annote_filename));
57 const QString htmlf(c2bSettingsP->cl_annote_filename + ".html");
58 texToHtml t2h;
59 t2h.toHtml(tex, htmlf);
60 return 0;
61 }
62 else
63 {
64 c2bUtils::warn(QObject::tr("Error: Could not open %1 file for reading").arg(c2bSettingsP->cl_annote_filename));
65 return 1;
66 }
67 }
68
69 int c2bConsole::cl_doc2bib()
70 {
71 bibParser bp;
72 metadataParser mp(&bp);
73 c2bNetworkQuery nq(&bp); // needs c2bUtils::fromHtmlString
74 bibExtractor be(&bp, &mp, &nq);
75 const int c(be.extract(c2bSettingsP->cl_extract_input_filenames, c2bSettingsP->cl_extract_output_filename,
76 bibExtractor::Document));
77 return c;
78 }
79
80 int c2bConsole::cl_txt2bib()
81 {
82 bibParser bp;
83 metadataParser mp(&bp);
84 c2bNetworkQuery nq(&bp);
85 bibExtractor be(&bp, &mp, &nq);
86 const int c(be.extract(c2bSettingsP->cl_extract_input_filenames, c2bSettingsP->cl_extract_output_filename,
87 bibExtractor::PlainText));
88 return c;
89 }
90
91 int c2bConsole::cl_index()
92 {
93 bibParser bp;
94 collectionIndex ci(&bp);
95 const int c(ci.index(c2bSettingsP->cl_index_dirname));
96 return c;
97 }
98
99 int c2bConsole::cl_cb2bib_information()
100 {
101 c2bTests* t(new c2bTests());
102 const int passed(t->writeInformation());
103 delete t;
104 return passed;
105 }
106
107 int c2bConsole::cl_cb2bib_tests()
108 {
109 c2bTests* t(new c2bTests());
110 const int passed(t->allTests());
111 delete t;
112 return passed;
113 }