00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CMDLINEOPTIONS_H
00019 #define CMDLINEOPTIONS_H
00020
00021 #include <string>
00022 #include <map>
00023 #include <cstdlib>
00024 #include <iostream>
00025 #include <fstream>
00026
00027 #include "platform_fs.h"
00028 #include "configurationreader.h"
00029 #include "datadir.h"
00030 #include "enums.h"
00031
00032 #ifdef _WIN32
00033 #include <windows.h>
00034 #endif
00035
00036
00037 #if defined(_WIN32) || defined(__SVR4) || defined(__sun__)
00038
00039 #ifndef USE_LOCAL_GETOPT
00040 #define USE_LOCAL_GETOPT
00041 #endif
00042 #endif
00043
00044 #ifdef USE_LOCAL_GETOPT
00045 #include "getopt.h"
00046 #else
00047 #include <getopt.h>
00048 #endif
00049
00050 #define OPT_VERBOSE "verbose"
00051 #define OPT_INC_STYLE "include-style"
00052 #define OPT_HELP "help"
00053 #define OPT_LINENO "linenumbers"
00054 #define OPT_XHTML "xhtml"
00055 #define OPT_RTF "rtf"
00056 #define OPT_TEX "tex"
00057 #define OPT_LATEX "latex"
00058 #define OPT_XSLFO "xsl-fo"
00059 #define OPT_FRAGMENT "fragment"
00060 #define OPT_ANCHORS "anchors"
00061 #define OPT_LISTTHEMES "list-themes"
00062 #define OPT_LISTLANGS "list-langs"
00063 #define OPT_VERSION "version"
00064 #define OPT_IN "input"
00065 #define OPT_OUT "output"
00066 #define OPT_SYNTAX "syntax"
00067 #define OPT_STYLE "style"
00068 #define OPT_STYLE_OUT "style-outfile"
00069 #define OPT_STYLE_IN "style-infile"
00070
00071 #define OPT_DELTABS "replace-tabs"
00072 #define OPT_BATCHREC "batch-recursive"
00073 #define OPT_OUTDIR "outdir"
00074 #define OPT_FORMATSTYLE "format-style"
00075 #define OPT_DATADIR "data-dir"
00076 #define OPT_ADDDATADIR "add-data-dir"
00077 #define OPT_INDEXFILE "print-index"
00078 #define OPT_HELPINT "help-int"
00079 #define OPT_WRAP "wrap"
00080 #define OPT_WRAPSIMPLE "wrap-simple"
00081 #define OPT_QUIET "quiet"
00082 #define OPT_REPLACE_QUOTES "replace-quotes"
00083 #define OPT_FOP "fop-compatible"
00084 #define OPT_PROGRESSBAR "progress"
00085 #define OPT_FILLZEROES "zeroes"
00086 #define OPT_ANSI "ansi"
00087 #define OPT_XML "xml"
00088 #define OPT_ENCODING "encoding"
00089 #define OPT_FORCE_OUTPUT "force"
00090 #define OPT_ORDERED_LIST "ordered-list"
00091 #define OPT_LNR_WIDTH "line-number-width"
00092 #define OPT_BASE_FONT "font"
00093 #define OPT_BASE_FONT_SIZE "font-size"
00094 #define OPT_LNR_START "line-number-start"
00095 #define OPT_BABEL "babel"
00096 #define OPT_PAGE_SIZE "page-size"
00097
00098
00099 #define S_OPT_ANSI 'A'
00100 #define S_OPT_OUT 'o'
00101 #define S_OPT_IN 'i'
00102 #define S_OPT_SYNTAX 'S'
00103 #define S_OPT_VERBOSE 'v'
00104 #define S_OPT_INC_STYLE 'I'
00105 #define S_OPT_HELP 'h'
00106 #define S_OPT_HELPINT 'H'
00107 #define S_OPT_LINENO 'l'
00108 #define S_OPT_STYLE 's'
00109 #define S_OPT_STYLE_OUT 'c'
00110 #define S_OPT_STYLE_IN 'e'
00111 #define S_OPT_DELTABS 't'
00112 #define S_OPT_XHTML 'X'
00113 #define S_OPT_RTF 'R'
00114 #define S_OPT_TEX 'T'
00115 #define S_OPT_LATEX 'L'
00116 #define S_OPT_XSLFO 'Y'
00117 #define S_OPT_XML 'Z'
00118 #define S_OPT_BATCHREC 'B'
00119 #define S_OPT_FRAGMENT 'f'
00120 #define S_OPT_ANCHORS 'a'
00121 #define S_OPT_LISTTHEMES 'w'
00122 #define S_OPT_LISTLANGS 'p'
00123 #define S_OPT_OUTDIR 'O'
00124
00125 #define S_OPT_FORMATSTYLE 'F'
00126 #define S_OPT_DATADIR 'D'
00127 #define S_OPT_ADDDATADIR 'E'
00128 #define S_OPT_INDEXFILE 'C'
00129 #define S_OPT_WRAP 'W'
00130 #define S_OPT_WRAPSIMPLE 'V'
00131 #define S_OPT_QUIET 'q'
00132 #define S_OPT_FOP 'g'
00133 #define S_OPT_REPLACE_QUOTES 'r'
00134 #define S_OPT_VERSION 'Q'
00135 #define S_OPT_PROGRESSBAR 'P'
00136 #define S_OPT_FILLZEROES 'z'
00137 #define S_OPT_ENCODING 'u'
00138 #define S_OPT_LNR_WIDTH 'j'
00139 #define S_OPT_LNR_START 'm'
00140 #define S_OPT_BASE_FONT 'k'
00141 #define S_OPT_BASE_FONT_SIZE 'K'
00142 #define S_OPT_ORDERED_LIST 'n'
00143 #define S_OPT_BABEL 'b'
00144 #define S_OPT_PAGE_SIZE 'x'
00145
00146
00147 #define OPT_CSSOUT "css-outfile"
00148 #define OPT_CSSIN "css-infile"
00149 #define OPT_INC_CSS "include-css"
00150
00151 #define S_OPTIONS_STRING "abfghlnvwpqrzACILYRTZXUV::W::Pk:K:j:x:o:i:S:B:O:s:c:e:t:u:m:F:D:H:E:"
00152
00153 using namespace std;
00154
00157 class CmdLineOptions
00158 {
00159 public:
00160
00165 CmdLineOptions(int argc, char *argv[]);
00166 ~CmdLineOptions();
00167
00169 const string &getSingleOutFilename();
00170
00172 const string &getSingleInFilename() const;
00173
00175 const string& getOutDirectory() ;
00176
00178 const string getStyleOutFilename() const;
00179
00181 const string& getStyleInFilename() const;
00182
00184 const string& getEncoding() const;
00185
00187 int getNumberSpaces() const;
00188
00190 bool printVersion() const;
00191
00193 bool printHelp() const;
00194
00196 bool printDebugInfo()const;
00197
00199 bool includeStyleDef() const;
00200
00202 bool printLineNumbers() const;
00203
00205 string getStyleName()const ;
00206
00208 int helpLanguage() const;
00209
00211 bool enableBatchMode() const;
00212
00214 bool fragmentOutput() const;
00215
00217 string getOutFileSuffix() const;
00218
00220 bool attachLineAnchors() const;
00221
00223 bool showThemes() const;
00224
00226 bool showLangdefs() const;
00227
00229 bool outDirGiven() const;
00230
00232 bool formattingEnabled();
00233
00235 bool dataDirGiven()const;
00236
00238 bool additionalDataDirGiven()const;
00239
00241 bool printIndexFile() const;
00242
00244 bool replaceQuotes() const;
00245
00247 bool disableBabelShorthands() const;
00248
00250 const string &getDataDir()const;
00251
00253 const string &getAdditionalDataDir()const;
00254
00256 bool syntaxGiven() const;
00257
00259 bool quietMode() const;
00260
00262 bool fopCompatible() const;
00263
00265 bool printProgress() const;
00266
00268 bool fillLineNrZeroes() const;
00269
00271 const string getHelpLang() const;
00272
00274 const string &getLanguage()const ;
00275
00277 highlight::WrapMode getWrappingStyle() const;
00278
00280 const vector <string> & getInputFileNames() const;
00281
00283 const string &getIndentScheme() const;
00284
00286 const string &getPageSize() const;
00287
00289 highlight::OutputType getOutputType() const;
00290
00292 bool formatSupportsExtStyle();
00293
00295 bool styleOutPathDefined() const{
00296 return opt_stylepath_explicit;
00297 }
00298
00300 bool omitEncoding() const;
00301
00303 bool forceOutput() const;
00304
00306 bool orderedList() const;
00307
00309 bool hasBaseFont() const ;
00310
00312 const string& getBaseFont() const ;
00313
00315 bool hasBaseFontSize() const ;
00317 const string& getBaseFontSize() const ;
00318
00320 int getNumberWidth();
00321
00323 int getNumberStart();
00324
00325 private:
00326
00327 int numberSpaces;
00328 int lineNrWidth;
00329 int lineNrStart;
00330 highlight::WrapMode wrappingStyle;
00331 highlight::OutputType outputType;
00332
00333
00334 string outFilename,
00335
00336 outDirectory,
00337
00338 language,
00339
00340 styleName,
00341
00342 styleOutFilename,
00343
00344 styleInFilename,
00345
00346 dataDir, additionalDataDir;
00347
00348 string indentScheme,
00349 pageSize;
00350
00351
00352 string baseFont, baseFontSize;
00353
00354
00355
00356 bool opt_language;
00357 bool opt_include_style;
00358 bool opt_help;
00359 bool opt_version ;
00360 bool opt_verbose;
00361 bool opt_linenumbers;
00362 bool opt_style;
00363 bool opt_batch_mode;
00364 bool opt_fragment;
00365 bool opt_attach_line_anchors;
00366 bool opt_show_themes;
00367 bool opt_show_langdefs;
00368 bool opt_asformat_output;
00369 bool opt_printindex;
00370 bool opt_quiet;
00371 bool opt_xslfo_fop;
00372 bool opt_replacequotes;
00373 bool opt_babel;
00374 bool opt_print_progress;
00375 bool opt_fill_zeroes;
00376 bool opt_stylepath_explicit;
00377 bool opt_force_output;
00378 bool opt_ordered_list;
00379
00380 bool configFileRead;
00381
00382 string helpLang, encodingName;
00383 string configFilePath;
00384
00385
00386 vector <string> inputFileNames;
00387
00389 void loadConfigurationFile();
00390
00392 string getFileSuffix( const string & fileName) const;
00393
00395 string getDirName( const string & path);
00396
00398 void readDirectory(const string & wildcard);
00399
00401 bool getFlag(const string& paramVal);
00402
00404 string validateDirPath(const string & path);
00405
00406 void printDeprecatedWarning(const char *oldOption, const char *newOption);
00407 };
00408
00409 #endif