1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef ADC_ADC_CMD_HXX 29 #define ADC_ADC_CMD_HXX 30 31 32 33 // USED SERVICES 34 // BASE CLASSES 35 #include <cosv/comdline.hxx> 36 // COMPONENTS 37 // PARAMETERS 38 39 40 namespace autodoc 41 { 42 namespace command 43 { 44 45 /** Context for a command, which can be read from the command line. 46 */ 47 class Context 48 { 49 public: 50 typedef StringVector::const_iterator opt_iter; 51 52 virtual ~Context() {} 53 54 void Init( 55 opt_iter & it, 56 opt_iter itEnd ); 57 private: 58 virtual void do_Init( 59 opt_iter & it, 60 opt_iter itEnd ) = 0; 61 }; 62 63 // IMPLEMENTATION 64 inline void 65 Context::Init( opt_iter & i_nCurArgsBegin, 66 opt_iter i_nEndOfAllArgs ) 67 68 { do_Init(i_nCurArgsBegin, i_nEndOfAllArgs); } 69 70 71 72 /** Interface for commands, autodoc is able to perform. 73 */ 74 class Command : public Context 75 { 76 public: 77 /** Running ranks of the commands are to be maintained at one location: 78 Here! 79 */ 80 enum E_Ranks 81 { 82 rank_Load = 10, 83 rank_Parse = 20, 84 rank_Save = 30, 85 rank_CreateHtml = 40, 86 rank_CreateXml = 50 87 }; 88 89 90 bool Run() const; 91 int RunningRank() const; 92 93 private: 94 virtual bool do_Run() const = 0; 95 virtual int inq_RunningRank() const = 0; 96 }; 97 98 // IMPLEMENTATION 99 inline bool 100 Command::Run() const 101 { return do_Run(); } 102 inline int 103 Command::RunningRank() const 104 { return inq_RunningRank(); } 105 106 107 108 109 /** The exception thrown, if the command line is invalid. 110 */ 111 class X_CommandLine 112 { 113 public: 114 X_CommandLine( 115 const char * i_sExplanation ) 116 : sExplanation(i_sExplanation) {} 117 118 void Report( 119 std::ostream & o_rOut ) 120 { o_rOut << "Error in command line: " 121 << sExplanation << Endl(); } 122 private: 123 String sExplanation; 124 }; 125 126 127 128 129 } // namespace command 130 } // namespace autodoc 131 #endif 132