source: wkhtmltox/trunk/fuentes/src/shared/commandlineparserbase.hh @ 51

Last change on this file since 51 was 51, checked in by mabarracus, 4 years ago

wip

File size: 2.9 KB
Line 
1// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
2// vi:set ts=4 sts=4 sw=4 noet :
3//
4// Copyright 2010, 2011 wkhtmltopdf authors
5//
6// This file is part of wkhtmltopdf.
7//
8// wkhtmltopdf is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Lesser General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12//
13// wkhtmltopdf is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public License
19// along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
20
21#ifndef __COMMANDLINEPARSERBASE_HH__
22#define __COMMANDLINEPARSERBASE_HH__
23#include <wkhtmltox/loadsettings.hh>
24#include <wkhtmltox/websettings.hh>
25class Outputter;
26class CommandLineParserBase;
27
28class ArgHandler {
29public:
30        QString longName;
31        QString desc;
32        char shortSwitch;
33        QVector<QString> argn;
34        bool display;
35        bool extended;
36        bool qthack;
37        virtual QString getDesc() const;
38        virtual ~ArgHandler();
39        int section;
40        virtual bool operator() (const char ** args, CommandLineParserBase & parser, char * page) = 0;
41};
42
43class CommandLineParserBase {
44public:
45        int currentMode;
46        QString currentSection;
47        bool currentExtended;
48        bool currentHack;
49
50        QList<QString> sections;
51        QHash<QString, ArgHandler *> longToHandler;
52        QHash<char, ArgHandler *> shortToHandler;
53        QHash<QString, QList<ArgHandler *> > sectionArgumentHandles;
54        QHash<QString, QString> sectionDesc;
55
56        //basearguments.cc
57        void section(QString s, QString desc="");
58        void mode(int m);
59        void qthack(bool);
60        void extended(bool);
61
62        void addarg(QString, char, QString, ArgHandler * h, bool display=true);
63        void addDocArgs();
64        void addWebArgs(wkhtmltopdf::settings::Web & s);
65        void addGlobalLoadArgs(wkhtmltopdf::settings::LoadGlobal & s);
66        void addPageLoadArgs(wkhtmltopdf::settings::LoadPage & s);
67
68        //commondocparts.cc
69        void outputName(Outputter * o) const;
70        void outputLicense(Outputter * o) const;
71        void outputAuthors(Outputter * o) const;
72        void outputStaticProblems(Outputter * o) const;
73        void outputProxyDoc(Outputter * o) const;
74
75        //commandlineparserbase.cc
76        void outputSwitches(Outputter * o, bool extended, bool doc) const;
77        virtual char * mapAddress(char * d, char *) const {return d;}
78        virtual void license(FILE * fd) const;
79        virtual void version(FILE * fd) const;
80        void parseArg(int sections, const int argc, const char ** argv, bool & defaultMode, int & arg, char * page);
81
82        virtual QString appName() const = 0;
83        const char *appVersion() const;
84        virtual void usage(FILE * fd, bool extended) const = 0;
85        virtual void manpage(FILE * fd) const = 0;
86        virtual void readme(FILE * fd, bool html) const = 0;
87};
88#endif //__COMMANDLINEPARSERBASE_HH__
Note: See TracBrowser for help on using the repository browser.